org.sonar.squidbridge.checks.SquidCheck Java Examples

The following examples show how to use org.sonar.squidbridge.checks.SquidCheck. 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: LuaSquidSensor.java    From sonar-lua with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void saveViolations(SensorContext context, InputFile inputFile, SourceFile squidFile) {
  Collection<CheckMessage> messages = squidFile.getCheckMessages();
  if (messages != null) {

    for (CheckMessage message : messages) {
      RuleKey ruleKey = checks.ruleKey((SquidCheck<LexerlessGrammar>) message.getCheck());
      NewIssue newIssue = context.newIssue()
        .forRule(ruleKey)
        .gap(message.getCost());
      Integer line = message.getLine();
      NewIssueLocation location = newIssue.newLocation()
        .on(inputFile)
        .message(message.getText(Locale.ENGLISH));
      if (line != null) {
        location.at(inputFile.selectLine(line));
      }
      newIssue.at(location);
      newIssue.save();
    }
  }
}
 
Example #2
Source File: LuaSquidSensor.java    From sonar-lua with GNU Lesser General Public License v3.0 4 votes vote down vote up
public LuaSquidSensor(CheckFactory checkFactory, FileLinesContextFactory fileLinesContextFactory) {
  this.checks = checkFactory
    .<SquidCheck<LexerlessGrammar>>create(CheckList.REPOSITORY_KEY)
    .addAnnotatedChecks((Iterable) CheckList.getChecks());
  this.fileLinesContextFactory = fileLinesContextFactory;
}
 
Example #3
Source File: HardcodingIdsCheckTest.java    From enforce-sonarqube-plugin with MIT License 2 votes vote down vote up
/**
 * Scan files given a file path and the respective check to scan file
 * @param filePath the path of the file to be scanned.
 * @param check visitor.
 */
private void scanFilesWithCheck(String filePath, SquidCheck<Grammar> check) {
    File file = new File(filePath);
    sourceFile = ApexAstScanner.scanFile(file, check);
}