GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [java] SimplifiedTernary: Incorrect ternary operation can be simplified. · Issue #232 · pmd/pmd

[java] SimplifiedTernary: Incorrect ternary operation can be simplified. #232

New issue
Copy link
New issue
Copy link
Closed
Closed
[java] SimplifiedTernary: Incorrect ternary operation can be simplified.#232
Copy link
Assignees
jsotuyod
Labels
a:bugPMD crashes or fails to analyse a file.
Milestone
5.4.5

Description

@SUPERCILEX
SUPERCILEX
opened on Feb 2, 2017
Issue body actions

Rule Set: basic.html#SimplifiedTernary

Description: I have a special case where to save money in my database, I return null if a boolean value is false in a method of return type Boolean.

Code Sample demonstrating the issue:

@Nullable
public Boolean getHasCustomName() {
    return mHasCustomName ? true : null; // From my understanding of Java, this cannot be simplified.
}

Running PMD through: Gradle

Activity

  1. jsotuyod
    added
    a:bugPMD crashes or fails to analyse a file.
    on Feb 2, 2017
  2. jsotuyod
    added this to the 5.4.5 milestone on Feb 2, 2017
  3. jsotuyod
    self-assigned this
    on Feb 2, 2017
  4. jsotuyod
    added a commit that references this issue on Feb 2, 2017

    [java] Fix FP in SimplifiedTernary with null value

    This issue will close once commit fbd9d21 is merged into the 'main' branch.
    fbd9d21
  5. adangel
    changed the title [-][java] Incorrect ternary operation can be simplified.[/-] [+][java] SimplifiedTernary: Incorrect ternary operation can be simplified.[/+] on Feb 12, 2017
  6. adangel commented on Feb 12, 2017

    @adangel
    adangel
    on Feb 12, 2017
    Member
    More actions

    Thanks for reporting. This bug will be fixed with PMD 5.4.5, 5.5.4, and later.

  7. adangel
    added 2 commits that reference this issue on Feb 12, 2017

    [java] Fix FP in SimplifiedTernary with null value

    This issue will close once commit ed77143 is merged into the 'main' branch.
    ed77143

    Update changelog, fixes pmd#232

    This issue will close once commit fc1e90b is merged into the 'main' branch.
    fc1e90b
  8. adangel
    closed this as completedin #236on Feb 12, 2017
  9. sschuberth commented on Mar 21, 2017

    @sschuberth
    sschuberth
    on Mar 21, 2017
    More actions

    @adangel Has this really been fixed for 5.5.4? Because for me 5.5.4 still has this issue, although with a slightly different piece of code:

    setToogle(varOfBooleanClass != null ? varOfBooleanClass : false);
    
  10. jsotuyod commented on Mar 21, 2017

    @jsotuyod
    jsotuyod
    on Mar 21, 2017
    Member
    More actions

    @sschuberth actually that is not a false positive. The rule is right, you could rewrite that without the conditional as:

    setToogle(varOfBooleanClass != null && varOfBooleanClass);
    Reacted by Jon Bevan, Jessica Shin, Gaurav Ranade, Sören Henning and chiamyunqing
  11. sschuberth commented on Mar 21, 2017

    @sschuberth
    sschuberth
    on Mar 21, 2017
    More actions

    @jsotuyod Doh, you're right, thanks for opening my eyes!

  12. sschuberth
    added a commit that references this issue on Apr 10, 2017

    Bump the PMD version used by the plugin to 5.5.5

    d442a83
  13. bmuschko
    added a commit that references this issue on Apr 11, 2017

    Bump the PMD version used by the plugin to 5.5.5 (#1623)

    3c041bb
  14. w25r
    added a commit that references this issue on May 3, 2017

    Bump the PMD version used by the plugin to 5.6.1 (#1858)

    c0b15be
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @jsotuyod
    jsotuyod

Labels

a:bugPMD crashes or fails to analyse a file.

Type

No type

Projects

No projects

    Milestone

    • 5.4.5

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.