Skip to content

Commit

Permalink
Test: Violations in existing files
Browse files Browse the repository at this point in the history
  • Loading branch information
adangel committed Feb 19, 2022
1 parent c39a9f6 commit 636df08
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@v2
- uses: pmd/pmd-github-action@v1
#- uses: pmd/pmd-github-action@v1
#- uses: pmd/pmd-github-action@main
#- uses: pmd/pmd-github-action@features/annotation
#- uses: adangel/pmd-github-action@analyze-modified-files-only
- uses: adangel/pmd-github-action@issue-51-annotations-windows
id: pmd
with:
rulesets: 'ruleset.xml,category/java/design.xml/AbstractClassWithoutAnyMethod'
8 changes: 8 additions & 0 deletions src/main/java/AvoidCatchingThrowableSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@ public void bar() {
th.printStackTrace();
}
}

public void foo() {
try {
// do something
} catch (Throwable th) { // should be reported as "AvoidCatchingThrowable" (prio 2, failure)
th.printStackTrace();
}
}
}
10 changes: 10 additions & 0 deletions src/main/java/ReturnFromFinallyBlockSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,14 @@ public String bar() {
return "A. O. K."; // should be reported as "ReturnFromFinallyBlock" (prio 3, warning)
}
}

public String foo() {
try {
throw new Exception( "My Exception" );
} catch (Exception e) {
throw e;
} finally {
return "A. O. K."; // should be reported as "ReturnFromFinallyBlock" (prio 3, warning)
}
}
}

0 comments on commit 636df08

Please sign in to comment.