为什么我添加的NewIssues没有转移到声呐? (自定义声纳插件)

Heyho,

我有我的声纳kotlin插件运行。 我的RuleDefinitions在规则页面显示,但是当分析一些kotlin项目时,找到的问题不会被保存。

我的传感器问题添加代码如下所示:

private fun projectIssues(detektion: Detektion, context: SensorContext) { val fileSystem = context.fileSystem() val baseDir = fileSystem.baseDir() val predicates = fileSystem.predicates() detektion.findings.forEach { _, findings -> findings.forEach { issue -> val inputFile = fileSystem.inputFile(predicates.`is`(baseDir.resolve(issue.location.file))) if (inputFile != null) { val newIssue = context.newIssue() .forRule(findKey(issue.id)) .gap(2.0) // TODO what to write here? .primaryLocation(issue, inputFile) println(newIssue) newIssue.save() } else { println("No file found for ${issue.location.file}") } } } } private fun NewIssue.primaryLocation(issue: Finding, inputFile: InputFile): NewIssue { val (line, _) = issue.startPosition val newIssueLocation = newLocation() .on(inputFile) .at(inputFile.selectLine(line)) .message("TODO needs PR!") return this.at(newIssueLocation) } 

即使是println(newIssue)显示它已经创建。

org.sonar-gradle-plugin in version 2.5使用了sonar-plugin-api version 5.6org.sonar-gradle-plugin in version 2.5 ,我的声纳发行版本是5.6.6版本,我使用embedded database

我的整个代码是在这个公关https://github.com/arturbosch/detekt/pull/81

Thx提前为您提供帮助。

我通过在RulesProfile中激活我的规则来解决我的问题:

 override fun createProfile(validation: ValidationMessages): RulesProfile { val profile = RulesProfile.create(DETEKT_WAY, KOTLIN_KEY) RULE_KEYS.forEach { profile.activateRule(Rule.create(it.repository(), it.rule()), null) } return profile } 
Interesting Posts