Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Некоторое количество исправлений по коду #355

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 10 additions & 56 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,68 +5,22 @@
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
.idea/inspectionProfiles/Project_Default.xml
.idea/material_theme_project_new.xml
.idea/jarRepositories.xml
.idea/misc.xml
.idea/vcs.xml
.idea/sonarlint/
.idea/sonarlint*.xml

# Gradle
.gradle/
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
.idea/modules.xml
.idea/*.iml
.idea/modules

# IntelliJ
out/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

.gradle/
*.zip
*.ps1
target/
.idea/compiler.xml
build/

# Scala compiler user settings
.idea/hydra.xml

.idea/sonarlint/

intellij-bsl/src/test/resources/parser/.idea/

gen/

# Crashlytics plugin (for Android Studio and IntelliJ)

\.idea/sonarlint-state\.xml

\.idea/sonarlint\.xml
/.idea/jarRepositories.xml
/.idea/vcs.xml
/.idea/compiler.xml
/.idea/inspectionProfiles/Project_Default.xml
/.idea/misc.xml
/.idea/material_theme_project_new.xml
2 changes: 1 addition & 1 deletion .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ English version -> https://1c-syntax.github.io/sonar-bsl-plugin-community/en/

## Матрица соответствия версий

Версия SonarQube | Версия плагина | Версия JAVA
-----------------|----------------|------------------
9.9+ | 1.13.0+ | 17
8.9+ | 1.11.0...1.12.0| 11
7.9+ | 0.7.0....1.10.0| 11
7.4 - 7.8 | 0.1.0....0.6.0 | 8
| Версия SonarQube | Версия плагина | Версия JAVA |
|------------------|-----------------|-------------|
| 25.1+ | 1.15.2+ | 17 |
| 9.9+ | 1.13.0+ | 17 |
| 8.9+ | 1.11.0...1.12.0 | 11 |
| 7.9+ | 0.7.0....1.10.0 | 11 |
| 7.4 - 7.8 | 0.1.0....0.6.0 | 8 |
15 changes: 8 additions & 7 deletions docs/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@

## Version matrix

SonarQube Version | Plugin Version | JAVA version
------------------|----------------|------------------
9.9+ | 1.13.0+ | 17
8.9+ | 1.11.0...1.12.0| 11
7.9+ | 0.7.0...1.10.0 | 11
7.4 - 7.8 | 0.1.0...0.6.0 | 8
| SonarQube Version | Plugin Version | JAVA version |
|-------------------|-----------------|--------------|
| 25.1+ | 1.15.2+ | 17 |
| 9.9+ | 1.13.0+ | 17 |
| 8.9+ | 1.11.0...1.12.0 | 11 |
| 7.9+ | 0.7.0...1.10.0 | 11 |
| 7.4 - 7.8 | 0.1.0...0.6.0 | 8 |

## Run analysis

Expand Down Expand Up @@ -74,7 +75,7 @@ If the SonarQube server has enabled the requirement of forced authorization and/
### For example

```sh
sonar-scanner -Dsonar.host.url=http://sonar.company.com -Dsonar.login=SONAR_AUTH_TOKEN
sonar-scanner -Dsonar.host.url=https://sonar.company.com -Dsonar.login=SONAR_AUTH_TOKEN
```

## Plugin settings
Expand Down
23 changes: 12 additions & 11 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Расчет базовых метрик, расчет количества строк кода;
* Регистрация диагностик, предоставляемых [BSL Language Server](https://1c-syntax.github.io/bsl-language-server) как внутренних правил;
* Встроенный анализатор - BSL Language Server Diagnostic provider
* Импорт результатов внешних анализаторов во внутреннем формате [json](https://1c-syntax.github.io/bsl-language-server/reporters/json.html);
* Импорт результатов внешних анализаторов во внутреннем формате [json](https://1c-syntax.github.io/bsl-language-server/reporters/json.html)

## Установка и обновление

Expand All @@ -31,12 +31,13 @@

## Матрица соответствия версий

Версия SonarQube | Версия плагина | Версия JAVA
-----------------|----------------|------------------
9.9+ | 1.13.0+ | 17
8.9+ | 1.11.0...1.12.0| 11
7.9+ | 0.7.0...1.10.0 | 11
7.4 - 7.8 | 0.1.0...0.6.0 | 8
| Версия SonarQube | Версия плагина | Версия JAVA |
|------------------|-----------------|-------------|
| 25.1+ | 1.15.2+ | 17 |
| 9.9+ | 1.13.0+ | 17 |
| 8.9+ | 1.11.0...1.12.0 | 11 |
| 7.9+ | 0.7.0...1.10.0 | 11 |
| 7.4 - 7.8 | 0.1.0...0.6.0 | 8 |

## Запуск анализа

Expand Down Expand Up @@ -142,7 +143,7 @@ sonar-scanner -Dsonar.bsl.languageserver.reportPaths=./bsl-json.json

Для расчета строк покрытия используйте утилиту Coverage41C или подобную, возвращающую полные данные по покрытию.

## Интеграция с Автоматизированная проверка конфигураций
## Интеграция с "Автоматизированная проверка конфигураций"

*Доступна с версии 1.6*

Expand All @@ -153,7 +154,7 @@ sonar-scanner -Dsonar.bsl.languageserver.reportPaths=./bsl-json.json
**Важно** Так как ключом правила является код ошибки из АПК, то сопоставление работает только если при выгрузке ошибок
обработкой [acc-export](https://github.com/otymko/acc-export) указать acc.titleError=code

Cвойство `sonar.bsl.acc.accRulesPaths`. Правила из поставки можно расширить за счет свойих внешних файлов в формате:
Свойство `sonar.bsl.acc.accRulesPaths`. Правила из поставки можно расширить за счет своих внешних файлов в формате:
```
{
"Rules": [
Expand All @@ -171,8 +172,8 @@ Cвойство `sonar.bsl.acc.accRulesPaths`. Правила из постав
}
```

Cвойство `sonar.bsl.acc.createExternalIssues`. Определяет как поступить с ошибками, которые были в файле, но для них
не было найдено активного правила. Для фильтрации ошибок поступающих от АПК на строне sonarqube потребуется отключить
Свойство `sonar.bsl.acc.createExternalIssues`. Определяет как поступить с ошибками, которые были в файле, но для них
не было найдено активного правила. Для фильтрации ошибок поступающих от АПК на стороне sonarqube потребуется отключить
свойство.

## Интеграция с 1C:EDT
Expand Down
4 changes: 0 additions & 4 deletions jitpack.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import com.github._1c_syntax.bsl.languageserver.configuration.Language;
import com.github._1c_syntax.bsl.languageserver.configuration.diagnostics.SkipSupport;
import lombok.experimental.UtilityClass;
import org.sonar.api.PropertyType;
import org.sonar.api.config.PropertyDefinition;
import org.sonar.api.resources.Qualifiers;
Expand All @@ -32,17 +33,19 @@
import java.util.Locale;
import java.util.stream.Stream;


public final class BSLCommunityProperties {
@UtilityClass
public class BSLCommunityProperties {

public static final String LANG_SERVER_DIAGNOSTIC_LANGUAGE_KEY = "sonar.bsl.languageserver.diagnosticLanguage";
public static final String LANG_SERVER_COMPUTE_DIAGNOSTICS_SKIP_SUPPORT_KEY = "sonar.bsl.languageserver.skipSupport";
public static final String LANG_SERVER_ENABLED_KEY = "sonar.bsl.languageserver.enabled";
public static final String LANG_SERVER_CONFIGURATION_PATH_KEY = "sonar.bsl.languageserver.configurationPath";
public static final String LANG_SERVER_OVERRIDE_CONFIGURATION_KEY = "sonar.bsl.languageserver.overrideConfiguration";
public static final String LANG_SERVER_REPORT_PATH_KEY = "sonar.bsl.languageserver.reportPaths";
public static final String LANG_SERVER_SUBSYSTEM_FILTER_INCLUDE_KEY = "sonar.bsl.languageserver.subsystemsFilter.include";
public static final String LANG_SERVER_SUBSYSTEM_FILTER_EXCLUDE_KEY = "sonar.bsl.languageserver.subsystemsFilter.exclude";
public static final String LANG_SERVER_SUBSYSTEM_FILTER_INCLUDE_KEY
= "sonar.bsl.languageserver.subsystemsFilter.include";
public static final String LANG_SERVER_SUBSYSTEM_FILTER_EXCLUDE_KEY
= "sonar.bsl.languageserver.subsystemsFilter.exclude";
public static final String BSL_FILE_EXTENSIONS_KEY = "sonar.bsl.file.suffixes";

public static final Boolean LANG_SERVER_ENABLED_DEFAULT_VALUE = Boolean.TRUE;
Expand All @@ -58,10 +61,6 @@ public final class BSLCommunityProperties {

private static final String BSL_SUBCATEGORY = "1C (BSL) Community";

private BSLCommunityProperties() {
// only statics
}

public static List<PropertyDefinition> getProperties() {
return Arrays.asList(
PropertyDefinitionUtils.newPropertyBuilderBSL(0,
Expand Down Expand Up @@ -108,9 +107,9 @@ public static List<PropertyDefinition> getProperties() {
LANG_SERVER_SUBSYSTEM_FILTER_INCLUDE_KEY,
"subsystemfilter.include",
"")
.onQualifiers(Qualifiers.PROJECT)
.multiValues(true)
.build(),
.onQualifiers(Qualifiers.PROJECT)
.multiValues(true)
.build(),
PropertyDefinitionUtils.newPropertyBuilderBSL(6,
LANG_SERVER_SUBSYSTEM_FILTER_EXCLUDE_KEY,
"subsystemfilter.exclude",
Expand Down
27 changes: 4 additions & 23 deletions src/main/java/com/github/_1c_syntax/bsl/sonar/BSLHighlighter.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,7 @@ public void saveHighlighting(InputFile inputFile, DocumentContext documentContex

if (startChar < endChar) {
// add string part
highlightingData.add(new HighlightingData(
line,
startChar,
endChar,
typeOfText
));
highlightingData.add(new HighlightingData(line, startChar, endChar, typeOfText));
}

endChar = currentToken.getRange().getEnd().getCharacter();
Expand All @@ -147,22 +142,14 @@ public void saveHighlighting(InputFile inputFile, DocumentContext documentContex
var typeOfText = string.getType();

if (startChar < endChar) {
highlightingData.add(new HighlightingData(
line,
startChar,
endChar,
typeOfText
));
highlightingData.add(new HighlightingData(line, startChar, endChar, typeOfText));
}
});

// merge collected bsl tokens with sdbl tokens
highlightingDataSDBL.values().forEach(highlightingData::addAll);

if (highlightingData.stream()
.filter(HighlightingData::isActive)
.findAny()
.isEmpty()) {
if (highlightingData.stream().filter(HighlightingData::isActive).findAny().isEmpty()) {
return;
}

Expand Down Expand Up @@ -200,16 +187,10 @@ public void highlightToken(
var range = Ranges.create(
line,
charPositionInLine,
line,
charPositionInLine + (int) tokenText.codePoints().count()
);

var data = new HighlightingData(
range,
typeOfText
);

highlightingData.add(data);
highlightingData.add(new HighlightingData(range, typeOfText));
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,20 @@
*/
package com.github._1c_syntax.bsl.sonar;

import lombok.experimental.UtilityClass;
import org.sonar.api.config.PropertyDefinition;

import java.util.ResourceBundle;

/**
* Вспомогательный класс для создания параметров плагина с выводом в UI
*/
@UtilityClass
public class PropertyDefinitionUtils {

private static final String PREFIX_KEY = "communitybsl";
private static final ResourceBundle L10N_BUNDLE = ResourceBundle.getBundle("org.sonar.l10n.communitybsl");

private static final String EXTERNAL_ANALYZERS_CATEGORY = "External Analyzers";

private PropertyDefinitionUtils() {
// static class
}

public static PropertyDefinition.Builder newPropertyBuilderBSL(int index,
String key,
String l10nKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,11 @@ protected QualityProfile(Configuration config, Reporter reporter) {
}

protected void define(Context context) {
if (!isEnabled) {
return;
}

addFullCheckProfile(context);
if (reporter.isInclude1CCertifiedProfile()) {
add1CCertifiedProfile(context);
if (isEnabled) {
addFullCheckProfile(context);
if (reporter.isInclude1CCertifiedProfile()) {
add1CCertifiedProfile(context);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,11 @@ protected RuleDefinition(Configuration config, Reporter properties) {
}

protected void define(Context context) {
if (!enabled) {
return;
if (enabled) {
repository = context.createRepository(repositoryKey, BSLLanguage.KEY).setName(repositoryName);
loadRules();
repository.done();
}

repository = context.createRepository(repositoryKey, BSLLanguage.KEY).setName(repositoryName);
loadRules();
repository.done();
}

private void loadRules() {
Expand Down
Loading
Loading