在Intellij IDEA中是否有某种方法可以关闭自动SonarLint分析?
我有大约10,000到20,000行代码类(不要问,不是我的错,试图重构).每次我编辑类中的单个字符时,SonarLint插件都会使IDEA无法使用几分钟.
在其他设置> SonarLint常规设置中,无法在未选中状态下保存"自动触发分析"复选框.我的问题还有其他解决办法吗?我真的想使用这个插件.我不能在自动模式下使用它.
我想抑制一些方法的Sonar lint插件警告,这个问题不是我想要的Intellij SonarLint 2.3 - 忽略规则.
目前我必须用方法注释@SuppressWarnings("all"),这会抑制所有警告.
我刚刚将Intellij Idea的SonarLint插件更新为2.3.2版.Changelog表示,因为连接模式下的2.3版规则排除应该可用.
下面是我的配置,似乎已经纠正,但是,忽略的规则仍然会弹出.
这是源代码中的许可证标题:
包org.osgl.ut;
/*-
* #%L
* Java Unit Test Tool
* %%
* Copyright (C) 2017 OSGL (Open Source General Library)
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用名为 sonarLint 的 IntelliJ idea 扩展来重构我的代码。在那里,sonarLint 建议进一步修改,如下图所示(我已将问题标记为红色)
这是我的代码
public class AbcController extends BaseController{
private final PermissionService permissionService;
public PermissionController(PermissionService permissionService) {
this.permissionService = permissionService;
}
@GetMapping("/groups")
public ResponseEntity<List<GroupResponse>> getGroups( String accessToken) {
List<GroupResponse> groupResponses = permissionService.getGroups(accessToken);
return getResponseEntity(groupResponses);
}
}
public abstract class BaseController <T>{
protected ResponseEntity<T> getResponseEntity(T t, HttpHeaders httpHeaders) {
return new ResponseEntity<> (t, httpHeaders, HttpStatus.OK);
}
protected ResponseEntity<T> getResponseEntity(T t) {
return new ResponseEntity<> (t, HttpStatus.OK);
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试根据 sonarLint 警报进行修改,但它不起作用。请帮我解决这个问题。谢谢你们。
我正在尝试使用SonarLint进行IntelliJ,但我对它有点警惕.它似乎没有提供任何比IntelliJ更多的东西,甚至没有办法看它提供什么规则,更不用说改变它们了.
现在,也许它确实增加了一些东西,但是,现在,我被误报所诟病.当在前一行中声明为非null时,说变量的内容可以为空.有没有办法让误报沉默,所以我可以专注于剩下的东西?
intellij-idea sonarqube intellij-14 sonarlint sonarlint-intellij
如果我们有代码:
@Contract("null, _, _ -> fail")
static void ifNull(Object object, ErrorType errorType, Object... args) throws ServiceException {
if (object == null) {
ExceptionFactory.throwServiceException(errorType, args);
}
}
Run Code Online (Sandbox Code Playgroud)
和
private boolean checkSeqValue(Sequence sequence, @Nonnull Number value) {
...
}
Run Code Online (Sandbox Code Playgroud)
和某处:
ifNull(value, ErrorType.NOT_FOUND, "Value for a sequence", "name = " + seqName);
if (checkSeqValue(sequence, value)) {
result = value;
}
Run Code Online (Sandbox Code Playgroud)
然后 SonarLint 插件显示了一个严重错误:
鱿鱼:S2637“@NonNull”值不应设置为空
对于此调用的 checkSeqValue 参数 2 已标记javax.annotation.Nonnull但传递了 null
直接检查:
if (value == null) {
throw new ServiceException();
}
if …Run Code Online (Sandbox Code Playgroud) 如何使用sonarlint来分析测试用例?我在声纳立方体中找到了类似的东西sonar.test.inclusions作为属性,但在中找不到类似的东西sonarlint > intellij.
我需要分析的文件夹:src/test/java
解决办法:
重命名 test 文件夹对我有用。我将 test 更改为 test1。我是否可以遵循并可以分析测试用例的正确方法/步骤?
Intellij 的 SonarLint 插件也为 TODO 提供警告。
默认情况下,Intellij 会突出显示 TODO 并将它们显示在提交对话框中。SonarLint 再次突出显示它是多余的。
此外,它还抑制了 Intellij 的一项有用功能 - Intellij 用蓝色突出显示 TODO,更容易识别和滚动到。
由于 SonarLint 插件,此功能被抑制。所以,我只想对待办事项禁用 sonarlint 警告。我怎样才能做到这一点?
intellij-idea suppress-warnings sonarlint sonarlint-intellij
我有以下代码:
String s1 = "a";
String s2 = "a";
if (s1 == s2) {
System.out.println("string not equal");
}
Run Code Online (Sandbox Code Playgroud)
当我使用 SonarLint 分析这段代码时,它没有被捕获。我希望这应该被以下规则所捕获
鱿鱼:S1698-“==”和“!=”当“等于”被覆盖时不应使用
我已经使用 Sonar Qube 7.0 在独立模式和连接模式下检查了这一点。有人知道为什么声纳会这样吗?
- - - - - - - -编辑 - - - - - - - - -
同样的情况也发生在:
Integer x= 500;
Integer y= 500;
if (x==y){
System.out.println("not equal");
}
Run Code Online (Sandbox Code Playgroud) if (res.getBody() == null || res.getBody().getServiceResult() == null) {
return; //
}
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,sonarlint 抱怨 SonarLint: A "NullPointerException" 可能会被抛出;“getBody()”可以返回 null。(来自 res.getBody().getServiceResult() )
我认为“res.getBody() == null”首先检查 null,因此它应该转到返回行,而不是到达下一个 if 条件。
我是不是在想什么问题?