@Test public void import_detekt_issues_with_rule_loader() throws IOException { List<ExternalIssue> externalIssues = importIssues("detekt-checkstyle.xml"); assertThat(externalIssues).hasSize(3); ExternalIssue first = externalIssues.get(0); assertThat(first.primaryLocation().inputComponent().key()).isEqualTo("externalreport-project:main.kt"); assertThat(first.ruleKey().rule()).isEqualTo("detekt.EmptyIfBlock"); assertThat(first.type()).isEqualTo(RuleType.CODE_SMELL); assertThat(first.severity()).isEqualTo(Severity.MINOR); assertThat(first.primaryLocation().message()).isEqualTo("This empty block of code can be removed."); assertThat(first.primaryLocation().textRange().start().line()).isEqualTo(3); ExternalIssue second = externalIssues.get(1); assertThat(second.primaryLocation().inputComponent().key()).isEqualTo("externalreport-project:main.kt"); assertThat(second.ruleKey().rule()).isEqualTo("detekt.MagicNumber"); assertThat(second.type()).isEqualTo(RuleType.CODE_SMELL); assertThat(second.severity()).isEqualTo(Severity.INFO); assertThat(second.remediationEffort().longValue()).isEqualTo(10L); assertThat(second.primaryLocation().message()).isEqualTo("This expression contains a magic number. Consider defining it to a well named constant."); assertThat(second.primaryLocation().textRange().start().line()).isEqualTo(3); ExternalIssue third = externalIssues.get(2); assertThat(third.primaryLocation().inputComponent().key()).isEqualTo("externalreport-project:A.kt"); assertThat(third.ruleKey().rule()).isEqualTo("detekt.EqualsWithHashCodeExist"); assertThat(third.type()).isEqualTo(RuleType.CODE_SMELL); assertThat(third.severity()).isEqualTo(Severity.CRITICAL); assertThat(third.primaryLocation().message()).isEqualTo("A class should always override hashCode when overriding equals and the other way around."); assertThat(third.primaryLocation().textRange().start().line()).isEqualTo(3); assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty(); }
@Override protected Severity severity(String ruleKey, @Nullable String severity) { return externalRuleLoader.ruleSeverity(ruleKey); }
CheckstyleFormatImporterWithRuleLoader extends CheckstyleFormatImporter { @Override protected Severity severity(String ruleKey, @Nullable String severity) { return externalRuleLoader.ruleSeverity(ruleKey); } }
CheckstyleFormatImporterWithRuleLoader extends CheckstyleFormatImporter { @Override protected Severity severity(String ruleKey, @Nullable String severity) { return externalRuleLoader.ruleSeverity(ruleKey); } CheckstyleFormatImporterWithRuleLoader(SensorContext context, String linterKey, ExternalRuleLoader externalRuleLoader); }
CheckstyleFormatImporterWithRuleLoader extends CheckstyleFormatImporter { @Override protected Severity severity(String ruleKey, @Nullable String severity) { return externalRuleLoader.ruleSeverity(ruleKey); } CheckstyleFormatImporterWithRuleLoader(SensorContext context, String linterKey, ExternalRuleLoader externalRuleLoader);  }
CheckstyleFormatImporterWithRuleLoader extends CheckstyleFormatImporter { @Override protected Severity severity(String ruleKey, @Nullable String severity) { return externalRuleLoader.ruleSeverity(ruleKey); } CheckstyleFormatImporterWithRuleLoader(SensorContext context, String linterKey, ExternalRuleLoader externalRuleLoader);   }