Skip to content

ForbidWildcardImports misses indented import statements #2938

@mirkoalicastro

Description

@mirkoalicastro

While testing some other spotless changes, I noticed this interesting behaviour. ForbidWildcardImports fails to flag wildcard import statements that have leading whitespace (either indentation or tab). Leading whitespace before an import is valid Java (although ugly 😅), so these lines compile but they don't get detected by the lint.

Steps to reproduce

Run the forbidWildcardImports step against:

  import java.util.*;

(2 leading spaces)

Expected

Line reported as wildcard-import lint errors.

Actual

No lint error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions