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] New rule UnnecessaryImport, deprecate DuplicateImports, ImportFromSamePackage, UnusedImports, DontImportJavaLang · Issue #3128 · pmd/pmd

[java] New rule UnnecessaryImport, deprecate DuplicateImports, ImportFromSamePackage, UnusedImports, DontImportJavaLang #3128

New issue
Copy link
New issue
Copy link
Closed
#3200
Closed
[java] New rule UnnecessaryImport, deprecate DuplicateImports, ImportFromSamePackage, UnusedImports, DontImportJavaLang#3128
#3200
Copy link
Labels
a:new-ruleProposal to add a new built-in ruleis:deprecationThe main focus is deprecating public APIs or rules, eg to make them internal, or removing them
Milestone
6.34.0

Description

@oowekyala
oowekyala
opened on Feb 19, 2021
Issue body actions

Is your feature request related to a problem? Please describe.

We have the rules DuplicateImports, UnusedImports, and ImportFromSamePackage

  • Duplicate imports are useless, so I think the first rule should naturally be subsumed by the second.
  • The DuplicateImports rule tries to figure out whether the imports overlap or whether they maybe are necessary because of some ambiguity. This is awkward and should already be better checked by UnusedImports (because it considers eg comments). There's really no need to write that logic twice. The same argument applies to ImportFromSamePackage, although it doesn't even try to handle these conflicts.
  • The rules are in 3 different categories (codestyle, bestpractices, errorprone), which is confusing. I don't see a reason to use one and not the other.

Describe the solution you'd like Deprecate DuplicateImports and ImportFromSamePackage in favor of UnusedImports.
Deprecate all 3 existing rules and add a new rule "UnnecessaryImport" which replaces these 3.

Additional context Updating DuplicateImports and UnusedImports to pmd 7 is not going to be trivial, which is why removing one of those would be nice. I don't even know why ImportFromSamePackage is separate.

Activity

  1. oowekyala
    added
    is:deprecationThe main focus is deprecating public APIs or rules, eg to make them internal, or removing them
    on Feb 19, 2021
  2. oowekyala
    changed the title [-][java] Deprecate DuplicateImports[/-] [+][java] Deprecate DuplicateImports and ImportFromSamePackage[/+] on Apr 5, 2021
  3. oowekyala
    added 3 commits that reference this issue on Apr 5, 2021

    Make UnusedImports report duplicate imports

    b77f1d1

    Deprecate rules DuplicateImports, ImportFromSamePackage

    e9a7097

    Make UnusedImports recognize imports from same package

    8420910
  4. oowekyala
    added this to the 6.34.0 milestone on Apr 5, 2021
  5. adangel
    changed the title [-][java] Deprecate DuplicateImports and ImportFromSamePackage[/-] [+][java] New rule UnnecessaryImport, deprecate DuplicateImports, ImportFromSamePackage, UnusedImports[/+] on Apr 19, 2021
  6. adangel
    added
    a:new-ruleProposal to add a new built-in rule
    on Apr 19, 2021
  7. adangel
    closed this as completedin #3200on Apr 19, 2021
  8. adangel
    added a commit that references this issue on Apr 19, 2021

    [doc] Update release notes, refs pmd#3200, refs pmd#3128

    235e55a
  9. oowekyala
    changed the title [-][java] New rule UnnecessaryImport, deprecate DuplicateImports, ImportFromSamePackage, UnusedImports[/-] [+][java] New rule UnnecessaryImport, deprecate DuplicateImports, ImportFromSamePackage, UnusedImports, DontImportJavaLang[/+] on Apr 19, 2021
  10. oowekyala
    added a commit that references this issue on Apr 20, 2021

    Remove deprecated imports rules

    078e903
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:new-ruleProposal to add a new built-in ruleis:deprecationThe main focus is deprecating public APIs or rules, eg to make them internal, or removing them

    Type

    No type

    Projects

    No projects

      Milestone

      • 6.34.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.