#179 AvoidStarImport with excludes

release_3.2
closed
Check (274)
5
2012-10-10
2003-05-28
No

AvoidStarImport should allow for certain packages to be
excluded, to implement a policy like "allow star import
only for java.util.*"

I implemented this in my company's set of checkstyle
extensions and will attach my code for
com.vecna.checkstyle.AvoidStarImportCheck.

Discussion

  • Bill Schneider

    Bill Schneider - 2003-05-28

    code for com.vecna.checkstyle.AvoidStarImportCheck

     
  • Lars Kühne

    Lars Kühne - 2003-06-02

    Logged In: YES
    user_id=401384

    Thanks, a RFE with patch included is much appreciated.

    Basically this looks good, but
    "name.getText().startsWith(m_excludes[i])" is incorrect.

    It might fire for unrelated packages that start with the
    same prefix, e.g. if the exclude list contains
    "java.lang.ref" the check will not report "import
    java.lang.reflect.*"

    Oh, and if you could contribute some unit tests for your new
    feature it would be just wonderful :-)

     
  • Bill Schneider

    Bill Schneider - 2003-06-10

    Logged In: YES
    user_id=768885

    added patch to AvoidStarImport check, plus a patch to the
    unit test. The unit test passed.

     
  • Lars Kühne

    Lars Kühne - 2003-06-23

    Logged In: YES
    user_id=401384

    incorporated to CVS, will be available in release 3.2

     

Log in to post a comment.