[ANN] Announcing CodeNarc 0.16

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[ANN] Announcing CodeNarc 0.16

chrismair

The CodeNarc Team is proud to announce the release of version 0.16.

CodeNarc is a static analysis tool for Groovy source code. Version 0.16 includes huge performance improvements from Hamlet and adds 13 new rules (bringing the total to 277 rules) and a bunch of bug fixes and enhancements. Try it out on the CodeNarc web console, running on Google App Engine.

New Features

·         Performance Improvements (3394481) - There are big performance improvements in this release.

·         Upgrade to GMetrics 0.4. (3424121) - This upgrade is optional for users, but may provide performance improvements.

·         Rule Index page: Rule name is now a link to the rule description web page. (3434063)

 

New and Updated Rules

·         @SuppressWarnings Support - The support for @SuppressWarnings was redesigned so that it is more reliable. @SuppressWarnings no works on *all* rules at the Class, Field, and Method level.

·         CouldBeElvis rule (convention) - Catch an if block that could be written as an elvis expression.

·         LongLiteralWithLowerCaseL rule (convention) - In Java and Groovy, you can specify long literals with the L or l character, for instance 55L or 24l. It is best practice to always use an uppercase L and never a lowercase l. This is because 11l rendered in some fonts may look like 111 instead of 11L.

·         ConfusingMultipleReturns rule (groovyism) - Multiple return values can be used to set several variables at once. To use multiple return values, the left hand side of the assignment must be enclosed in parenthesis. If not, then you are not using multiple return values, you're only assigning the last element.

·         GetterMethodCouldBeProperty rule (groovyism) - If a class defines a public method that follows the Java getter notation, and returns a constant, then it is cleaner to provide a Groovy property for the value rather than a Groovy method.

·         UnnecessaryDefInMethodDeclaration rule (unnecessary) - 3176230 - Rule now catches when you try to add the def keyword to constructor declarations. Also expanded to catch more instances of in method declarations with explicit return types.

·         UnnecessaryDefInFieldDeclaration rule (unnecessary) - If a field has a visibility modifier or a type declaration, then the def keyword is unneeded. For instance, 'static def constraints = {}' is redundant and can be simplified to 'static constraints = {}.

·         UnnecessaryDefInVariableDeclaration rule (unnecessary) - Expanded rule to catch more instances of unneeded defs.

·         UnusedMethodParameter rule (unused) - This rule finds instances of method parameters not being used. It does not analyze private methods (that is done by the UnusedPrivateMethodParameter rule) or methods marked @Override.

·         BuilderMethodWithSideEffects rule (design) - 3408045 - A builder method is defined as one that creates objects. As such, they should never be of void return type. If a method is named build, create, or make, then it should always return a value.

·         MisorderedStaticImportRule - 3392892 - The rule now allows you to specify that static imports come after the other imports, not just before.  This rule has one property comesBefore, which defaults to true. If you like your static imports to come after the others, then set this property to false.

·         FactoryMethodName rule (naming) - A factory method is a method that creates objects, and they are typically named either buildFoo(), makeFoo(), or createFoo(). This rule enforces that only one naming convention is used. It defaults to makeFoo(), but that can be changed using the property 'regex'.

·         UseCollectMany rule (groovyism) - 3411722 - In many case collectMany() yields the same result as collect{}.flatten. It is easier to understand and more clearly conveys the intent.

·         CollectAllIsDeprecated rule (groovyism) - 3411724 - collectAll is deprecated since Groovy 1.8.1. Use collectNested instead

·         UseCollectNested rule (groovyism) - 3411724 - Instead of nested collect{}-calls use collectNested{}

·         DuplicateMapLiteral (dry) - 3413600 - Check for multiple instances of the same Map literal; limited to Maps where the keys and values are all constants or literals.

·         DuplicateListLiteral (dry) - 3413601 - Check for multiple instances of the same List literal; limited to Lists where the values are all constants or literals..

 

Bug Fixes and Enhancements

·         #3393179: Fix for JUnitPublicNonTestMethod reporting violations for public non-test methods that are annotated @Override

·         #3394313: Fixed UnusedPrivateField to honor the @SuppressWarnings annotation.

·         #3397468: Fixed CyclomaticComplexity rule to honor the @SuppressWarnings annotation. 

·         #3392768: The UnnecessaryDefInVariableDeclaration no longer checks fields. That work is done in the UnnecessaryDefInFieldDeclaration rule.

·         #3401516: Fixed FinalClassWithProtectedMember to ignore methods with @Override

·         #3408106: Fixed UnnecessaryDefInMethod to ignore parameters that have the def keyword

·         #3393184: Fixed ExplicitCallToEqualsMethod to suggest a better rewrite, which works better with negation

·         #3408108: Fixed UnnecessaryDefInMethodDeclaration to not flag generic methods with a required def as an error

·         #3410261: Fixed UnusedImport - confuses import of similar class names

·         #3408440: Fixed UnnecessaryObjectReferences rule to not track references across methods.

·         #3393144: Fixed unnecessaryObjectReferences rule to not track references across fields.

·         #3394312: Fixed UnusedPrivateField rule to search for usages based on super class references.

·         #3423987: BracesFor* rules should not produce violations if there are no braces.

·         #3429658: False positive for UnusedPrivateMethod rule

·         #3387422: ClosureAsLastMethodParameter - false positive.

 

Breaking Changes***

 

HardcodedWindowsRootDirectory

The HardcodedWindowsRootDirectory rule has been renamed to HardCodedWindowsRootDirectory. (#3433741)

 

Major Reorganization of the "Basic" RuleSet

There has been a major reorganization of the "Basic" RuleSet (#3432475). This included moving several rules from the "Basic" ruleset to other rulesets, as well as adding two new rulesets:

      1. "Groovyism" – Groovy idiomatic usage, and Groovy-specific bad practices

      2. "Convention" – Coding conventions; not typically errors.

 

  The following rules were moved out of the "Basic" ruleset:

     - AddEmptyString                                     (unnecessary)

     - AssignCollectionSort                               (groovyism)

     - AssignCollectionUnique                          (groovyism)

     - BooleanMethodReturnsNull                   (design)

     - CloneableWithoutClone                          (design)

     - ClosureAsLastMethodParameter            (groovyism)

     - CollectAllIsDeprecated                           (groovyism)

     - CompareToWithoutComparable              (design)

     - ConfusingMultipleReturns                      (groovyism)

     - ConfusingTernary                                    (convention)

     - ConsecutiveLiteralAppends                    (unnecessary)

     - ConsecutiveStringConcatenation            (unnecessary)

     - CouldBeElvis                                          (convention)

     - ExplicitArrayListInstantiation                 (groovyism)

     - ExplicitCallToAndMethod                      (groovyism)

     - ExplicitCallToCompareToMethod          (groovyism)

     - ExplicitCallToDivMethod                       (groovyism)

     - ExplicitCallToEqualsMethod                  (groovyism)

     - ExplicitCallToGetAtMethod                   (groovyism)

     - ExplicitCallToLeftShiftMethod              (groovyism)

     - ExplicitCallToMinusMethod                   (groovyism)

     - ExplicitCallToModMethod                     (groovyism)

     - ExplicitCallToMultiplyMethod               (groovyism)

     - ExplicitCallToOrMethod                         (groovyism)

     - ExplicitCallToPlusMethod                      (groovyism)

     - ExplicitCallToPowerMethod                   (groovyism)

     - ExplicitCallToRightShiftMethod            (groovyism)

     - ExplicitCallToXorMethod                       (groovyism)

     - ExplicitHashMapInstantiation                 (groovyism)

     - ExplicitHashSetInstantiation                   (groovyism)

     - ExplicitLinkedHashMapInstantiation     (groovyism)

     - ExplicitLinkedListInstantiation              (groovyism)

     - ExplicitStackInstantiation                       (groovyism)

     - ExplicitTreeSetInstantiation                    (groovyism)

     - GStringAsMapKey                                  (groovyism)

     - GroovyLangImmutable                           (groovyism)

     - InvertedIfElse                                         (convention)

     - LongLiteralWithLowerCaseL                 (convention)

     - ReturnsNullInsteadOfEmptyArray         (design)

     - ReturnsNullInsteadOfEmptyCollection (design)

     - SimpleDateFormatMissingLocale           (design)

     - UseCollectMany                                      (groovyism)

     - UseCollectNested                                    (groovyism)

 

The ruleset parser classes have been modified to print a helpful error message for moved and renamed rules (see MovedRules helper class).

 

AbstractAstVisitor Method Name Changes

In a previous version, method names on AbstractAstVisitor were changed to add @SuppressWarnings support. visitField became visitFieldEx, visitProperty became visitPropertyEx, and visitConstructor became visitConstructorEx. These were changed back to the default names used by Groovy visitors.

 

Thanks

  • Thanks to the Groovy Users of Minnesota for the CouldBeElvis rule. Thanks Jeff Beck, Doug Sabers, Ryan Applegate, and Mike Minner.
  • Thanks to Joachim Baumann for UseCollectMany, CollectAllIsDeprecated, UseCollectNested.

Visit the CodeNarc Home Page

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Announcing CodeNarc 0.16

paulk_asert
Cool!

On Fri, Nov 11, 2011 at 1:12 PM, Chris Mair <[hidden email]> wrote:

> The CodeNarc Team is proud to announce the release of version 0.16.
>
> CodeNarc is a static analysis tool for Groovy source code. Version 0.16
> includes huge performance improvements from Hamlet and adds 13 new rules
> (bringing the total to 277 rules) and a bunch of bug fixes and enhancements.
> Try it out on the CodeNarc web console, running on Google App Engine.
>
> New Features
>
> ·         Performance Improvements (3394481) - There are big performance
> improvements in this release.
>
> ·         Upgrade to GMetrics 0.4. (3424121) - This upgrade is optional for
> users, but may provide performance improvements.
>
> ·         Rule Index page: Rule name is now a link to the rule description
> web page. (3434063)
>
>
>
> New and Updated Rules
>
> ·         @SuppressWarnings Support - The support for @SuppressWarnings was
> redesigned so that it is more reliable. @SuppressWarnings no works on *all*
> rules at the Class, Field, and Method level.
>
> ·         CouldBeElvis rule (convention) - Catch an if block that could be
> written as an elvis expression.
>
> ·         LongLiteralWithLowerCaseL rule (convention) - In Java and Groovy,
> you can specify long literals with the L or l character, for instance 55L or
> 24l. It is best practice to always use an uppercase L and never a lowercase
> l. This is because 11l rendered in some fonts may look like 111 instead of
> 11L.
>
> ·         ConfusingMultipleReturns rule (groovyism) - Multiple return values
> can be used to set several variables at once. To use multiple return values,
> the left hand side of the assignment must be enclosed in parenthesis. If
> not, then you are not using multiple return values, you're only assigning
> the last element.
>
> ·         GetterMethodCouldBeProperty rule (groovyism) - If a class defines
> a public method that follows the Java getter notation, and returns a
> constant, then it is cleaner to provide a Groovy property for the value
> rather than a Groovy method.
>
> ·         UnnecessaryDefInMethodDeclaration rule (unnecessary) - 3176230 -
> Rule now catches when you try to add the def keyword to constructor
> declarations. Also expanded to catch more instances of in method
> declarations with explicit return types.
>
> ·         UnnecessaryDefInFieldDeclaration rule (unnecessary) - If a field
> has a visibility modifier or a type declaration, then the def keyword is
> unneeded. For instance, 'static def constraints = {}' is redundant and can
> be simplified to 'static constraints = {}.
>
> ·         UnnecessaryDefInVariableDeclaration rule (unnecessary) - Expanded
> rule to catch more instances of unneeded defs.
>
> ·         UnusedMethodParameter rule (unused) - This rule finds instances of
> method parameters not being used. It does not analyze private methods (that
> is done by the UnusedPrivateMethodParameter rule) or methods marked
> @Override.
>
> ·         BuilderMethodWithSideEffects rule (design) - 3408045 - A builder
> method is defined as one that creates objects. As such, they should never be
> of void return type. If a method is named build, create, or make, then it
> should always return a value.
>
> ·         MisorderedStaticImportRule - 3392892 - The rule now allows you to
> specify that static imports come after the other imports, not just before.
> This rule has one property comesBefore, which defaults to true. If you like
> your static imports to come after the others, then set this property to
> false.
>
> ·         FactoryMethodName rule (naming) - A factory method is a method
> that creates objects, and they are typically named either buildFoo(),
> makeFoo(), or createFoo(). This rule enforces that only one naming
> convention is used. It defaults to makeFoo(), but that can be changed using
> the property 'regex'.
>
> ·         UseCollectMany rule (groovyism) - 3411722 - In many case
> collectMany() yields the same result as collect{}.flatten. It is easier to
> understand and more clearly conveys the intent.
>
> ·         CollectAllIsDeprecated rule (groovyism) - 3411724 - collectAll is
> deprecated since Groovy 1.8.1. Use collectNested instead
>
> ·         UseCollectNested rule (groovyism) - 3411724 - Instead of nested
> collect{}-calls use collectNested{}
>
> ·         DuplicateMapLiteral (dry) - 3413600 - Check for multiple instances
> of the same Map literal; limited to Maps where the keys and values are all
> constants or literals.
>
> ·         DuplicateListLiteral (dry) - 3413601 - Check for multiple
> instances of the same List literal; limited to Lists where the values are
> all constants or literals..
>
>
>
> Bug Fixes and Enhancements
>
> ·         #3393179: Fix for JUnitPublicNonTestMethod reporting violations
> for public non-test methods that are annotated @Override
>
> ·         #3394313: Fixed UnusedPrivateField to honor the @SuppressWarnings
> annotation.
>
> ·         #3397468: Fixed CyclomaticComplexity rule to honor the
> @SuppressWarnings annotation.
>
> ·         #3392768: The UnnecessaryDefInVariableDeclaration no longer checks
> fields. That work is done in the UnnecessaryDefInFieldDeclaration rule.
>
> ·         #3401516: Fixed FinalClassWithProtectedMember to ignore methods
> with @Override
>
> ·         #3408106: Fixed UnnecessaryDefInMethod to ignore parameters that
> have the def keyword
>
> ·         #3393184: Fixed ExplicitCallToEqualsMethod to suggest a better
> rewrite, which works better with negation
>
> ·         #3408108: Fixed UnnecessaryDefInMethodDeclaration to not flag
> generic methods with a required def as an error
>
> ·         #3410261: Fixed UnusedImport - confuses import of similar class
> names
>
> ·         #3408440: Fixed UnnecessaryObjectReferences rule to not track
> references across methods.
>
> ·         #3393144: Fixed unnecessaryObjectReferences rule to not track
> references across fields.
>
> ·         #3394312: Fixed UnusedPrivateField rule to search for usages based
> on super class references.
>
> ·         #3423987: BracesFor* rules should not produce violations if there
> are no braces.
>
> ·         #3429658: False positive for UnusedPrivateMethod rule
>
> ·         #3387422: ClosureAsLastMethodParameter - false positive.
>
>
>
> Breaking Changes***
>
>
>
> HardcodedWindowsRootDirectory
>
> The HardcodedWindowsRootDirectory rule has been renamed to
> HardCodedWindowsRootDirectory. (#3433741)
>
>
>
> Major Reorganization of the "Basic" RuleSet
>
> There has been a major reorganization of the "Basic" RuleSet (#3432475).
> This included moving several rules from the "Basic" ruleset to other
> rulesets, as well as adding two new rulesets:
>
>       1. "Groovyism" – Groovy idiomatic usage, and Groovy-specific bad
> practices
>
>       2. "Convention" – Coding conventions; not typically errors.
>
>
>
>   The following rules were moved out of the "Basic" ruleset:
>
>      - AddEmptyString                                     (unnecessary)
>
>      - AssignCollectionSort                               (groovyism)
>
>      - AssignCollectionUnique                          (groovyism)
>
>      - BooleanMethodReturnsNull                   (design)
>
>      - CloneableWithoutClone                          (design)
>
>      - ClosureAsLastMethodParameter            (groovyism)
>
>      - CollectAllIsDeprecated                           (groovyism)
>
>      - CompareToWithoutComparable              (design)
>
>      - ConfusingMultipleReturns                      (groovyism)
>
>      - ConfusingTernary                                    (convention)
>
>      - ConsecutiveLiteralAppends                    (unnecessary)
>
>      - ConsecutiveStringConcatenation            (unnecessary)
>
>      - CouldBeElvis                                          (convention)
>
>      - ExplicitArrayListInstantiation                 (groovyism)
>
>      - ExplicitCallToAndMethod                      (groovyism)
>
>      - ExplicitCallToCompareToMethod          (groovyism)
>
>      - ExplicitCallToDivMethod                       (groovyism)
>
>      - ExplicitCallToEqualsMethod                  (groovyism)
>
>      - ExplicitCallToGetAtMethod                   (groovyism)
>
>      - ExplicitCallToLeftShiftMethod              (groovyism)
>
>      - ExplicitCallToMinusMethod                   (groovyism)
>
>      - ExplicitCallToModMethod                     (groovyism)
>
>      - ExplicitCallToMultiplyMethod               (groovyism)
>
>      - ExplicitCallToOrMethod                         (groovyism)
>
>      - ExplicitCallToPlusMethod                      (groovyism)
>
>      - ExplicitCallToPowerMethod                   (groovyism)
>
>      - ExplicitCallToRightShiftMethod            (groovyism)
>
>      - ExplicitCallToXorMethod                       (groovyism)
>
>      - ExplicitHashMapInstantiation                 (groovyism)
>
>      - ExplicitHashSetInstantiation                   (groovyism)
>
>      - ExplicitLinkedHashMapInstantiation     (groovyism)
>
>      - ExplicitLinkedListInstantiation              (groovyism)
>
>      - ExplicitStackInstantiation                       (groovyism)
>
>      - ExplicitTreeSetInstantiation                    (groovyism)
>
>      - GStringAsMapKey                                  (groovyism)
>
>      - GroovyLangImmutable                           (groovyism)
>
>      - InvertedIfElse                                         (convention)
>
>      - LongLiteralWithLowerCaseL                 (convention)
>
>      - ReturnsNullInsteadOfEmptyArray         (design)
>
>      - ReturnsNullInsteadOfEmptyCollection (design)
>
>      - SimpleDateFormatMissingLocale           (design)
>
>      - UseCollectMany                                      (groovyism)
>
>      - UseCollectNested                                    (groovyism)
>
>
>
> The ruleset parser classes have been modified to print a helpful error
> message for moved and renamed rules (see MovedRules helper class).
>
>
>
> AbstractAstVisitor Method Name Changes
>
> In a previous version, method names on AbstractAstVisitor were changed to
> add @SuppressWarnings support. visitField became visitFieldEx, visitProperty
> became visitPropertyEx, and visitConstructor became visitConstructorEx.
> These were changed back to the default names used by Groovy visitors.
>
>
>
> Thanks
>
> Thanks to the Groovy Users of Minnesota for the CouldBeElvis rule. Thanks
> Jeff Beck, Doug Sabers, Ryan Applegate, and Mike Minner.
> Thanks to Joachim Baumann for UseCollectMany, CollectAllIsDeprecated,
> UseCollectNested.
>
> Visit the CodeNarc Home Page

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email