Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-18089

The source code must obey the avoid star import checkstyle rule

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Normal
    • Resolution: Duplicate
    • 5.x
    • Build
    • None
    • Code Clarity
    • Normal
    • All
    • None
    • Hide

      The documentation must be updated once an agreement on this issue will be reached.

      To test do the following:

      $ git fetch upstream pull/2041/head:cassandra-18089
      $ ant checkstyle
      $ ant checkstyle-test
      
      Show
      The documentation must be updated once an agreement on this issue will be reached. To test do the following: $ git fetch upstream pull/2041/head:cassandra-18089 $ ant checkstyle $ ant checkstyle-test

    Description

      Cassandra has the code style rules regarding the classes import order: https://cassandra.apache.org/_/development/code_style.html

      Importing all classes from a package or static members from a class leads to tight coupling between packages or classes and might lead to problems when a new library version introduces name clashes. The advantage of explicitly listing all imports from a package is that you can tell at a glance which class you meant to use, which does reading and refactoring the source code that much easier.

      The checkstyle that is already used for checking the source code has a such check and this check may be added to the config both for the production and test source code:
      https://checkstyle.sourceforge.io/config_imports.html#AvoidStaticImport

      Besides adding a new checkstyle rule it may be more convenient for those community members that are working with the code to reflect the same rule in the IDE's inspection profiles (if it's possible), thus using the 'optimize imports' will produce the same results on each execution as the checkstyle does.

      Summary:

      • add new checkstyle rule;
      • update IDE's appropriate built-in inspections configurations;
      • update development code-style web page and wiki;

      Attachments

        Issue Links

          Activity

            People

              mmuzaf Maxim Muzafarov
              mmuzaf Maxim Muzafarov
              Maxim Muzafarov
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m