Branch: refs/heads/master
  Home:   https://github.com/pmd/pmd
  Commit: 50f748e191fe9d8fe136ae5b6d6a6d2ecb0541f9
      https://github.com/pmd/pmd/commit/50f748e191fe9d8fe136ae5b6d6a6d2ecb0541f9
  Author: Andreas Dangel <[email protected]>
  Date:   2019-10-20 (Sun, 20 Oct 2019)

  Changed paths:
    M docs/pages/release_notes.md
    M 
pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symboltable/ClassScope.java
    M 
pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/UnusedPrivateMethod.xml

  Log Message:
  -----------
  [java] UnusedPrivateMethod false-positive with method result

Fixes #1531

In case we determined, that the method argument is a method call,
then we skip now completly trying to determine the correct argument
type. It was half-way fixed before for the first if condition, but
we still evaluated e.g. the allocation expression in

    print(new Integer(1).toString());

and wrongly assumed, the argument type would be an integer,
without taking into account the `toString()` method call.

The same happened with

    privateBooleanMethod(s, "true".equals(s));

where we took the 2nd argument as a literal and assumed
it is a "String", while the method call result actually
is a boolean.

With this change now, the false positive is fixed.

However, since we don't determine the argument type at all, the
method is matched solely on argument count. This will obviously
lead to wrong matches if method overloading is used.


  Commit: 9a2314ab5db294a8f2ed570e876e70ee730e570b
      https://github.com/pmd/pmd/commit/9a2314ab5db294a8f2ed570e876e70ee730e570b
  Author: Juan Martín Sotuyo Dodero <[email protected]>
  Date:   2019-10-23 (Wed, 23 Oct 2019)

  Changed paths:
    M docs/pages/release_notes.md
    M 
pmd-java/src/main/java/net/sourceforge/pmd/lang/java/symboltable/ClassScope.java
    M 
pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/bestpractices/xml/UnusedPrivateMethod.xml

  Log Message:
  -----------
  Merge pull request #2079 from adangel/issue-1531-unusedprivatemethod

[java] UnusedPrivateMethod false-positive with method result


Compare: https://github.com/pmd/pmd/compare/abc048ce41bf...9a2314ab5db2


_______________________________________________
Pmd-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pmd-commits

Reply via email to