Skip to content

apply convention over configuration principle to prevent wildcard imports #45898

@Pankraz76

Description

@Pankraz76

Adhering to Quarkus Guidelines: Avoid Wildcard Imports

To adhere to the Quarkus performance approach and avoid wildcard imports under any circumstances (to enable pre-optimization), the guidelines suggest setting the import count to 999. This ensures that wildcard imports are not introduced, thereby improving maintainability and adhering to best practices.

Steps to Disable Wildcard Imports

Referencing the official Quarkus Contributing Guide, follow these steps to disable wildcard imports:

  1. Navigate to Editor → Code Style → Java → Imports.
  2. Set Class count to use import with '*' to 999.
  3. Set Names count to use static import with '*' to 999.

Automating Best Practices

Considering the suggestion by @rhusar, we can leverage .editorconfig to eliminate the need for manual configuration. This aligns with the "convention over configuration" principle commonly adopted by frameworks. Automating this ensures developers follow best practices right from the start.

Blocking Wildcard Imports via PR

The proposed Pull Request #45372 aims to introduce a blockage of any wildcard imports. This further enforces the standard and helps maintain consistent, optimized coding practices across the Quarkus codebase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/housekeepingIssue type for generalized tasks not related to bugs or enhancements

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions