Suppressing java:S104 - Long Class File

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)- Developer Edition Version 9.9.1

  • how is SonarQube deployed: zip, Docker, Helm - Helm

  • what are you trying to achieve -
    Trying to suppress one of the rules namely java:S104 which is pertaining to long class file. One of the java class gives a rule violation error - This file has 1,486 lines, which is greater than 1,000 authorized. Split it into smaller files.
    For some reasons we do not want to break down the class file that we have. The concerned class also has nested static classes as well. So we want to suppress this Rule check failure for the class

  • what have you tried so far to achieve this:
    I have tried putting @SuppressWarnings(" java:S104") on top of outer most class - This did not worked
    I have tried putting @SuppressWarnings(" squid:S104") on top of outer most class - This also did not worked
    I have tried putting // NOSONAR on top of outer most class - This also did not worked.
    I am also suppressing some other Rules like “java:S116”,“java:S3398” and these are getting suppressed but not java:S104

Please Suggest
Thank you

Hi,

Welcome to the community!

I think the in-file suppressions you’re trying aren’t working because the issue is file-level. I’ll raise that with the team.

In the meantime, you can use a multi-criteria exclusion to accomplish what you’re after.

 
HTH,
Ann

3 Likes

Thanks for the response Ann.
I will follow the suggested approach and check if that works.