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#13345: Enable RightCurlyCheckExampleTest
- Loading branch information
1 parent
a820a89
commit a379ad8
Showing
11 changed files
with
290 additions
and
230 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
60 changes: 60 additions & 0 deletions
60
...examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/Example1.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,60 @@ | ||
/*xml | ||
<module name="Checker"> | ||
<module name="TreeWalker"> | ||
<module name="RightCurly"/> | ||
</module> | ||
</module> | ||
*/ | ||
|
||
package com.puppycrawl.tools.checkstyle.checks.blocks.rightcurly; | ||
|
||
// xdoc section -- start | ||
public class Example1 { | ||
|
||
public void test() { | ||
|
||
boolean foo = false; | ||
if (foo) { | ||
bar(); | ||
} // violation, 'should be on the same line' | ||
// as the next part of a multi-block statement (one that directly | ||
// contains multiple blocks: if/else-if/else, do/while or try/catch/finally). | ||
else { | ||
bar(); | ||
} | ||
|
||
if (foo) { | ||
bar(); | ||
} else { | ||
bar(); | ||
} | ||
|
||
if (foo) { bar(); } int i = 0; | ||
// violation above, 'should be alone on a line.' | ||
|
||
if (foo) { bar(); } | ||
i = 0; | ||
|
||
try { | ||
bar(); | ||
} // violation, 'should be on the same line' | ||
// as the next part of a multi-block statement (one that directly | ||
// contains multiple blocks: if/else-if/else, do/while or try/catch/finally). | ||
catch (Exception e) { | ||
bar(); | ||
} | ||
|
||
try { | ||
bar(); | ||
} catch (Exception e) { | ||
bar(); | ||
} | ||
|
||
} | ||
|
||
private void bar() { | ||
} | ||
|
||
public void testSingleLine() { bar(); } // OK, because singleline is allowed | ||
} | ||
// xdoc section -- end |
50 changes: 0 additions & 50 deletions
50
...-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/Example1.txt
This file was deleted.
Oops, something went wrong.
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
40 changes: 40 additions & 0 deletions
40
...examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/Example3.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,40 @@ | ||
/*xml | ||
<module name="Checker"> | ||
<module name="TreeWalker"> | ||
<module name="RightCurly"> | ||
<property name="option" value="alone"/> | ||
<property name="tokens" value="LITERAL_SWITCH"/> | ||
</module> | ||
</module> | ||
</module> | ||
*/ | ||
|
||
package com.puppycrawl.tools.checkstyle.checks.blocks.rightcurly; | ||
|
||
// xdoc section -- start | ||
class Example3 { | ||
|
||
public void method0() { | ||
int mode = 0; | ||
switch (mode) { | ||
case 1: | ||
int x = 1; | ||
break; | ||
default: | ||
x = 0; | ||
} // ok, RightCurly is alone | ||
} | ||
|
||
public void method01() { | ||
int mode = 0; | ||
switch (mode) { | ||
case 1: | ||
int x = 1; | ||
break; | ||
default: | ||
x = 0; } | ||
// violation above, 'should be alone on a line.' | ||
} | ||
|
||
} | ||
// xdoc section -- end |
37 changes: 0 additions & 37 deletions
37
...-examples/resources/com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly/Example3.txt
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.