Java Code Examples for org.sonar.api.batch.sensor.SensorContext#newIssue()

The following examples show how to use org.sonar.api.batch.sensor.SensorContext#newIssue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EsqlSensor.java    From sonar-esql-plugin with Apache License 2.0 6 votes vote down vote up
private void processRecognitionException(RecognitionException e, SensorContext sensorContext, InputFile inputFile) {
    if (parsingErrorRuleKey != null) {
        NewIssue newIssue = sensorContext.newIssue();

        NewIssueLocation primaryLocation = newIssue.newLocation()
                .message(ParsingErrorCheck.MESSAGE)
                .on(inputFile)
                .at(inputFile.selectLine(e.getLine()));

        newIssue
                .forRule(parsingErrorRuleKey)
                .at(primaryLocation)
                .save();
    }

    sensorContext.newAnalysisError()
            .onFile(inputFile)
            .at(inputFile.newPointer(e.getLine(), 0))
            .message(e.getMessage())
            .save();
}
 
Example 2
Source File: EsqlSensor.java    From sonar-esql-plugin with Apache License 2.0 6 votes vote down vote up
private static void savePreciseIssue(SensorContext sensorContext, InputFile inputFile, RuleKey ruleKey, PreciseIssue issue) {
    NewIssue newIssue = sensorContext.newIssue();

    newIssue
            .forRule(ruleKey)
            .at(newLocation(inputFile, newIssue, issue.primaryLocation()));

    if (issue.cost() != null) {
        newIssue.gap(issue.cost());
    }

    for (IssueLocation secondary : issue.secondaryLocations()) {
        newIssue.addLocation(newLocation(inputFile, newIssue, secondary));
    }
    newIssue.save();
}
 
Example 3
Source File: AbstractLanguageAnalyzerSensor.java    From sonar-css-plugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void processRecognitionException(RecognitionException e, SensorContext sensorContext, InputFile inputFile) {
  if (parsingErrorRuleKey != null) {
    NewIssue newIssue = sensorContext.newIssue();

    NewIssueLocation primaryLocation = newIssue.newLocation()
      .message(e.getMessage())
      .on(inputFile)
      .at(inputFile.selectLine(e.getLine()));

    newIssue
      .forRule(parsingErrorRuleKey)
      .at(primaryLocation)
      .save();
  }
}
 
Example 4
Source File: GherkinSquidSensor.java    From sonar-gherkin-plugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void processRecognitionException(RecognitionException e, SensorContext sensorContext, InputFile inputFile) {
  if (parsingErrorRuleKey != null) {
    NewIssue newIssue = sensorContext.newIssue();

    NewIssueLocation primaryLocation = newIssue.newLocation()
      .message(e.getMessage())
      .on(inputFile)
      .at(inputFile.selectLine(e.getLine()));

    newIssue
      .forRule(parsingErrorRuleKey)
      .at(primaryLocation)
      .save();
  }
}
 
Example 5
Source File: HtlFilesAnalyzer.java    From AEM-Rules-for-SonarQube with Apache License 2.0 5 votes vote down vote up
private void processRecognitionExceptionForCustomRule(SightlyCompilerException e, SensorContext sensorContext, InputFile inputFile) {
    NewIssue newIssue = sensorContext.newIssue();

    NewIssueLocation primaryLocation = newIssue.newLocation()
        .message("Parse error: " + e.getMessage())
        .on(inputFile)
        .at(inputFile.selectLine(e.getLine()));

    newIssue
        .forRule(parsingErrorRuleKey)
        .at(primaryLocation)
        .save();
}
 
Example 6
Source File: EsqlSensor.java    From sonar-esql-plugin with Apache License 2.0 5 votes vote down vote up
private static void saveLineIssue(SensorContext sensorContext, InputFile inputFile, RuleKey ruleKey, LineIssue issue) {
    NewIssue newIssue = sensorContext.newIssue();

    NewIssueLocation primaryLocation = newIssue.newLocation()
            .message(issue.message())
            .on(inputFile)
            .at(inputFile.selectLine(issue.line()));

    saveIssue(newIssue, primaryLocation, ruleKey, issue);
}
 
Example 7
Source File: EsqlSensor.java    From sonar-esql-plugin with Apache License 2.0 5 votes vote down vote up
private static void saveFileIssue(SensorContext sensorContext, InputFile inputFile, RuleKey ruleKey, FileIssue issue) {
    NewIssue newIssue = sensorContext.newIssue();

    NewIssueLocation primaryLocation = newIssue.newLocation()
            .message(issue.message())
            .on(inputFile);

    saveIssue(newIssue, primaryLocation, ruleKey, issue);
}