Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
java_version: ['17', '21']
java_version: ['21', '25']
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/night_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v5
with:
java-version: 17
java-version: 21
distribution: 'adopt'
- name: Build with Gradle
run: ./gradlew build
Expand Down
26 changes: 14 additions & 12 deletions .github/workflows/pluginTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
steps:
- uses: actions/checkout@v6

- name: Set up JDK 17
- name: Set up JDK
uses: actions/setup-java@v5
with:
java-version: '17'
distribution: 'adopt'
java-version: '21'
distribution: 'temurin'
cache: 'gradle'

- name: Build Plugin
Expand Down Expand Up @@ -41,16 +41,18 @@ jobs:
repository: '1c-syntax/ssl_3_1'
path: 'target-project'

- name: Run Sonar Scanner
- name: Install Sonar scanner
run: npm install -g sonar-scanner

- name: SonarQube Scan
run: |
docker run --rm --network="host" -v "$(pwd)/target-project:/usr/src" \
sonarsource/sonar-scanner-cli \
-Dsonar.projectKey=test-project \
-Dsonar.sources=. \
-Dsonar.host.url=http://localhost:9000 \
-Dsonar.token=${{ env.SONAR_TOKEN }} \
-Dsonar.lang.patterns.bsl=**/*.bsl,**/*.os \
-Dsonar.scm.disabled=true
sonar-scanner \
-Dsonar.projectKey=test-project \
-Dsonar.sources=target-project \
-Dsonar.host.url=http://localhost:9000 \
-Dsonar.token=${{ env.SONAR_TOKEN }} \
-Dsonar.lang.patterns.bsl=**/*.bsl,**/*.os \
-Dsonar.scm.disabled=true

- name: Server Logs on Failure
if: failure()
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
fetch-depth: ''
- run: |
git fetch --prune --unshallow
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: 17
java-version: 21
distribution: 'adopt'
- name: SonarCloud Scan
run: ./gradlew check sonar
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v5
with:
java-version: 17
java-version: 21
distribution: 'adopt'
- name: Build with Gradle
run: ./gradlew build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update-gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
steps:
- uses: actions/checkout@v6

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: 17
java-version: 21
distribution: 'temurin'
cache: gradle

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ English version -> https://1c-syntax.github.io/sonar-bsl-plugin-community/en/

| Версия SonarQube | Версия плагина | Версия JAVA |
|------------------|-----------------|-------------|
| 25.1+ | 1.15.2+ | 17 |
| 9.9+ | 1.13.0+ | 17 |
| 25.4+ | 1.18.0+ | 21 |
| 25.1+ | 1.15.2...1.17.2 | 17 |
| 9.9+ | 1.13.0...1.17.2 | 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 |
40 changes: 22 additions & 18 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,44 @@ repositories {
maven("https://central.sonatype.com/repository/maven-snapshots")
}

val sonarQubeVersion = "9.9.0.65466"
val sonarQubeVersion = "25.4.0.105899"
val commonmarkVersion = "0.27.1"

dependencies {
compileOnly("org.sonarsource.api.plugin", "sonar-plugin-api", "9.14.0.375")
compileOnly("org.sonarsource.api.plugin", "sonar-plugin-api", "11.3.0.2824")

implementation("io.github.1c-syntax", "bsl-language-server", "0.28.5") {
exclude("com.contrastsecurity", "java-sarif")
exclude("io.sentry", "sentry-logback")
exclude("info.picocli", "picocli-spring-boot-starter")
exclude("me.tongfei", "progressbar")
}
implementation("org.sonarsource.analyzer-commons", "sonar-analyzer-commons", "2.5.0.1358")
implementation("org.sonarsource.analyzer-commons", "sonar-analyzer-commons", "2.21.0.4626")

// MD to HTML converter of BSL LS rule descriptions
implementation("org.commonmark", "commonmark", "0.24.0")
implementation("org.commonmark", "commonmark-ext-gfm-tables", "0.24.0")
implementation("org.commonmark", "commonmark-ext-autolink", "0.24.0")
implementation("org.commonmark", "commonmark-ext-heading-anchor", "0.24.0")

testImplementation("org.junit.jupiter", "junit-jupiter-api", "5.11.4")
testImplementation("org.assertj", "assertj-core", "3.27.0")
testImplementation("org.mockito", "mockito-core", "5.14.2")
testImplementation("org.sonarsource.sonarqube", "sonar-testing-harness", sonarQubeVersion)
testImplementation("org.sonarsource.sonarqube", "sonar-core", sonarQubeVersion)
implementation("org.commonmark", "commonmark", commonmarkVersion)
implementation("org.commonmark", "commonmark-ext-gfm-tables", commonmarkVersion)
implementation("org.commonmark", "commonmark-ext-autolink", commonmarkVersion)
implementation("org.commonmark", "commonmark-ext-heading-anchor", commonmarkVersion)

testImplementation("org.junit.jupiter", "junit-jupiter-api", "6.0.3")
testImplementation("org.assertj", "assertj-core", "3.27.7")
testImplementation("org.mockito", "mockito-core", "5.21.0")
testImplementation("org.sonarsource.sonarqube", "sonar-testing-harness", sonarQubeVersion) {
exclude("org.sonarsource.sonarqube", "sonar-sarif")
}
testImplementation("org.sonarsource.sonarqube", "sonar-core", sonarQubeVersion) {
exclude("org.sonarsource.sonarqube", "sonar-sarif")
}
testImplementation("org.reflections", "reflections", "0.10.2")

testRuntimeOnly("org.junit.jupiter", "junit-jupiter-engine", "5.11.4")
testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.11.4")
testRuntimeOnly("org.junit.jupiter", "junit-jupiter-engine", "6.0.3")
testRuntimeOnly("org.junit.platform", "junit-platform-launcher", "6.0.3")
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

tasks.withType<JavaCompile> {
Expand Down Expand Up @@ -127,7 +132,6 @@ tasks.jar {
attributes["Plugin-Developers"] = "Alexey Sosnoviy, Nikita Fedkin"

attributes["SonarLint-Supported"] = false
attributes["Sonar-Version"] = sonarQubeVersion

attributes["Plugin-Organization"] = "1c-syntax"
attributes["Plugin-OrganizationUrl"] = "https://github.com/1c-syntax"
Expand Down
1 change: 1 addition & 0 deletions lombok.config
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
lombok.anyConstructor.addConstructorProperties=true
lombok.addLombokGeneratedAnnotation=true
lombok.log.fieldName=LOGGER
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import lombok.experimental.UtilityClass;
import org.sonar.api.PropertyType;
import org.sonar.api.config.PropertyDefinition;
import org.sonar.api.resources.Qualifiers;

import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -69,14 +68,12 @@ public static List<PropertyDefinition> getProperties() {
LANG_SERVER_DIAGNOSTIC_LANGUAGE_DEFAULT_VALUE)
.type(PropertyType.SINGLE_SELECT_LIST)
.options(Language.RU.getLanguageCode(), Language.EN.getLanguageCode())
.onQualifiers(Qualifiers.APP, Qualifiers.PROJECT)
.build(),
PropertyDefinitionUtils.newPropertyBuilderBSL(1,
LANG_SERVER_ENABLED_KEY,
"enabled",
LANG_SERVER_ENABLED_DEFAULT_VALUE.toString())
.type(PropertyType.BOOLEAN)
.onQualifiers(Qualifiers.PROJECT)
.build(),
PropertyDefinitionUtils.newPropertyBuilderBSL(2,
LANG_SERVER_COMPUTE_DIAGNOSTICS_SKIP_SUPPORT_KEY,
Expand All @@ -87,49 +84,42 @@ public static List<PropertyDefinition> getProperties() {
.map(value -> value.name().toLowerCase(Locale.ENGLISH).replace("_", " "))
.toList()
)
.onQualifiers(Qualifiers.PROJECT)
.build(),
PropertyDefinitionUtils.newPropertyBuilderBSL(3,
LANG_SERVER_OVERRIDE_CONFIGURATION_KEY,
"overrideConfiguration",
LANG_SERVER_OVERRIDE_CONFIGURATION_DEFAULT_VALUE.toString())
.type(PropertyType.BOOLEAN)
.onQualifiers(Qualifiers.PROJECT)
.build(),
PropertyDefinitionUtils.newPropertyBuilderBSL(4,
LANG_SERVER_CONFIGURATION_PATH_KEY,
"enabled.configurationPath",
LANG_SERVER_CONFIGURATION_PATH_DEFAULT_VALUE)
.type(PropertyType.STRING)
.onQualifiers(Qualifiers.PROJECT)
.build(),
PropertyDefinitionUtils.newPropertyBuilderBSL(5,
LANG_SERVER_SUBSYSTEM_FILTER_INCLUDE_KEY,
"subsystemfilter.include",
"")
.onQualifiers(Qualifiers.PROJECT)
.multiValues(true)
.build(),
PropertyDefinitionUtils.newPropertyBuilderBSL(6,
LANG_SERVER_SUBSYSTEM_FILTER_EXCLUDE_KEY,
"subsystemfilter.exclude",
"")
.onQualifiers(Qualifiers.PROJECT)
.multiValues(true)
.build(),
PropertyDefinitionUtils.newPropertyBuilderBSL(7,
BSL_FILE_EXTENSIONS_KEY,
"file.suffixes",
BSL_FILE_EXTENSIONS_DEFAULT_VALUE)
.onQualifiers(Qualifiers.PROJECT)
.multiValues(true)
.build(),
PropertyDefinitionUtils.newPropertyBuilderExternal(0,
LANG_SERVER_REPORT_PATH_KEY,
"reportPaths",
"")
.subCategory(BSL_SUBCATEGORY)
.onQualifiers(Qualifiers.PROJECT)
.multiValues(true)
.build()
);
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/com/github/_1c_syntax/bsl/sonar/BSLCoreSensor.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.github._1c_syntax.bsl.sonar.language.BSLLanguage;
import com.github._1c_syntax.bsl.sonar.language.BSLLanguageServerRuleDefinition;
import com.github._1c_syntax.utils.Absolute;
import lombok.extern.slf4j.Slf4j;
import org.antlr.v4.runtime.Token;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.lsp4j.Diagnostic;
Expand All @@ -46,8 +47,6 @@
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.FileLinesContextFactory;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;

import java.io.File;
import java.nio.file.Path;
Expand All @@ -60,12 +59,13 @@
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

@Slf4j
public class BSLCoreSensor implements Sensor {

private static final Logger LOGGER = Loggers.get(BSLCoreSensor.class);
private static final int COUNT_FILES_PB = 100;
private final SensorContext context;
private final FileLinesContextFactory fileLinesContextFactory;

Expand Down Expand Up @@ -159,19 +159,19 @@ public void execute(SensorContext context) {
bslServerContext.populateContext();

int total = inputFilesList.size();
final int[] count = {0};
var count = new AtomicInteger(0);

inputFilesList.parallelStream().forEach((InputFile inputFile) -> {
var uri = inputFile.uri();
LOGGER.debug(uri.toString());
processFile(inputFile, bslServerContext);
count[0]++;
if (count[0] % 100 == 0) {
LOGGER.info("Processing files: {}/{}", count[0], total);
var current = count.incrementAndGet();
if (current % COUNT_FILES_PB == 0) {
LOGGER.info("Processing files: {}/{}", current, total);
}
});

LOGGER.info("Processing files: {}/{}", count[0], total);
LOGGER.info("Processing files: {}/{}", count.get(), total);

bslServerContext.clear();
});
Expand Down Expand Up @@ -414,7 +414,7 @@ private static Map<String, Object> getDiagnosticConfiguration(DiagnosticInfo dia
ActiveRule activeRule) {
var params = activeRule.params();
var diagnosticParameters = diagnosticInfo.getParameters();
Map<String, Object> diagnosticConfiguration = new HashMap<>(diagnosticParameters.size());
Map<String, Object> diagnosticConfiguration = HashMap.newHashMap(diagnosticParameters.size());
params.forEach((String key, String value) ->
diagnosticInfo.getParameter(key).ifPresent(diagnosticParameterInfo ->
diagnosticConfiguration.put(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.github._1c_syntax.bsl.sonar.language.BSLLanguageServerRuleDefinition;
import lombok.AllArgsConstructor;
import lombok.Value;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.lsp4j.Diagnostic;
import org.eclipse.lsp4j.DiagnosticRelatedInformation;
import org.eclipse.lsp4j.DiagnosticSeverity;
Expand All @@ -44,8 +45,6 @@
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rules.RuleType;
import org.sonar.api.scanner.fs.InputProject;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;

import javax.annotation.CheckForNull;
import java.net.URI;
Expand All @@ -58,9 +57,8 @@
import java.util.function.Supplier;
import java.util.stream.Collectors;

@Slf4j
public class IssuesLoader {

private static final Logger LOGGER = Loggers.get(IssuesLoader.class);
private static final String BSLLS_ENGINE_ID = "bsl-language-server";

private final SensorContext context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.github._1c_syntax.bsl.languageserver.reporters.data.FileInfo;
import com.github._1c_syntax.bsl.languageserver.reporters.databind.AnalysisInfoJsonMapper;
import com.github._1c_syntax.bsl.sonar.language.BSLLanguage;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.eclipse.lsp4j.Diagnostic;
import org.sonar.api.batch.fs.FilePredicates;
Expand All @@ -33,8 +34,6 @@
import org.sonar.api.batch.sensor.Sensor;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonarsource.analyzer.commons.ExternalReportProvider;

import javax.annotation.CheckForNull;
Expand All @@ -46,10 +45,9 @@

import static com.github._1c_syntax.bsl.sonar.BSLCommunityProperties.LANG_SERVER_REPORT_PATH_KEY;

@Slf4j
public class LanguageServerDiagnosticsLoaderSensor implements Sensor {

private static final Logger LOGGER = Loggers.get(LanguageServerDiagnosticsLoaderSensor.class);

private final SensorContext context;
private final IssuesLoader issueLoader;
private FileSystem fileSystem;
Expand Down
Loading