use of org.sonar.scanner.repository.FileData in project sonarqube by SonarSource.
the class SameInputFilePredicate method test.
@Override
public boolean test(InputFile inputFile) {
FileData fileDataPerPath = projectRepositories.fileData(moduleKey, inputFile.relativePath());
if (fileDataPerPath == null) {
// ADDED
return true;
}
String previousHash = fileDataPerPath.hash();
if (StringUtils.isEmpty(previousHash)) {
// ADDED
return true;
}
// this will trigger computation of metadata
String hash = ((DefaultInputFile) inputFile).hash();
if (StringUtils.equals(hash, previousHash)) {
// SAME
LOG.debug("'{}' filtering unmodified file", inputFile.relativePath());
return false;
}
// CHANGED
return true;
}
use of org.sonar.scanner.repository.FileData in project sonarqube by SonarSource.
the class StatusDetection method status.
InputFile.Status status(String projectKey, String relativePath, String hash) {
FileData fileDataPerPath = projectSettings.fileData(projectKey, relativePath);
if (fileDataPerPath == null) {
return InputFile.Status.ADDED;
}
String previousHash = fileDataPerPath.hash();
if (StringUtils.equals(hash, previousHash)) {
return InputFile.Status.SAME;
}
if (StringUtils.isEmpty(previousHash)) {
return InputFile.Status.ADDED;
}
return InputFile.Status.CHANGED;
}
use of org.sonar.scanner.repository.FileData in project sonarqube by SonarSource.
the class ScanOnlyChangedTest method prepare.
@Before
public void prepare() throws IOException {
String filePath = "xources/hello/HelloJava.xoo";
String md5sum = DigestUtils.md5Hex(FileUtils.readFileToString(new File(Resources.getResource("mediumtest/xoo/sample/" + filePath).getPath())));
tester = ScannerMediumTester.builder().bootstrapProperties(ImmutableMap.of(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_ISSUES)).registerPlugin("xoo", new XooPlugin()).addDefaultQProfile("xoo", "Sonar Way").addRules(new XooRulesDefinition()).addActiveRule("xoo", "OneIssuePerLine", null, "One issue per line", "MAJOR", null, "xoo").addActiveRule("xoo", "OneIssueOnDirPerFile", null, "OneIssueOnDirPerFile", "MAJOR", null, "xoo").addActiveRule("xoo", "OneIssuePerModule", null, "OneIssuePerModule", "MAJOR", null, "xoo").addFileData("sample", filePath, new FileData(md5sum, null)).setPreviousAnalysisDate(new Date()).mockServerIssue(ServerIssue.newBuilder().setKey("xyz").setModuleKey("sample").setMsg("One issue per Line copied").setPath("xources/hello/HelloJava.xoo").setRuleRepository("xoo").setRuleKey("OneIssuePerLine").setLine(1).setSeverity(Severity.MAJOR).setCreationDate(date("14/03/2004")).setChecksum(DigestUtils.md5Hex("packagehello;")).setStatus("OPEN").build()).mockServerIssue(ServerIssue.newBuilder().setKey("resolved-on-project").setModuleKey("sample").setRuleRepository("xoo").setRuleKey("OneIssuePerModule").setSeverity(Severity.CRITICAL).setCreationDate(date("14/03/2004")).setStatus("OPEN").build()).build();
tester.start();
}
use of org.sonar.scanner.repository.FileData in project sonarqube by SonarSource.
the class ProjectRepositoriesProviderTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
Table<String, String, String> t1 = HashBasedTable.create();
Table<String, String, FileData> t2 = HashBasedTable.create();
project = new ProjectRepositories(t1, t2, new Date());
provider = new ProjectRepositoriesProvider();
when(projectKey.get()).thenReturn("key");
}
use of org.sonar.scanner.repository.FileData in project sonarqube by SonarSource.
the class StatusDetectionTest method createTable.
private static Table<String, String, FileData> createTable() {
Table<String, String, FileData> t = HashBasedTable.create();
t.put("foo", "src/Foo.java", new FileData("ABCDE", "12345789"));
t.put("foo", "src/Bar.java", new FileData("FGHIJ", "123456789"));
return t;
}
Aggregations