forked from checkstyle/checkstyle
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue checkstyle#3839: Added 3 methods to help detect empty LITERAL_C…
…ASE. Added corresponding UTs
- Loading branch information
Showing
3 changed files
with
140 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
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
36 changes: 36 additions & 0 deletions
36
src/test/resources/com/puppycrawl/tools/checkstyle/checks/blocks/InputEmptyCase.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,36 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// Input test file for testing empty LITERAL_CASE. | ||
// Created: 2017 | ||
//////////////////////////////////////////////////////////////////////////////// | ||
package com.puppycrawl.tools.checkstyle.checks.blocks; | ||
|
||
class InputEmptyCase | ||
{ | ||
void method1(int a) { | ||
switch (a) {} | ||
switch (a) {case 1:} | ||
switch (a) {case 1:{}} // 1 violation | ||
switch (a) { | ||
case 1: | ||
} | ||
switch (a) { | ||
case 1: // 1 violation | ||
{} | ||
} | ||
switch (a) { | ||
case 1: // 1 violation if checking statements | ||
{// none if checking text | ||
} | ||
} | ||
} | ||
|
||
public void method2(char c) { | ||
switch(c) { case 0: } // no violation | ||
switch(c) { case 0: {} } // 1 violation | ||
switch(c) { case 0: method1(0); {} } // no violation | ||
switch(c) { case 0: case 1: {} } // 1 violation | ||
switch(c) { case 0: {} case 1: {// 2 violations if checking statements | ||
} | ||
} | ||
} | ||
} |