【发布时间】:2019-11-20 05:42:24
【问题描述】:
我刚刚安装了最新版本的 SonarLint 并对我们的新学员的代码进行了完整的 SonarLint 分析,他将一些非静态非注入成员放入 Spring 单例中,就像在这个例子中一样:
@Controller
public class HelloWorld {
private String name = null;
@RequestMapping("/greet", method = GET)
public String greet(String greetee) {
if (greetee != null) {
this.name = greetee;
}
return "Hello " + this.name; // if greetee is null, you see the previous user's data
}
}
https://rules.sonarsource.com/java/tag/spring/RSPEC-3749
所以我希望 SonarLint 能够检测到它,但没有(我有其他建议,但对此一无所知)。
此规则是否属于需要在某个配置中激活的特殊设置?
【问题讨论】: