Questions tagged [sonarlint]
SonarLint is an extension to IDEs (such as VS, Eclipse or IntelliJ) that provides on-the-fly feedback to developers on new bugs and quality issues found in their code, using Static Code Analysis.
640
questions
1
vote
0
answers
43
views
Fields that are subclasses of type Serializable trigger a warning to be made Serializable by SonarQube
Let's say we have some class:
class Foo implements Serializable { }
And some interface:
interface Bar extends Serializable { }
If we have an implementation like this:
class X implements Bar {
...
0
votes
0
answers
14
views
Is Java 8 or 9 Required for Sonarlint in Visual Studio Code
Inquiring if Java 8 or 9 is required when running Sonarlint in Visual Studio Code, kept receiving error "Couldn't start client SonarLint Language Server". Currently have Java 1.8 installed ...
0
votes
0
answers
36
views
SonarLint: "std::forward" should only be called on a forwarding reference
By analyzing some code using SonarLint, I saw it complaining about the second parameter (Args... args) of the function below. It says:
"std::forward" should only be called on a forwarding ...
0
votes
2
answers
29
views
How To Exclude a specific rule from a specific file in Sonarlint
I am trying to exclude a specific rule from a file in sonarlint, I have multiple java automation projects open in eclipse, and I am wondering if my "Value" is correct on my analyzed property ...
0
votes
1
answer
38
views
How to handle "Raw types usage" warning while sending raw ResponseEntity from Controllers?
I have a simple APIs that initiates some action on records and return a 200 response:
/**
* Initiate some workflow.
*
* @param recordsBulkInitiate records to initiate
* @return ...
0
votes
1
answer
28
views
What does number in SonarLint actually means?
I am very new to sonarlint, So after installing it and analyzing the file, I have seen a number indications in my code. I searched on google about the same but didn’t find anything. A version of ...
0
votes
1
answer
33
views
SonarLint says I should remove or rename the parameter being used
Sonar lint says:
Remove the unused function parameter "customParams" or rename it to "_customParams" to make intention explicit.
But, the "customParams" parameter is ...
0
votes
0
answers
23
views
Sonarlint warn if an object is used in java code base
Can someone let me know how can I raise a sonar warning if an object is used in java code base? For example, let's say I have an object
public class TukWebClient extends WebClient {
...
}
So I ...
0
votes
0
answers
29
views
SonarSource vs. native .Net Code Analysis
I am looking for a code analysis / linting tool for C# projects. After reading about SonarSource and doing some preliminary analyses, it seems to me that many rules in the SonarSource C# ruleset are ...
1
vote
1
answer
77
views
"Make this anonymous inner class a lambda" code smell in SonarLint
While checking up the SonarLint report, I am getting this code smell "Make this anonymous inner class a lambda" a number of times.
How can I make this inner class as lambda? It is bit ...
0
votes
0
answers
54
views
Proxy configuration for SonarLint (vscode)
Using the vscode extension SonarLint, I'm unable to get it connect to our on-premise SonarQube server. I know that it is a proxy problem, since I can only connect to the SonarQube server using curl ...
0
votes
0
answers
26
views
SonarLint - Sync pull request "quality gate" results with SonarLint in Visual Studio 2022
Following this illustration, it should be possible to send results of pull requests back to the IDE (Visual Studio 2022 with SonarLint) using SonarQube. Is there a similar option for SonarCloud.io? I ...
1
vote
1
answer
28
views
Java returning assignement vs assigning then returning. (E.g. in Singletons)
Basically, you can have code like this:
From: Baeldung.com
public static synchronized ClassSingleton getInstance() {
if(instance == null) {
instance = new ClassSingleton();
}
...
0
votes
1
answer
66
views
Roslyn SonarAnalyzer.CSharp does not respect rule settings from SonarLint.xml
I am trying to customize some rules, particularly S134 but it does not take my deviation from the default max parameter into account
Repro: Create new Console App in Visual Studio, Add SonarAnalyzer....
0
votes
0
answers
20
views
How to reduce Cognitive Complexity in a form with many fields
I have a lot of fields in user form, and SonarLint display a message
"Refactor this function to reduce its Cognitive Complexity"
How can I do this, move each field in separate component? in ...
0
votes
0
answers
23
views
SonarLint: Invoke method(s) only conditionally on ZonedDateTime.now().format
The ZonedDateTime.now().format(dateformat) in below code is causing SonarLint warning
Invoke method(s) only conditionally.
logger.info("{} : Return Code: {}", ZonedDateTime.now().format(...
0
votes
1
answer
34
views
VS code - SonarLint:Simplify the expression produce invalid syntax
I'm getting S1125 for a code smell:
MyVO vo;
public boolean is() {
return vo == null ? false : vo.is();
}
Remove the unnecessary boolean literal.sonarlint(java:S1125)
But when choosing Quick Fix ...
0
votes
0
answers
77
views
How to fix sonar issue "Update or refactor this function so that its implementation doesn't duplicate the one on line"
SonarLint identifies these 3 functions as duplicates in some specific lines (39, 55 and 71):
Update this function so that its implementation is not identical to the one on line 25.
const { ...
0
votes
0
answers
33
views
Spring boot security antMatchers and Sonarlint vulnerability
I am confused with the following spingboot security config and a Critical Vulnerability raised by Sonalint.
Is there a way to simplify the configuration to avoid the error ?
"HttpSecurity" ...
-1
votes
1
answer
174
views
SonarLint rule Java:S3252 ("static" base class members should not be accessed via derived types) [closed]
I've installed SonarLint for STS a few days ago and I would like to ask a question about the rule Java:S3252 ("static" base class members should not be accessed via derived types).
In my ...
0
votes
0
answers
130
views
Sonar ternary operation throws warning "A "NullPointerException" could be thrown; "getBody()" can return null."
I have java code like this:
String str = response != null && response.getBody() != null ? response.getBody().getUser() : null;
Even though, Sonar is showing the following alert:
A "...
0
votes
0
answers
151
views
Why is SonarAnalyzer reporting 'Unused method parameters should be removed'?
I am having an issue with SonarLint/Analyzer's (SonarAnalzer.CSharp (8.36.1.44192)) reporting of the "Unused method parameters should be removed" (1172) rule. I wish to know what I might be ...
0
votes
1
answer
130
views
Why does SonarQube is showing the message for all Java Streams: Refactor the code so this stream pipeline is used.?
I have a Java project running in Java 17 version. I have pushed my code to the organization repository where SonarQube is running. In that repository, I am getting issues/bugs for all the Java Streams ...
1
vote
0
answers
1k
views
Migrate Sonarqube to support Java 17
I have some inconsistent warnings and code smells when scanning the code written with Java 17 LTS, below some warnings :
When I migrate my classes to record, I see my imports tagged as unused within ...
0
votes
1
answer
146
views
Merge SonarAnalyzer.CSharp and the Microsoft.CodeAnalysis rulesets
We run a SonarQube in our company. We also installed the SonarLint for Visual Studio 2019 extension.
If I now connect a solution to the SonarQube, a file named "{MySolution}csharp.ruleset" ...
3
votes
0
answers
244
views
Why SonarQube shows this as Noncompliant code (Refactor the code so this stream pipeline is used.)?
I have a few simple Java Streams in my code for these Streams SonarQube/Sonarlint shows as Noncompliant with the message:
Refactor the code so this stream pipeline is used.
Following are my Java ...
0
votes
0
answers
184
views
Sonar Lint how to suppress issues on commented code only
I have this piece of code.
public String createElasticSearchQuery(MultiValuedHashMap queryMap){
SearchSourceBuilder elasticSearchSourceBuilder = new SearchSourceBuilder();
...
0
votes
1
answer
63
views
Sonarlint plugin crashes when Eclipse is in Program Files
I have an installation of Eclipse 2021-12 with Sonarlint installed in C:\Program Files.
When I launch Eclipse, ang go to Window->Preferences, Sonarlint, there are no rules.
In the console, I have ...
1
vote
0
answers
65
views
SonarLint plugin misses some (SonarCloud's) rules locally
TL;DR -> Force code smells to apear as SonarCloud issues on IDE
I got SonarLint plugin (vscode) installed locally and configured with external SonarCloud rules (by my organization's project).
The ...
0
votes
1
answer
58
views
SonarLint: Remove the literal "false" boolean value
I get "Remove the literal "false" boolean value." error for the following statement, but I am not sure if there is a possibility to remove false. Any idea?
final boolean isDisabled ...
1
vote
0
answers
327
views
Not able to generate sonarqube report locally as I am getting the EXECUTION FAILURE with error log :Tasks support was removed in SonarQube 7.6
My requirement is to get the code coverage in local using Visual studio :
SonarQube server is up . I have attached the snapshot as shown :
jvm 1 | 2022.02.14 16:04:07 INFO app[][o.s.a....
0
votes
0
answers
74
views
SonarLint Plugin Initialisation Error in Eclipse IDE
I have recently installed SonarLint plugin in Eclipse IDE on one of my workstation.
However, while initialising the plugin, I am getting an error
Illegal character in path at index 16
because of ...
0
votes
0
answers
191
views
Failed to save project configuration org.osgi.service.prefs.BackingStoreException
I am trying to setup SonarLint and SonarCloud with the openEMR project in Eclipse. When I finally want to save the configuration, I am getting below error.
Failed to save project configuration
org....
0
votes
1
answer
300
views
Issue in analyzing files using sonar lint in eclipse
I installed sonar lint (version 7.2) in STS (version - 4.13.0), installation was completely fine.
But while analyzing the files using sonar lint, I am getting 0 issues with following logs in console -
...
0
votes
1
answer
236
views
Sonarlint for Eclipse - Unable to load plugin bundleentry error
I am getting below exception when tried to scan the project in Eclipse IDE for Java developers Version: 2021-12 (4.22.0) Build id: 20211202-1639
Starting SonarLint for Eclipse 7.2.0.42510
Started ...
-1
votes
1
answer
50
views
How to fix this sonarqube blocker without affecting to the logic
Could you please look at below image and please let me know the solution for this. I have tried to write a try-with-reources for Statement and Resultset but inside try block what should I write
enter ...
0
votes
2
answers
176
views
Using SonarLint with VSCode. How can I change the regex rule S116 for Jave uses?
I am using Sonarlint with VSCode on a Java project on Windows 10. My project has a variable naming convention such that we use underscores as long as it isn't the first character. These variables are ...
0
votes
1
answer
55
views
How can I fix below sonarqube issue
Please check the below screenshot. I was able to fix all the other issues using try-with-resources. But I'm confusing how to fix this using try-with-resources.
0
votes
0
answers
30
views
define or delete copy ctor in a helper class/struct that uses neither? [duplicate]
I have the following helper utility class defined in a header:
Util.h
struct Timer
{
std::chrono::time_point< std::chrono::steady_clock > start { std::chrono::steady_clock::now( ) };
std:...
0
votes
0
answers
95
views
SonarLint Generated Files, Visual Studio 2022, and .gitignore [duplicate]
I have SonarLint in Visual Studio 2022 connected to a local SonarQube instance for the first time, and as a part of that connection SonarLint adds a SonarLint.xml and SOLUTIONNAME.slconfig to the ...
1
vote
1
answer
736
views
sonarlint failed to analyze javascript code
sonarlint version: 6 ,
sonarqube version 9.2 ,
nodejs 16 and
configuration :
Node.js path is C:\programFile\nodejs but again plaese configure nodejs path in sonarlint setting.
5
votes
1
answer
169
views
A "constexpr" function should not be declared "inline"
By analyzing code using SonarLint, I got a message (the title of the question) about a destructor that is declared like below:
class Foo
{
public:
. // default ctor
. // parameterized ctor
.
...
1
vote
1
answer
616
views
Either log this exception and handle it, or rethrow it with some contextual information
Can some one help me why SonarLint is showing this:
Either log this exception and handle it, or rethrow it with some contextual information.
for below piece of code.
public static <T> T ...
0
votes
0
answers
38
views
Avoiding Sonarlint error efficiently in Java for infinite while loop
I have a RabbitMQ Consumer Java application that keeps on checking for the new message on the queue with a while(true) loop.
Is there any solution so I can avoid following Sonalint Blocker bug without ...
2
votes
2
answers
31
views
Sonarlint sentinel value fake positive
I have the next code snippet, where the sonarlint tool says that my boolean variable sentinel always evaluates to true, and the sentinel = true it's an useless asingment.
import static java.lang....
0
votes
1
answer
411
views
Sonarlint false positive NullPointer warning (S2259) when using ResponseEntity
For general restTemplate operation,as :
ResponseEntity<ResponseVO> response = restTemplate.postForEntity(url, entity, ResponseVO.class);
if (response.getBody() != null) {
String url = ...
1
vote
1
answer
249
views
SonarLint : Code Smell : Local variables should not be declared and then immediately returned or thrown
After analyzing my code with SonarLint, I get the following smell code: "Local variables should not be declared and then immediately returned or thrown".
Even if this is not blocking and the ...
0
votes
0
answers
124
views
SonarLint : Code smell : Rename this file to
After analyzing my code with SonarLint, I get the following smell code: Rename this file to "Notify".
I tried to change the name of my component several times but I still get the code smell.
...
-1
votes
1
answer
155
views
SonarLint: Remove the unneccessary boolean literal
I'm using the following code to select a record from an array where it's the oldest of the non deleted records.
const firstRec = records.filter(rec => rec.isDeleted != false)
.reduce((a, b) => ...
0
votes
0
answers
251
views
SonarLint Eclipse plugin does not find any issue
I would like to use SonarLint to find possible issues in my Java code. I installed SonarLint plugin from the official Eclipse Marketplace successfully. According to the console logs it runs, and ...