switch statements are used to trigger different block of code based on different values. Developers should avoid switch statements with less than 3 branches. If a switch statement has less than 3 branches, we should rather use a if statement.
classMain{publicstaticvoidmain(String[]args){switch(condition){casevalue1:break;casevalue2:break;default:break;}switch(condition){casevalue1:// comments are supportedcasevalue2:break;default:break;}}}
Seamless integrations. Try Datadog Code Analysis
Datadog Code Analysis
Try this rule and analyze your code with Datadog Code Analysis
How to use this rule
1
2
rulesets:- java-best-practices # Rules to enforce Java best practices.
Create a static-analysis.datadog.yml with the content above at the root of your repository
Use our free IDE Plugins or add Code Analysis scans to your CI pipelines