forked from checkstyle/checkstyle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue checkstyle#15340: created inputFormatted file for section 4.8.2…
….1 One variable per declaration
- Loading branch information
1 parent
4616146
commit fec0f28
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
...hapter4formatting/rule4821onevariableperline/InputFormattedOneVariablePerDeclaration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package com.google.checkstyle.test.chapter4formatting.rule4821onevariableperline; | ||
|
||
/** Some javadoc. */ | ||
public class InputFormattedOneVariablePerDeclaration { | ||
int mnp, efg; // violation 'Each variable declaration must be in its own statement.' | ||
int i1; | ||
int j1; | ||
|
||
void method1() { | ||
String str, str1; // violation 'Each variable declaration must be in its own statement.' | ||
java.lang.Object obj; | ||
Object obj1; | ||
} | ||
|
||
// second definition is wrapped | ||
// line of VARIABLE_DEF is not the same as first line of the definition | ||
java.lang.String string; | ||
java.lang.String[] strings; | ||
// both definitions are wrapped | ||
java.lang.String string1; | ||
java.lang.String[] strings1; | ||
|
||
void method2() { | ||
for (int i = 0, j = 0; i < 10; i++, j--) { // ok | ||
} | ||
|
||
for (int i = 0; i < 4; i++) {} | ||
} | ||
|
||
class Inner { | ||
int xyz, qwe; // violation 'Each variable declaration must be in its own statement.' | ||
int i1; | ||
int j1; | ||
|
||
void method1() { | ||
String str, str1; | ||
// violation above 'Each variable declaration must be in its own statement.' | ||
java.lang.Object obj; | ||
Object obj1; | ||
} | ||
|
||
// second definition is wrapped | ||
// line of VARIABLE_DEF is not the same as first line of the definition | ||
java.lang.String string; | ||
java.lang.String[] strings; | ||
// both definitions are wrapped | ||
java.lang.String string1; | ||
java.lang.String[] strings1; | ||
|
||
void method2() { | ||
for (int i = 0, j = 0; i < 10; i++, j--) { // ok | ||
} | ||
|
||
for (int i = 0; i < 4; i++) {} | ||
} | ||
|
||
Inner anon = | ||
new Inner() { | ||
int abc, pqr; // violation 'Each variable declaration must be in its own statement.' | ||
int i1; | ||
int j1; | ||
|
||
void method1() { | ||
String str, str1; | ||
// violation above 'Each variable declaration must be in its own statement.' | ||
java.lang.Object obj; | ||
Object obj1; | ||
} | ||
|
||
// second definition is wrapped | ||
// line of VARIABLE_DEF is not the same as first line of the definition | ||
java.lang.String string; | ||
java.lang.String[] strings; | ||
// both definitions are wrapped | ||
java.lang.String string1; | ||
java.lang.String[] strings1; | ||
|
||
void method2() { | ||
for (int i = 0, j = 0; i < 10; i++, j--) { // ok | ||
} | ||
|
||
for (int i = 0; i < 4; i++) {} | ||
} | ||
}; | ||
} | ||
|
||
class Suppress { | ||
@SuppressWarnings("unused") | ||
// violation above 'Each variable declaration must be in its own statement.' | ||
long q1, q2, q3; | ||
@SuppressWarnings("unused") | ||
long q4, q5, q6; | ||
// violation 2 lines above 'Each variable declaration must be in its own statement.' | ||
} | ||
} |