In Java, it is possible to declare multiple variables of the same type on a single line using commas. This can make code more cluttered and less readable. Declare each variable on a separate line to improve code clarity and maintainability.
Non-Compliant Code Examples
publicclassPerson{// combined declarations (same line) - a violationStringfirstName,lastName;// combined declaration (diff line) - no violationStringfirstName,lastName;}
Compliant Code Examples
publicclassPerson{// separate declarations - no violationStringfirstName;StringlastName;}
シームレスな統合。 Datadog Code Security をお試しください
Datadog Code Security
このルールを試し、Datadog Code Security でコードを解析する
このルールの使用方法
1
2
rulesets:- java-best-practices # Rules to enforce Java best practices.