Skip to main content

Split variable declarations into their own statements (Sonar)

sonar:java/declare-variable-on-separate-line-s1659​

ImportanceReview GuidanceRequires Scanning Tool
LOWMerge Without ReviewYes (Sonar)

This change splits variable assignments onto their own lines. Many sources believe it is easier to review code where the variables are separate statements on their own individual line.

Our changes look something like this:

-   int i = 0, limit = 10;
+ int i = 0;
+ int limit = 10;

while (i < limit){

F.A.Q.​

Why is this codemod marked as Merge Without Review?​

There is no functional difference after the change, but the source code will be easier to understand.

References​