首页 > 解决方案 > SonarQube 上的激活规则

问题描述

我尝试在 SonarQube 和 Robotframework 语言之间进行集成,因此我使用 java 创建了一个插件,其中包含与命名为 Rflint 的工具规则相关的创建类问题:

@Override
public void execute(SensorContext context) {
    FileSystem fs = context.fileSystem();
    Iterable<InputFile> inputFiles = fs.inputFiles(fs.predicates().hasLanguage("Robot"));
    for (InputFile inputFile : inputFiles) {
      // no need to define the severity as it is automatically set according
      // to the configured Quality profile
      NewIssue newIssue = context.newIssue()
        .forRule(RobotRulesDefinition.No_operation)

        // gap is used to estimate the remediation cost to fix the debt
        .gap(ARBITRARY_GAP);


      NewIssueLocation primaryLocation = newIssue.newLocation()
        .on(inputfile)
        .at(inputfile.selectLine(LINE_1))
        .message("You can't do anything. This is first line!");
      newIssue.at(primaryLocation);
      newIssue.save();
    }
  }
}

但是当我扫描我的项目机器人时,SonarQube 没有在分析中使用我的规则的问题

标签: javasonarqubestatic-analysis

解决方案


推荐阅读