Menu

#1448 [java] ImmutableField: Private field in inner class gives false positive with lambdas

PMD-5.4.4
closed
None
PMD
3-Major
Bug
5.4.0
2017-01-28
2015-12-04
Rei Angelus
No

A little example of this false positive:

   <test-code>
        <description>ImmutableField Rule: Private field in inner class gives false positive</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class CombinersTest {

    private static final BinaryOperator<Purse> ADDITION = (p1, p2) -> {
        p1.amount += p2.amount;
        return p1;
    };

    private static class Purse {
        private int amount;

        public Purse(final int amount) {
            this.amount = amount;
        }
      }

}
        ]]></code>
    </test-code>

Thanks

Discussion

  • Andreas Dangel

    Andreas Dangel - 2017-01-27
    • summary: ImmutableField Rule: Private field in inner class gives false positive --> [java] ImmutableField Rule: Private field in inner class gives false positive
     
  • Andreas Dangel

    Andreas Dangel - 2017-01-28
    • summary: [java] ImmutableField Rule: Private field in inner class gives false positive --> [java] ImmutableField: Private field in inner class gives false positive with lambdas
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,5 +1,6 @@
     A little example of this false positive:
    
    +`````
     :::xml
    
        <test-code>
    @@ -24,5 +25,7 @@
     }
             ]]></code>
         </test-code>
    -    
    +`````
    +
    +
      Thanks
    
    • status: open --> in-progress
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> PMD-5.4.4
     
  • Andreas Dangel

    Andreas Dangel - 2017-01-28
    • status: in-progress --> closed
     
  • Andreas Dangel

    Andreas Dangel - 2017-01-28

    Thanks for reporting.
    This bug will be fixed with PMD 5.4.4, 5.5.3 and later.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.