diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2022-06-22 16:17:26 -0500 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-07-23 20:02:53 +0000 |
commit | 0fb5e45d935ad212aa3fe32202c33dd8395078c5 (patch) | |
tree | 4c2afc044dc034f9c70a11b58f02a762b3ba3448 /sonar-scanner-engine/src/main/java/org | |
parent | 1220331cf405fb916a005284120b0ed02ea67ac2 (diff) | |
download | sonarqube-0fb5e45d935ad212aa3fe32202c33dd8395078c5.tar.gz sonarqube-0fb5e45d935ad212aa3fe32202c33dd8395078c5.zip |
SONAR-17044 Optimize Compute Engine issue tracking and persisting of measures when file is marked as unchanged
Diffstat (limited to 'sonar-scanner-engine/src/main/java/org')
4 files changed, 14 insertions, 5 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java index 9fe8fc5a7f5..4ca7c8be780 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java @@ -66,6 +66,7 @@ public class ComponentsPublisher implements ReportPublisherStep { fileBuilder.setIsTest(file.type() == InputFile.Type.TEST); fileBuilder.setLines(file.lines()); fileBuilder.setStatus(convert(file.status())); + fileBuilder.setMarkedAsUnchanged(file.isMarkedAsUnchanged()); String lang = getLanguageKey(file); if (lang != null) { diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorStorage.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorStorage.java index 7aaf4b5eebe..f2c25f372e4 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorStorage.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/DefaultSensorStorage.java @@ -186,6 +186,10 @@ public class DefaultSensorStorage implements SensorStorage { reportPublisher.getWriter().appendComponentMeasure(((DefaultInputComponent) component).scannerId(), toReportMeasure(measure)); } + public boolean hasIssues(DefaultInputComponent inputComponent) { + return reportPublisher.getReader().hasIssues(inputComponent.scannerId()); + } + public static ScannerReport.Measure toReportMeasure(DefaultMeasure measureToSave) { ScannerReport.Measure.Builder builder = ScannerReport.Measure.newBuilder(); builder.setMetricKey(measureToSave.metric().key()); diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorContext.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorContext.java index 86c54c41d69..a573f94ff0e 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorContext.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ModuleSensorContext.java @@ -27,7 +27,6 @@ import org.sonar.api.batch.fs.internal.DefaultInputProject; import org.sonar.api.batch.rule.ActiveRules; import org.sonar.api.batch.sensor.cache.ReadCache; import org.sonar.api.batch.sensor.cache.WriteCache; -import org.sonar.api.batch.sensor.internal.SensorStorage; import org.sonar.api.config.Configuration; import org.sonar.api.config.Settings; import org.sonar.scanner.cache.AnalysisCacheEnabled; @@ -39,7 +38,7 @@ public class ModuleSensorContext extends ProjectSensorContext { private final InputModule module; public ModuleSensorContext(DefaultInputProject project, InputModule module, Configuration config, Settings mutableModuleSettings, FileSystem fs, ActiveRules activeRules, - SensorStorage sensorStorage, SonarRuntime sonarRuntime, BranchConfiguration branchConfiguration, + DefaultSensorStorage sensorStorage, SonarRuntime sonarRuntime, BranchConfiguration branchConfiguration, WriteCache writeCache, ReadCache readCache, AnalysisCacheEnabled analysisCacheEnabled) { super(project, config, mutableModuleSettings, fs, activeRules, sensorStorage, sonarRuntime, branchConfiguration, writeCache, readCache, analysisCacheEnabled); this.module = module; diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorContext.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorContext.java index a4cd85157d6..4c72730b94c 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorContext.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorContext.java @@ -40,7 +40,6 @@ import org.sonar.api.batch.sensor.cpd.internal.DefaultCpdTokens; import org.sonar.api.batch.sensor.error.NewAnalysisError; import org.sonar.api.batch.sensor.highlighting.NewHighlighting; import org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting; -import org.sonar.api.batch.sensor.internal.SensorStorage; import org.sonar.api.batch.sensor.issue.NewExternalIssue; import org.sonar.api.batch.sensor.issue.NewIssue; import org.sonar.api.batch.sensor.issue.internal.DefaultExternalIssue; @@ -67,7 +66,7 @@ public class ProjectSensorContext implements SensorContext { private final Settings mutableSettings; private final FileSystem fs; private final ActiveRules activeRules; - private final SensorStorage sensorStorage; + private final DefaultSensorStorage sensorStorage; private final DefaultInputProject project; private final SonarRuntime sonarRuntime; private final Configuration config; @@ -77,7 +76,7 @@ public class ProjectSensorContext implements SensorContext { private final AnalysisCacheEnabled analysisCacheEnabled; public ProjectSensorContext(DefaultInputProject project, Configuration config, Settings mutableSettings, FileSystem fs, ActiveRules activeRules, - SensorStorage sensorStorage, SonarRuntime sonarRuntime, BranchConfiguration branchConfiguration, WriteCache writeCache, ReadCache readCache, + DefaultSensorStorage sensorStorage, SonarRuntime sonarRuntime, BranchConfiguration branchConfiguration, WriteCache writeCache, ReadCache readCache, AnalysisCacheEnabled analysisCacheEnabled) { this.project = project; this.config = config; @@ -194,6 +193,12 @@ public class ProjectSensorContext implements SensorContext { } @Override + public void markAsUnchanged(InputFile inputFile) { + DefaultInputFile defaultInputFile = (DefaultInputFile) inputFile; + defaultInputFile.setMarkedAsUnchanged(true); + } + + @Override public WriteCache nextCache() { return writeCache; } |