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] UselessStringValueOf: False positive when there is no initial String to append to · Issue #3492 · pmd/pmd

[java] UselessStringValueOf: False positive when there is no initial String to append to #3492

New issue
Copy link
New issue
Copy link
Closed
#3631
Closed
[java] UselessStringValueOf: False positive when there is no initial String to append to#3492
#3631
Copy link
Labels
a:false-positivePMD flags a piece of code that is not problematic
Milestone
6.42.0

Description

@pzygielo
pzygielo
opened on Aug 28, 2021
Issue body actions

Affects PMD Version: 6.37.0

Rule: UselessStringValueOf

Description: False positive, when there is no initial String to append to.

Code Sample demonstrating the issue:
40b5f95/#3490

public class Test {
    private short getPrefix(long id) {
        return 0;
    }
    private short getTimestamp(long id) {
        return 0;
    }
    private short getCounter(long id) {
        return 0;
    }
    public String toShortString(long id) {
        return String.valueOf(getPrefix(id)) + getTimestamp(id) + getCounter(id); // (12)
    }
}

Expected outcome:

PMD reports a violation at line 12, but that's wrong. That's a false positive.

Running PMD through: Maven

Activity

  1. pzygielo
    added
    a:false-positivePMD flags a piece of code that is not problematic
    on Aug 28, 2021
  2. adangel
    changed the title [-]False positive for `UselessStringValueOf`, when there is no initial String to append to[/-] [+][java] False positive for `UselessStringValueOf`, when there is no initial String to append to[/+] on Nov 16, 2021
  3. adangel
    changed the title [-][java] False positive for `UselessStringValueOf`, when there is no initial String to append to[/-] [+][java] UselessStringValueOf - False positive when there is no initial String to append to[/+] on Nov 16, 2021
  4. adangel
    added this to the 6.42.0 milestone on Nov 26, 2021
  5. adangel
    changed the title [-][java] UselessStringValueOf - False positive when there is no initial String to append to[/-] [+][java] UselessStringValueOf: False positive when there is no initial String to append to[/+] on Dec 3, 2021
  6. adangel
    added 2 commits that reference this issue on Dec 3, 2021

    [doc] Update release notes (#3492, #3631)

    72a037d

    Merge pull request #3631 from johnra2:3492-usvo-fp-no-initial-string

    641b0e9
  7. adangel
    closed this as completedin #3631on Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-positivePMD flags a piece of code that is not problematic

    Type

    No type

    Projects

    No projects

      Milestone

      • 6.42.0

      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.