A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/5207 below:

false positve for a private method `void skip(int)` in a subclass of FilterInputStream · Issue #5207 · pmd/pmd · GitHub

Affects PMD Version: 7.5.0, 7.4.0, 7.3.0 (worked back in 7.2.0)

Rule:

CheckSkipResult
https://docs.pmd-code.org/pmd-doc-7.5.0/pmd_rules_java_errorprone.html#checkskipresult

Description:
Reproducer for Apache Commons Compress:

git clone https://gitbox.apache.org/repos/asf/commons-compress.git
cd commons-compress.git
git checkout 287e94beb6a81ddf111403b4c56ab80f957308b5

Fails when running:

mvn pmd:check -Dcommons.pmd-impl.version=7.4.0
...
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-pmd-plugin:3.24.0:check (default-cli) on project commons-compress: PMD 7.4.0 has found 3 violations. For more details see: C:\Users\ggregory\git\a\commons-compress\target\pmd.xml -> [Help 1]

Passes when running:

mvn commons.pmd-impl.version 

For all callers of a custom method:

    private void skip(final int bytes) throws IOException {
        // bytes cannot be more than 3 bytes
        if (bytes > 0) {
            readFully(fourBytesBuf, 0, bytes);
        }
    }

Expected outcome:

PMD reports 3 violations at lines:

<?xml version="1.0" encoding="iso-8859-1"?>
<pmd xmlns="http://pmd.sourceforge.net/report/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sourceforge.net/report/2.0.0 https://pmd.github.io/schema/report_2_0_0.xsd" version="7.5.0" timestamp="2024-09-11T17:25:13.760">
<file name="C:\Users\ggregory\git\a\commons-compress\src\main\java\org\apache\commons\compress\archivers\cpio\CpioArchiveInputStream.java">
<violation beginline="334" endline="334" begincolumn="13" endcolumn="42" rule="CheckSkipResult" ruleset="Error Prone" package="org.apache.commons.compress.archivers.cpio" class="CpioArchiveInputStream" method="read" externalInfoUrl="https://docs.pmd-code.org/pmd-doc-7.5.0/pmd_rules_java_errorprone.html#checkskipresult" priority="3">
Check the value returned by the skip() method of an InputStream to see if the requested number of bytes has been skipped.
</violation>
<violation beginline="424" endline="424" begincolumn="9" endcolumn="50" rule="CheckSkipResult" ruleset="Error Prone" package="org.apache.commons.compress.archivers.cpio" class="CpioArchiveInputStream" method="readNewEntry" externalInfoUrl="https://docs.pmd-code.org/pmd-doc-7.5.0/pmd_rules_java_errorprone.html#checkskipresult" priority="3">
Check the value returned by the skip() method of an InputStream to see if the requested number of bytes has been skipped.
</violation>
<violation beginline="487" endline="487" begincolumn="9" endcolumn="50" rule="CheckSkipResult" ruleset="Error Prone" package="org.apache.commons.compress.archivers.cpio" class="CpioArchiveInputStream" method="readOldBinaryEntry" externalInfoUrl="https://docs.pmd-code.org/pmd-doc-7.5.0/pmd_rules_java_errorprone.html#checkskipresult" priority="3">
Check the value returned by the skip() method of an InputStream to see if the requested number of bytes has been skipped.
</violation>
</file>
<suppressedviolation filename="C:\Users\ggregory\git\a\commons-compress\src\main\java\org\apache\commons\compress\changes\ChangeSetPerformer.java" suppressiontype="//nopmd" msg="This if statement could be combined with its parent" usermsg=" NOSONAR
"></suppressedviolation>
</pmd>

All 3 violations are false positives.

Running PMD through: Maven


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4