From bfcbc3b5e043d346fa82192f23d25b7380307a5b Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Sat, 12 Nov 2022 20:21:42 +0100 Subject: [PATCH] Re-introduce test code --- .github/workflows/pitest-analyze-pr.yml | 26 +++++++++++++++++++ .../bugpatterns/PrimitiveComparison.java | 8 ++++++ 2 files changed, 34 insertions(+) diff --git a/.github/workflows/pitest-analyze-pr.yml b/.github/workflows/pitest-analyze-pr.yml index c63baaa07e7..bd05ae9cfa8 100644 --- a/.github/workflows/pitest-analyze-pr.yml +++ b/.github/workflows/pitest-analyze-pr.yml @@ -30,3 +30,29 @@ jobs: with: name: pitest-reports path: ./target/pit-reports-ci + + # XXX: Drop the job below. Here only for testing purposes. + update-pr: + permissions: + actions: read + checks: write + contents: read + pull-requests: write + needs: analyze-pr + runs-on: ubuntu-22.04 + steps: + - name: Check out code + uses: actions/checkout@v3.1.0 + - name: Set up JDK + uses: actions/setup-java@v3.6.0 + with: + java-version: 17 + distribution: temurin + cache: maven + - name: Download Pitest analysis artifact + uses: actions/download-artifact@v3.0.1 + with: + name: pitest-reports + path: ./target/pit-reports-ci + - name: Update PR + run: mvn -DrepoToken="${{ secrets.GITHUB_TOKEN }}" pitest-github:updatePR diff --git a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparison.java b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparison.java index bd26e35d3f9..91067945f20 100644 --- a/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparison.java +++ b/error-prone-contrib/src/main/java/tech/picnic/errorprone/bugpatterns/PrimitiveComparison.java @@ -80,6 +80,14 @@ public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState return Description.NO_MATCH; } + if (state.getSourceForNode(tree).equals("XXX")) { + return Description.NO_MATCH; + } + + if (state.getSourceForNode(tree).equals("YYY")) { + return Description.NO_MATCH; + } + return getPotentiallyBoxedReturnType(tree.getArguments().get(0)) .flatMap(cmpType -> attemptMethodInvocationReplacement(tree, cmpType, isStatic, state)) .map(fix -> describeMatch(tree, fix))