aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api-impl
diff options
context:
space:
mode:
authorZipeng WU <zipeng.wu@sonarsource.com>2022-02-24 17:40:25 +0100
committersonartech <sonartech@sonarsource.com>2022-02-26 20:02:50 +0000
commit30b3456935e069ae51179ea33ea6b57f42bf1d46 (patch)
tree96ab00efcb033f8c31261a761cac356981d4b641 /sonar-plugin-api-impl
parent765ac490d9bb24d575f331b4fbb2b5d2f6654319 (diff)
downloadsonarqube-30b3456935e069ae51179ea33ea6b57f42bf1d46.tar.gz
sonarqube-30b3456935e069ae51179ea33ea6b57f42bf1d46.zip
SONAR-16064 new API in SensorContext to indicate possibility to skip unchanged files
Diffstat (limited to 'sonar-plugin-api-impl')
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java11
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java7
2 files changed, 18 insertions, 0 deletions
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java
index 458860be4f8..d5d0c27f8da 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java
@@ -110,6 +110,7 @@ public class SensorContextTester implements SensorContext {
private DefaultInputProject project;
private DefaultInputModule module;
private SonarRuntime runtime;
+ private boolean canSkipUnchangedFiles;
private boolean cancelled;
private SensorContextTester(Path moduleBaseDir) {
@@ -198,6 +199,16 @@ public class SensorContextTester implements SensorContext {
}
@Override
+ public boolean canSkipUnchangedFiles() {
+ return canSkipUnchangedFiles;
+ }
+
+ public SensorContextTester setCanSkipUnchangedFiles(boolean canSkipUnchangedFiles) {
+ this.canSkipUnchangedFiles = canSkipUnchangedFiles;
+ return this;
+ }
+
+ @Override
public InputModule module() {
return module;
}
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java
index 6d30694829b..eb61b3a55d4 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/sensor/internal/SensorContextTesterTest.java
@@ -75,6 +75,13 @@ public class SensorContextTesterTest {
}
@Test
+ public void test_canSkipUnchangedFiles() {
+ assertThat(tester.canSkipUnchangedFiles()).isFalse();
+ tester.setCanSkipUnchangedFiles(true);
+ assertThat(tester.canSkipUnchangedFiles()).isTrue();
+ }
+
+ @Test
public void testActiveRules() {
NewActiveRule activeRule = new NewActiveRule.Builder()
.setRuleKey(RuleKey.of("foo", "bar"))