diff --git a/src/main/java/com/github/_1c_syntax/bsl/sonar/BSLCoreSensor.java b/src/main/java/com/github/_1c_syntax/bsl/sonar/BSLCoreSensor.java index 7688ab6c..300d2e2b 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/sonar/BSLCoreSensor.java +++ b/src/main/java/com/github/_1c_syntax/bsl/sonar/BSLCoreSensor.java @@ -227,7 +227,7 @@ private void saveCpd(InputFile inputFile, DocumentContext documentContext) { line, charPositionInLine, line, - charPositionInLine + tokenText.length(), + charPositionInLine + (int) tokenText.codePoints().count(), tokenText ); } diff --git a/src/main/java/com/github/_1c_syntax/bsl/sonar/BSLHighlighter.java b/src/main/java/com/github/_1c_syntax/bsl/sonar/BSLHighlighter.java index 01f9b2cd..56377b47 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/sonar/BSLHighlighter.java +++ b/src/main/java/com/github/_1c_syntax/bsl/sonar/BSLHighlighter.java @@ -201,7 +201,7 @@ public void highlightToken( line, charPositionInLine, line, - charPositionInLine + tokenText.length() + charPositionInLine + (int) tokenText.codePoints().count() ); var data = new HighlightingData( diff --git a/src/test/java/com/github/_1c_syntax/bsl/sonar/BSLCoreSensorTest.java b/src/test/java/com/github/_1c_syntax/bsl/sonar/BSLCoreSensorTest.java index dc13037b..542857bc 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/sonar/BSLCoreSensorTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/sonar/BSLCoreSensorTest.java @@ -205,7 +205,7 @@ void testComplexity() { // todo надо как-то нормально ключ компонента определить var componentKey = "moduleKey:" + FILE_NAME; assertThat(context.measures(componentKey)).isNotEmpty(); - assertThat(context.measure(componentKey, CoreMetrics.COMPLEXITY).value()).isEqualTo(3); + assertThat(context.measure(componentKey, CoreMetrics.COMPLEXITY).value()).isEqualTo(5); assertThat(context.measure(componentKey, CoreMetrics.COGNITIVE_COMPLEXITY).value()).isEqualTo(1); } @@ -225,7 +225,7 @@ void testCPD() { var componentKey = "moduleKey:" + FILE_NAME; assertThat(context.cpdTokens(componentKey)) .isNotNull() - .hasSize(13); + .hasSize(19); assertThat(context.cpdTokens(componentKey)) .filteredOn(tok -> tok.getValue().startsWith("ОставшийсяТокен")) .hasSize(1); diff --git a/src/test/resources/examples/src/test.bsl b/src/test/resources/examples/src/test.bsl index 275bc30d..6f2128ed 100644 --- a/src/test/resources/examples/src/test.bsl +++ b/src/test/resources/examples/src/test.bsl @@ -15,6 +15,14 @@ #КонецВставки КонецПроцедуры +Функция ФункцияКотораяДолжнаНеУпасть() + Возврат "🟡"; +КонецФункции + +Функция ФункцияКотораяНеУпадет() + Возврат "✅"; +КонецФункции + #Область Тест Проверка = Истина;