When I use SonarLint plugin to scan the Java code in IntelliJ IDEA, it shows warning like this: remove usage of generic wildcard type. This is the Java code: What should I do to avoid this warnings? Answer You should use generic type or actual type for return type of method declaration Or Or specific type:
Tag: sonarqube
Java mutable object to causing nullpointer exception
I have the following DTO and I pass the objects to the ArrayLists to prevent objects to be changed and fix the SonarQube error as “Message: Store a copy of allergenInfoList”, etc. However, this approach requires null check and it makes my code ugly as shown below: So, is there any better approach to fix the problem without null check?
How to remove duplicate cases in switch in java
I have sonarQube running but it says that there are duplicates within these lines of code. How do resolve this in a switch statement? I am just learning how unit testing in java works so any help would be great! Answer I think below solution should work for you:
Using SonarQube how would one implement a java import blacklist?
Using SonarQube (version 3.0) I am trying to implement a blacklist of java libraries. For example I’d like for SonarQube to generate a code smell for any java file that contains an import for org.apache.lang.StringUtils I did find this rule: “Track uses of disallowed dependencies” however as previously stated I want to focus on the java file import statements themselves.
Searching for issues with Sonarcloud API returns none even though they exist
I am trying to get all the sonar report issues from a branch of a private Sonarcloud project. I do this with the following REST call: https://@sonarcloud.io/api/issues/search?projects=…
Sonar: Possible null pointer dereference due to return value of called method
I am getting issue from Sonar: “Style – Possible null pointer dereference due to return value of called method. findbugs:NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE. the issue is on lockUntil.after(…
Sonar Cube “null pointer exception could be thrown” : False positive?
I have a bug raised by sonar cube on following code : private request = null; try { request = createRequest(); // create Request log.info(” Request created with details “+request.toString());…
Singleton writes a field in unsynchronized manner
I am getting : Singleton class writes to a field in an unsynchronized manner at 4-5 places in Springboot code while scanning through SonarQube. Now, I am trying to understand how can I make this …
Kotlin, Java 8 and Sonar coverage showing as 0
I have a kotlin project using Java 8 and I use Sonar to measure code coverage I am using the latest version of Sonar and noticed the coverage has gone down due to changes in the openjdk. My tests are …
Sonar with multi-module gradle project
I have java and kotlin based multi module gradle project. I am trying to setup sonar analysis for the same. I configured sonar at root project and ran analysis with CircleCI. The result in sonarcloud gets for only one of the sub-project. My project structure is as below: projectA/build.gradle ProjectB/build.gradle ProjectC/build.gradle build.gradle Here is my root build.gradle. Answer Need to