是否有可能使用Checkstyle插件配置SonarQube 5.1以支持@SuppressWarnings("deprecation")
注释。我不想关闭“避免使用已弃用的方法”规则,我只想让SonarQube尊重@SuppressWarnings
注释。
我有一个Java代码,我需要使用弃用的createValidator()
方法,如下所示:
@SuppressWarnings("deprecation")
@Override
public javax.xml.bind.Validator createValidator() throws JAXBException {
return contextDelegate.createValidator();
}
Java编译器在编译代码时不会发出警告,但不幸的是,带有CheckStyle插件的SonarQube会出现问题:
squid:CallToDeprecatedMethod
Avoid use of deprecated methods
答案 0 :(得分:2)
鱿鱼是一种不同的野兽。正如SonarQube docs中所建议的那样,您必须使用稍微不同的语法,例如:
@SuppressWarnings("squid:CallToDeprecatedMethod")
字符串squid:CallToDeprecatedMethod
是SonarQube 规则键。
不幸的是,这意味着添加两个注释以有效地抑制弃用警告。但是afaik,这是禁用规则的唯一方法。
答案 1 :(得分:1)
Squid是声纳规则的名称或编号,与checkstyle无关,所有checkstyle规则都在http://checkstyle.sourceforge.net/checks.html
中描述