Commented code rule

Hi everyone,

I have problem with commented code rule,

I’m sure in another versions of Quality Profiles, exists a rule for lines of code commented. But in my current versión of SonarCloud. I only have “Sections of code should not be commented out”, so when I have line commented, Sonar don’t detected (the rule works in sections or blocks, but the “problem” is in the logic lines of code commented).

Thanks and greetings!

Hey there.

Can you share a sample of code where a single line is commented out and not detected? The rule is not precious about the number of lines (and a single line counts as a “section”) :slight_smile:

Hi Colin, thanks for your answer.

For example:

public static boolean validToken(string idNumber) {
   String idToken = Util.getTokenById(idNumber);
   if(idToken != null) { // || idToken != "") {
   return idToken;

I this days I checked the issues is detected, sometimes, in code like:

String error = Util.convertToJson(ex.getStatusText(), Example.class) // gson.FromJson(ex.getStatus(), Error.class)

Hello @Joaquin_Alonso_Dinam,

Thank you for reporting!

I checked your example and I could not reproduce the issue as it is now detected. I am using the latest version of SonarLint-Intellij (8.1).



In my caase the sonar lint plugin can find the problem.
But the results from the sonar scanner in circle does not show the commented code as an problem.
The rule to detect commeted code is enabled but is not triggered.

Any suggestions?