CodeNarc v0.12 - Source Code Analysis for Groovy
Join the DZone community and get the full member experience.Join For Free
The CodeNarc Team is proud to announce the release of version 0.12.
CodeNarc is a static analysis tool for Groovy source code. Version 0.12 adds 36 new rules to the product (bringing the total to 160+ rules). Try it out on the CodeNarc web console, running on Google App Engine.
- Improved performance of the CodeNarc Ant Task (by multi-threading source code analysis) - Feature #3150044
- Add support for message parameter substitution in Rule descriptions - Feature #3133988
- CompareToWithoutComparable rule (basic) - Adds violation if you implement a compare method without implementing the Comparable interface
- ExplicitGarbageCollection rule (basic) - Feature #3106689 - Adds a violation if you try to manually trigger a garbage collection run
- ConfusingTernary rule (basic) - Feature #3158945 - Adds violation if you use unnecessary negation within a ternary expression
- SimpleDateFormatMissingLocale rule (basic) - Feature #3160227 - Adds a violation if SimpleDateFormat is used without a Locale.
- AbstractClassWithoutAbstractMethod rule (design) - Feature #3160204 - Adds a violation when an abstract class does not contain any abstract methods
- CloseWithoutCloseable rule (design) - Feature #3138445 - Adds a violation if you implement a close method without imlpementing the Closeable interface
- FinalClassWithProtectedMember rule (design) - Feature #3137650 - Adds violation if you have a protected member in a final class
- ConstantsOnlyInterface rule (design) - Feature #3159134 - Adds violation if an interface contains constants but no methods
- EmptyMethodInAbstractClass rule (design) - Feature #3159180 - Adds violation if an abstract class contains an empty method
- CatchArrayIndexOutOfBoundsException rule (exceptions) - Feature #3122979 - Adds violation if you explicitly catch ArrayIndexOutOfBoundsException
- CatchIndexOutOfBoundsException rule (exceptions) - Feature #3122979 - Adds violation if you explicitly catch IndexOutOfBoundsException
- MissingNewInThrowStatement (exceptions) - Feature #3140762 -Adds a violation if a throw statement is used to throw a class literal
- RequiredString rule (generic) - Feature #3122980 - Adds violation if a user-defined String is not found. For example, a copyright notice may be required.
- UseAssertFalseInsteadOfNegation rule (junit) - Feature #3114728 - Adds violation if JUnit's assertEquals is used with the boolean literal 'false'
- UseAssertTrueInsteadOfNegation rule (junit) - Feature #3114728 - Adds violation if JUnit's assertEquals is used with the boolean literal 'true'
- JUnitTestMethodWithoutAssert. rule (junit) - Feature #3111443 - Adds violation if a JUnit test method contains no assert statements
- LoggerForDifferentClass rule (logging) - Feature #3114736 - Adds violation if a Logger is created based on a Class that is not the enclosing class
- LoggerWithWrongModifiers rule (logging) - Adds violation if a Logger is not private, final, and static.
- LoggingSwallowsStacktrace rule (logging) - Adds violation if a log statement logs an exception without the accompanying stack trace
- MultipleLoggers rule (logging) - Adds a violation if a class declares more than one logger field
- UnnecessaryBigDecimalInstantiation rule (unnecessary) - Adds a violation for explicit instantiation of BigDecimal
- UnnecessaryBigIntegerInstantiation rule (unnecessary) - Adds a violation for explicit instantiation of BigInteger
- UnnecessaryCatchBlock rule (unnecessary) - Feature #3107168 - Adds violation if catch block does nothing but throw original exception
- UnnecessaryDoubleInstantiation rule (unnecessary) - Adds a violation for explicit instantiation of Double
- UnnecessaryFloatInstantiation rule (unnecessary) - Adds a violation for explicit instantiation of Float
- UnnecessaryInstantiationToGetClass (unnecessary) - Feature #3158935 - Adds a violation if a new instance is created in order to invoke getClass()
- UnnecessaryIntegerInstantiation rule (unnecessary) - Adds a violation for explicit instantiation of Integer
- UnnecessaryLongInstantiation rule (unnecessary) - Adds a violation for explicit instantiation of Long
- UnnecessaryNullCheck Rule (unnecessary) - Feature #3160184 - Adds violation when a null-safe dereference can be used instead of an explicit null check
- UnnecessaryNullCheckBeforeInstanceOf rule (unnecessary) - Feature #3159274 - Adds a violation for an unnecessary null check before using the instanceof operator
- UnnecessaryObjectReferences rule (unnecessary) - Feature #3107838 - Adds a violation for a chain of setters being invoked, which can be converted into a with or identity block
- UnnecessaryCallForLastElement rule (unnecessary) - Feature #3107884 - Adds violation if accessing the last element of a list without using the .last() method or -1th index
- UnnecessaryCollectCall rule (unnecessary) - Feature #3110317 - Adds a violation if a collect method call can be replaced with the spread operator
- UnnecessaryCatchBlock rule (unnecessary)- Feature #3110318 - Adds a violation if a catch block does nothing but throw the original exception
- UnnecessaryGetter rule (unnecessary)- Feature #3110321 - Adds a violation if a a getter method is called explicitly instead of using property syntax
- UnusedPrivateMethodParameter rule (unused) - Feature #3151598 - Adds a violation if the parameter to a private method is never used within that method
- Fix Bug #3127967 DuplicateImportRule: Fix for Groovy 1.7. Resort to parsing source code.
- Fix Bug #3146678: UnnecessaryGetter false positive, e.g. def allPaths = resultsMap.keySet() keySet() can probably be rewritten as set.
- Fix Bug #3111189: "StatelessClassRule - Honor @Immutable".
- Fix Bug #3111181: "UnnecessaryIfStatement - misses if without explicit return".
- Fix Bug #3108126: "assertNoViolations still passes when compile fails"
- Fix Bug #3111439: "Synchronized on getClass() rule gives double warnings".
- Fix Bug #3111438: "Lines with annotations have the wrong source line".
- Fix Bug #3109909: DuplicateStringLiteralRule: Add "" as default ignoreStringLiteral.
- Fix Bug #3110308: "Rules to catch null returns ignore ternary expressions".
- Fix Bug #3110303: "ExplicitCallToXMethod rules should ignore spread statements".
- Fix Bug #3109917: "DuplicateStringLiteralRule - enum names".
- Fix Bug #3109628: "Exceptions are thrown with CodeNarc v0.11" – "GString as map key checking classes that do not exist yet” and “unnecessary ctor rule breaks for anonymous classes".
- Moved the existing StringInstantiation and BooleanInstantiation rules from the Basic ruleset into the Unnecessary ruleset.Also renamed the rules to UnnecessaryStringInstantiationRule and UnnecessaryBooleanInstantiation.Likewise, the rule classes were moved from the org.codenarc.rule.basic package into org.codenarc.rule.unnecessary.NOTE: This should only affect users if
- You configured one of these rules specifically by rule name or by class name within a custom ruleset
- You configured one of these rules (by rule name) within "codenarc.properties"
- You configured one of these rules (by rule name) within a @SuppressWarnings annotation
- You configured one of these rules (by rule name) within "codenarc-message.properties".
- Removed deprecated applyToFilenames and doNotApplyToFilenames properties of AbstractRule.
- UnnecessaryIfStatementRule: Expand the rule to also catch if/else statements that contain only single constant/literal expressions for the if and/or else blocks, if the if is not the last statement in the block.
- Feature #3108153: Expand ReturnNull* rules to catch elvis operators
- Feature #3111442: "add better error messages to the ReturnsNull*Rules"
- Feature #3111440: "added better violation messages to BigDecimalInstantiationRule, BooleanInstantiationRule, and StringInstantiationRule".
- Add isValid() to SourceCode (and AbstractSourceCode).
Vote for IDEA Support for CodeNarc
Visit the CodeNarc Home Page
Groovy (programming language)
Opinions expressed by DZone contributors are their own.
Operator Overloading in Java
Building a Flask Web Application With Docker: A Step-by-Step Guide
Scaling Site Reliability Engineering (SRE) Teams the Right Way
Database Integration Tests With Spring Boot and Testcontainers