CodeNarc
-------------------------------------------------------------------------------
http://www.codenarc.org
Changes in version 0.18.1 (Feb 2013)
-------------------------------------------
BUG FIXES
- Fix #3596256: SpaceAroundOperatorRule: False positive if source line contains unicode chars.
Also affects (known limitation): SpaceAfterClosingBrace, SpaceBeforeOpeningBrace, SpaceBeforeClosingBrace - Known limitation: will not catch violations on same line following unicode char literal.
- Fix #3598154: SpaceAroundOperator: bad/duplicate violation for ?: after closure. Ignore standalone elvis expression statements (known limitation).
- Fix #3598717: BracesForClassRule failing on annotation types. (Known limitation: ignore for @interface). Thanks to Marcin Gryszko.
- Fix #3598732: BracesForMethodRule fixed for methods with closure parameters. Thanks to Marcin Gryszko.
- Fix #3596323: BracesForClassRule ignored for enums and Groovy 1.7. Thanks to Marcin Gryszko.
- Fix for CodeNarc GitHub issue #10: No such property: maxMethodComplexity for class: org.codenarc.rule.size.AbcMetricRule.
- Fix #3604095: AssignCollectionSort ignore calls that pass in mutate=false; add checks for two-arg calls.
- Fix #3603257: UnusedVariable reported for variable used in (more than one) for loop.
Changes in version 0.18 (Dec 2012 )
-------------------------------------------
NEW RULES
- #3531554: New JUnitLostTest rule. Checks for classes that import JUnit 4 classes and contain a public, instance, void, no-arg method named test* that is not annotated with @Test.
- #3509530: New SpaceAfterComma rule. Checks that there is at least one space or whitespace following each comma. That includes checks for method and closure declaration parameter lists, method call parameter lists, Map literals and List literals.
- #3583257: New SpaceAfterSemicolon rule. Checks that there is at least one space or whitespace following a semicolon that separates classic for loop clauses and also multiple statements per line.
- #3509532: New SpaceAroundOperator rule. Check that there is at least one space (blank) or whitespace around each binary operator, including: +, -, *, /, >>, <<, &&, ||, &, |, ?:, =.
- #3583262: New SpaceBeforeOpeningBrace rule. Check that there is at least one space (blank) or whitespace before each opening brace ("{"). This checks method/class/interface declarations, closure expressions and block statements.
- #3583262: New SpaceAfterOpeningBrace rule. Check that there is at least one space (blank) or whitespace after each opening brace ("{"). This checks method/class/interface declarations, closure expressions and block statements.
- #3583262: New SpaceAfterClosingBrace rule. Check that there is at least one space (blank) or whitespace after each closing brace ("}"). This checks method/class/interface declarations, closure expressions and block statements.
- #3583262: New SpaceBeforeClosingBrace rule. Check that there is at least one space (blank) or whitespace before each closing brace ("}"). This checks method/class/interface declarations, closure expressions and block statements.
- #3589701: New SpaceAfterIf rule. Check that there is exactly one space (blank) after the if keyword and before the opening parenthesis.
- #3589701: New SpaceAfterWhile rule. Check that there is exactly one space (blank) after the while keyword and before the opening parenthesis.
- #3589701: New SpaceAfterFor rule. Check that there is exactly one space (blank) after the for keyword and before the opening parenthesis.
- #3589701: New SpaceAfterSwitch rule. Check that there is exactly one space (blank) after the switch keyword and before the opening parenthesis.
- #3589701: New SpaceAfterCatch rule. Check that there is exactly one space (blank) after the catch keyword and before the opening parenthesis.
- #3581377: New JUnitUnnecessaryThrowsException rule. Check for throws clauses on JUnit test methods. That is not necessary in Groovy.
- #3575859: New GrailsDuplicateMapping rule. Check for duplicate entry in a domain class mapping.
- #3575861: New GrailsDuplicateConstraint rule. Check for duplicate constraints entry
- #3592678: New IfStatementCouldBeTernary rule - Checks for if statements where both the if and else blocks contain only a single return statement with a value
- #3581378: New ExceptionNotThrown rule - Checks for an exception constructor call without a throw as the last statement within a catch block.
UPDATED/ENHANCED RULES
- Pull request #2: Adding support for catch, finally, and else brace placement validation. Thanks to Matias Bjarland.
- #3521130: PrintStackTrace: Also check for StackTraceUtils.printSanitizedStackTrace().
- #3589971: Add threshold for max class metric value for CyclomaticComplexity, AbcMetric and CrapMetric.
- #3574257: Rename AbcComplexity rule to AbcMetric. Deprecate old AbcComplexity rule and set enabled=false. Rename properties, e.g. maxMethodAbcScore.
- Pull request #5: Enhanced UnusedVariableRule to enable ignoring some variables (ignoreVariableNames). Thanks to René Scheibe.
BUG FIXES
- Fix #3555096: UnusedPrivateMethod - StringIndexOutOfBoundsException for zero-length method name.
- Fix #3524882: False positive UnnecessaryPackageReference violation for Enums.
- Fix #3558623: UnnecessarySemicolon - violations inside classes were ignored. Thanks to Marcin Erdmann.
- Fix #3574259: CyclomaticComplexity, CrapMetric and AbcComplexity: Do not check class-level metric value if maxClassAverageMethodXX value is null or 0.
- Fix #3526749: The FieldName rule should ignore serialVersionUID fields by default.
- Fix #3543848: Online docs; formatting on Naming rules doc.
- Fix #3441842: Online docs; UnnecessarySubstring documentation is misleading.
- Fix #3511004: PrivateFieldCouldBeFinal false positive (-- and ++ operators).
- Fix Pull request #4: parseReport doesn't work with absolute paths on windows. Thanks to Gavin Matthews.
FRAMEWORK AND INFRASTRUCTURE
- #3546737: Migrate source code from Subversion to GitHub. Many thanks to Marcin Erdmann.
- #3578372: Add notes to rule index and sample rule sets that ABC/CC rules require the GMetrics jar.
- #3578909: Move helper methods from AbstractTestCase into new TestUtil class (to enable use by other test frameworks, e.g. Spock)
- #3578909: Upgrade tests and test framework to JUnit 4.
- #3578909: Move test framework classes into src/main/groovy, so that they are included in the CodeNarc jar:
AbstractTestCase, InMemoryAppender, TestUtil, AbstractRuleTestCase, StubRule
- Switch to Sonatype OSS Maven Repository
Changes in version 0.17 (March 2012)
-------------------------------------------
NEW RULES
- #3433042: New PrivateFieldCouldBeFinal rule: Checks for private fields that are only set within a constructor or field initializer. Such fields can safely be made final.
- #3432991: New ParameterReassignment rule: Checks for a method or closure parameter being reassigned to a new value within the body of the method/closure, which is a confusing, bad practice. Use a temporary variable instead.
- #3108331: New TernaryCouldBeElvis rule: Checks for ternary with boolean and true expressions are the same; can be simplified to an Elvis expression.
- #3489801: New AssertWithinFinallyBlock rule: Checks for assert statements within a finally block. An assert can throw an exception, hiding the original exception, if there is one.
- #3489800: New ConstantAssertExpression rule: Checks for assert statements where the assert condition expressions is a constant value or literal value.
- #3161693: New BrokenNullCheck rule: Looks for faulty checks for null that can cause a NullPointerException.
- #3495466: New VectorIsObsolete rule: Checks for references to the (effectively) obsolete java.util.Vector class. Use the Java Collections Framework classes instead including ArrayList or Collections.synchronizedList().
- #3495466: New HashtableIsObsolete rule: Checks for references to the (effectively) obsolete java.util.Hashtable class. Use the Java Collections Framework classes instead including HashMap or ConcurrentHashMap.
- #3485545: New CrapMetric rule: Checks the CRAP metric score for methods. This metric is based on the cyclomatic complexity and test coverage for individual methods. Requires a Cobertura XML coverage file and GMetrics 0.5.
UPDATED/ENHANCED RULES
- #3476844: Extend GetterMethodCouldBeProperty to also check static getter methods.
- #3477351: UnnecessaryConstructor: Also catch constructor containing only call to super().
- #3460463: StatelessClassRule and GrailsStatelessServiceRule: Ignore fields annotated with @Inject.
- #3460463: GrailsStatelessServiceRule: Ignore non-static properties (i.e., no visibility modifier specified) declared with "def".
- #3485544: AssignmentInConditional: Also catch nested binary expressions, e.g. if (x==1 || x=3)
- #3488705: GrailsDomainHasToString: Ignore classes annotated with @ToString or @Canonical.
- #3488704: GrailsDomainHasEquals: Ignore classes annotated with @EqualsAndHashCode or @Canonical.
- #3501349: UnnecessaryPackageReference: Also check for explicitly-imported classes.
- #3509542: UnnecessaryPackageReference: Also check for package references in "as <Class>".
BUG FIXES
- #3463408: Remove dependency on Java 1.6 (String.isEmpty()).
- #3475170: Fix duplicate violations for SimpleDateFormatMissingLocale.
- #3477085. Fix UnusedImport violations missing line numbers for imports with semicolons.
- #3477162: Fix duplicate violations for UnnecessaryDotClass.
- #3487448: Fix UnnecessaryNullCheckBeforeInstanceOf should also check standalone binary (boolean) expressions, e.g. boolean ready = x != null && x instanceof Integer
- #3496557: Fix UseCollectNestedRule: GroovyCastException: Cannot cast object VariableExpression to class ClosureExpression
- #3496696: Fix UnusedPrivateFieldRule: GroovyCastException: Cannot cast object with class 'org.codehaus.groovy.ast.FieldNode' to class 'groovy.lang.MetaClass'.
FRAMEWORK AND INFRASTRUCTURE
- #3495841: Support Groovy 2.x.
- #3496463: Support GMetrics 0.5.
- #3476394: Include PMD report in project reports; Fix/resolve violations.
- Introduce AbstractSharedAstVisitorRule. Refactor UnusedPrivateFieldRule and UnusedPrivateMethodRule to use it.
- Add exists() method to org.codenarc.util.io.Resource and implementations