use of org.sonar.api.issue.Issuable in project sonarqube by SonarSource.
the class OneIssuePerFileSensor method processFile.
@Override
protected void processFile(InputFile inputFile, org.sonar.api.resources.File sonarFile, SensorContext context, RuleKey ruleKey, String languageKey) {
Issuable issuable = perspectives.as(Issuable.class, sonarFile);
issuable.addIssue(issuable.newIssueBuilder().ruleKey(ruleKey).effortToFix(settings.getDouble(EFFORT_TO_FIX_PROPERTY)).message("This issue is generated on each file").build());
}
use of org.sonar.api.issue.Issuable in project sonarqube by SonarSource.
the class DeprecatedResourceApiSensor method createIssueOnDir.
private Directory createIssueOnDir(Directory dir) {
Issuable issuable = perspectives.as(Issuable.class, dir);
issuable.addIssue(issuable.newIssueBuilder().ruleKey(RuleKey.of(XooRulesDefinition.XOO_REPOSITORY, RULE_KEY)).message("Issue created using deprecated API").build());
return dir;
}
use of org.sonar.api.issue.Issuable in project sonarqube by SonarSource.
the class IssuableFactoryTest method file_should_be_issuable.
@Test
public void file_should_be_issuable() {
IssuableFactory factory = new IssuableFactory(mock(DefaultSensorContext.class));
Issuable issuable = factory.loadPerspective(Issuable.class, new TestInputFileBuilder("foo", "src/Foo.java").build());
assertThat(issuable).isNotNull();
assertThat(issuable.issues()).isEmpty();
}
use of org.sonar.api.issue.Issuable in project sonarqube by SonarSource.
the class DeprecatedResourceApiSensor method analyse.
@Override
public void analyse(Project module, org.sonar.api.batch.SensorContext context) {
for (File f : fs.files(fs.predicates().and(fs.predicates().hasType(Type.MAIN), fs.predicates().hasLanguage(Xoo.KEY)))) {
String relativePathFromBaseDir = new PathResolver().relativePath(fs.baseDir(), f);
org.sonar.api.resources.File sonarFile = org.sonar.api.resources.File.create(relativePathFromBaseDir);
Issuable issuable = perspectives.as(Issuable.class, sonarFile);
issuable.addIssue(issuable.newIssueBuilder().ruleKey(RuleKey.of(XooRulesDefinition.XOO_REPOSITORY, RULE_KEY)).message("Issue created using deprecated API").line(1).build());
// Message and line are nullable
issuable.addIssue(issuable.newIssueBuilder().ruleKey(RuleKey.of(XooRulesDefinition.XOO_REPOSITORY, RULE_KEY)).message(null).line(null).build());
sonarFile = context.getResource(sonarFile);
Directory parent = sonarFile.getParent();
createIssueOnDir(parent);
}
}
use of org.sonar.api.issue.Issuable in project sonarqube by SonarSource.
the class OneBlockerIssuePerFileSensor method processFile.
@Override
protected void processFile(InputFile inputFile, org.sonar.api.resources.File sonarFile, SensorContext context, RuleKey ruleKey, String languageKey) {
Issuable issuable = perspectives.as(Issuable.class, sonarFile);
issuable.addIssue(issuable.newIssueBuilder().ruleKey(ruleKey).severity(Severity.BLOCKER).message("This issue is generated on each file. Severity is blocker, whatever quality profile").build());
}
Aggregations