Skip to content

[core] Utility classes in pmd 7 #2873

@oowekyala

Description

@oowekyala

Currently on master, all of the nspmd.util package was marked internal (#2060), and we have a few utility classes in nspmd.internal.util. Some of those are used in other pmd modules (IteratorUtil, StringUtil, CollectionUtil).

I think we should be strict about usage of internal API, ie, even modules in the main repo should not have access to pmd core's internal API.

I think we should have public utilities in nspmd.util, and a nspmd.util.internal for utils that are only relevant to pmd core (eg, IOUtil).

Public ones include at least:

  • IteratorUtil (should be moved from nspmd.internal.util)
  • CollectionUtil
  • StringUtil
  • AssertionUtil
  • GraphUtil (used in pmd-java)

Plus stuff like OptionalBool and DataMap. Publishing IteratorUtil also allows us to remove DesignerIteratorUtil from the designer codebase (it was intentionally copied to not depend on pmd-core's internals).

Other things should be internal (esp. FileUtil and IOUtil, which are only relevant to pmd-core).

We can also use the InternalApiUsage rule to verify that there is no internal api leak across our codebase.

Refs #995

Metadata

Metadata

Assignees

No one assigned

    Labels

    an:enhancementAn improvement on existing features / rules

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions