Menu

#1307 False positive: SingularField and lambda-expression

PMD-5.3.0
closed
None
PMD
3-Major
Bug
5.2.2
2015-04-01
2015-01-13
No
package com.foo;

import java.util.Optional;

public enum Supplier {
    bar("Bar"),

    private final String supplierName;

    private Supplier(String supplierName) {
        this.supplierName = supplierName;
    }

    public static String getSupplierNameIfPresent(String supplier) {
        return Optional.ofNullable(supplier).map(foo -> valueOf(supplier).supplierName).orElse("");
    }
}

Discussion

  • PJ Walstroem

    PJ Walstroem - 2015-01-13

    violates SingularField:
    "Perhaps 'supplierName' could be replaced by a local variable."

     

    Last edit: PJ Walstroem 2015-01-13
  • Andreas Dangel

    Andreas Dangel - 2015-03-27
    • status: open --> closed
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> PMD-Next
     
  • Andreas Dangel

    Andreas Dangel - 2015-03-27

    Will be fixed with the next version.

     

Log in to post a comment.