Search in sources :

Example 36 with FilePredicates

use of org.sonar.api.batch.fs.FilePredicates in project sonarqube by SonarSource.

the class OneBugIssuePerTestLineSensor method analyse.

private void analyse(SensorContext context, String language, String repo) {
    FileSystem fs = context.fileSystem();
    FilePredicates p = fs.predicates();
    for (InputFile file : fs.inputFiles(p.and(p.hasLanguages(language), p.hasType(Type.TEST)))) {
        createIssues(file, context, repo);
    }
}
Also used : FileSystem(org.sonar.api.batch.fs.FileSystem) FilePredicates(org.sonar.api.batch.fs.FilePredicates) InputFile(org.sonar.api.batch.fs.InputFile)

Example 37 with FilePredicates

use of org.sonar.api.batch.fs.FilePredicates in project sonarqube by SonarSource.

the class OneCodeSmellIssuePerTestLineSensor method analyse.

private void analyse(SensorContext context, String language, String repo) {
    FileSystem fs = context.fileSystem();
    FilePredicates p = fs.predicates();
    for (InputFile file : fs.inputFiles(p.and(p.hasLanguages(language), p.hasType(Type.TEST)))) {
        createIssues(file, context, repo);
    }
}
Also used : FileSystem(org.sonar.api.batch.fs.FileSystem) FilePredicates(org.sonar.api.batch.fs.FilePredicates) InputFile(org.sonar.api.batch.fs.InputFile)

Example 38 with FilePredicates

use of org.sonar.api.batch.fs.FilePredicates in project sonarqube by SonarSource.

the class OneExternalIssuePerLineSensor method execute.

@Override
public void execute(SensorContext context) {
    FileSystem fs = context.fileSystem();
    FilePredicates p = fs.predicates();
    for (InputFile file : fs.inputFiles(p.and(p.hasLanguages(Xoo.KEY), p.hasType(InputFile.Type.MAIN)))) {
        createIssues(file, context);
    }
    if (context.config().getBoolean(REGISTER_AD_HOC_RULE).orElse(false)) {
        context.newAdHocRule().engineId(ENGINE_ID).ruleId(RULE_ID).name("An ad hoc rule").description("blah blah").severity(Severity.BLOCKER).type(RuleType.BUG).save();
    }
}
Also used : FileSystem(org.sonar.api.batch.fs.FileSystem) FilePredicates(org.sonar.api.batch.fs.FilePredicates) InputFile(org.sonar.api.batch.fs.InputFile)

Example 39 with FilePredicates

use of org.sonar.api.batch.fs.FilePredicates in project sonarqube by SonarSource.

the class OneExternalIssuePerLineWithoutMessageSensor method execute.

@Override
public void execute(SensorContext context) {
    FileSystem fs = context.fileSystem();
    FilePredicates p = fs.predicates();
    for (InputFile file : fs.inputFiles(p.and(p.hasLanguages(Xoo.KEY), p.hasType(InputFile.Type.MAIN)))) {
        createIssues(file, context);
    }
    if (context.config().getBoolean(REGISTER_AD_HOC_RULE).orElse(false)) {
        context.newAdHocRule().engineId(ENGINE_ID).ruleId(RULE_ID).name("An ad hoc rule").description("blah blah").severity(Severity.BLOCKER).type(RuleType.BUG).save();
    }
}
Also used : FileSystem(org.sonar.api.batch.fs.FileSystem) FilePredicates(org.sonar.api.batch.fs.FilePredicates) InputFile(org.sonar.api.batch.fs.InputFile)

Example 40 with FilePredicates

use of org.sonar.api.batch.fs.FilePredicates in project sonarqube by SonarSource.

the class OnePredefinedAndAdHocRuleExternalIssuePerLineSensor method execute.

@Override
public void execute(SensorContext context) {
    FileSystem fs = context.fileSystem();
    FilePredicates p = fs.predicates();
    for (InputFile file : fs.inputFiles(p.and(p.hasLanguages(Xoo.KEY), p.hasType(Type.MAIN)))) {
        createIssues(file, context);
    }
}
Also used : FileSystem(org.sonar.api.batch.fs.FileSystem) FilePredicates(org.sonar.api.batch.fs.FilePredicates) InputFile(org.sonar.api.batch.fs.InputFile)

Aggregations

FilePredicates (org.sonar.api.batch.fs.FilePredicates)43 InputFile (org.sonar.api.batch.fs.InputFile)38 FileSystem (org.sonar.api.batch.fs.FileSystem)22 File (java.io.File)6 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 Path (java.nio.file.Path)4 FilePredicate (org.sonar.api.batch.fs.FilePredicate)4 SensorContext (org.sonar.api.batch.sensor.SensorContext)4 RuleKey (org.sonar.api.rule.RuleKey)4 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)3 NewIssue (org.sonar.api.batch.sensor.issue.NewIssue)3 InputStreamReader (java.io.InputStreamReader)2 Reader (java.io.Reader)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 StreamSupport (java.util.stream.StreamSupport)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 ActiveRule (org.sonar.api.batch.rule.ActiveRule)2