Download Latest Version CodeNarc-1.0.jar (4.3 MB) Get Updates
Home / codenarc / CodeNarc Version 0.15
Name Modified Size InfoDownloads / Week
Parent folder
CodeNarc-0.15-bin.zip 2011-08-04 8.8 MB
README.txt 2011-08-04 8.2 kB
CodeNarc-0.15-bin.tar.gz 2011-08-04 6.1 MB
Totals: 3 Items   14.9 MB 0
CodeNarc ------------------------------------------------------------------------------- http://www.codenarc.org Changes in version 0.15 (August 2011) ------------------------------------------- NEW AND UPDATED RULES - UnnecessaryDefInVariableDeclaration rule (unnecessary) - If a variable has a visibility modifier or a type declaration, then the def keyword is unneeded. For instance 'def private n = 2' is redundant and can be simplified to 'private n = 2'. - UnnecessaryDefInMethodDeclaration rule (unnecessary) - Added more checked modifiers: final, synchronized, abstract, strictfp. Multiple method declarations in a single line are handled correctly. - AssignCollectionUnique rule (basic) - The Collections.unique() method mutates the list and returns the list as a value. If you are assigning the result of unique() to a variable, then you probably don't realize that you're also modifying the original list as well. This is frequently the cause of subtle bugs. - AssignCollectionSort rule (basic) - The Collections.sort() method mutates the list and returns the list as a value. If you are assigning the result of sort() to a variable, then you probably don't realize that you're also modifying the original list as well. This is frequently the cause of subtle bugs. - UnnecessaryDotClass rule (unnecessary) - To make a reference to a class, it is unnecessary to specify the '.class' identifier. For instance String.class can be shortened to String. - BitwiseOperatorInConditional rule (basic) - Checks for bitwise operations in conditionals, if you need to do a bitwise operation then it is best practive to extract a temp variable. - UnnecessaryInstanceOfCheck rule (unnecessary) - This rule finds instanceof checks that cannot possibly evaluate to true. For instance, checking that (!variable instanceof String) will never be true because the result of a not expression is always a boolean. - UnnecessarySubstring rule (unnecessary) - This rule finds usages of String.substring(int) and String.substring(int, int) that can be replaced by use of the subscript operator. For instance, var.substring(5) can be replaced with var[5..-1]. - HardcodedWindowsRootDirectory rule (basic) - This rule find cases where a File object is constructed with a windows-based path. This is not portable, and using the File.listRoots() method is a better alternative. - HardCodedWindowsFileSeparator rule (basic) - This rule finds usages of a Windows file separator within the constructor call of a File object. It is better to use the Unix file separator or use the File.separator constant. - RandomDoubleCoercedToZero rule (basic) - The Math.random() method returns a double result greater than or equal to 0.0 and less than 1.0. If you coerce this result into an Integer or int, then it is coerced to zero. Casting the result to int, or assigning it to an int field is probably a bug. - BracesForClass rule (formatting) - Checks the location of the opening brace ({) for classes. By default, requires them on the same line, but the sameLine property can be set to false to override this. - LineLength rule (formatting) - Checks the maximum length for each line of source code. It checks for number of characters, so lines that include tabs may appear longer than the allowed number when viewing the file. The maximum line length can be configured by setting the length property, which defaults to 120. - GrailsDomainHasToString rule (grails) - Checks that Grails domain classes redefine toString() - GrailsDomainHasEquals rule (grails) - Checks that Grails domain classes redefine equals(). - BracesForForLoop rule (formatting) - Checks the location of the opening brace ({) for for loops. By default, requires them on the same line, but the sameLine property can be set to false to override this. - BracesForIfElse rule (formatting) - Checks the location of the opening brace ({) for if statements. By default, requires them on the same line, but the sameLine property can be set to false to override this. - BracesForMethod rule (formatting) - Checks the location of the opening brace ({) for constructors and methods. By default, requires them on the same line, but the sameLine property can be set to false to override this. - BracesForTryCatchFinally rule (formatting) - Checks the location of the opening brace ({) for try statements. By default, requires them on the line, but the sameLine property can be set to false to override this. - ClassJavadoc rule (formatting) - Makes sure each class and interface definition is preceded by javadoc. Enum definitions are not checked, due to strange behavior in the Groovy AST. - JdbcConnectionReference rule (jdbc) - Check for direct use of java.sql.Connection, which is discouraged and almost never necessary in application code. - JdbcResultSetReference rule (jdbc) - Check for direct use of java.sql.ResultSet, which is not necessary if using the Groovy Sql facility or an ORM framework such as Hibernate. - JdbcStatementReference rule (jdbc) - Check for direct use of java.sql.Statement, java.sql.PreparedStatement, or java.sql.CallableStatement, which is not necessary if using the Groovy Sql facility or an ORM framework such as Hibernate. - IllegalClassReference rule (generic) - Checks for reference to any of the classes configured in classNames. BUG FIXES and NEW FEATURES - #3325147: Fix for running CodeNarc with a Groovy 1.8 runtime. There should no longer be StackOverflowExceptions. - #3317632: CloneableWithoutClone - false positive. - #3315990: StaticXxxField false positive on initializer: StaticSimpleDateFormatField, StaticDateFormatField, StaticCalendarField. - #3314773: UnnecessaryGroovyImportRule: false positive on static imports - #3315992: ClosureAsLastMethodParameter - false positive, when method call surrounded by parentheses. - #3307699: Fixed a typo and made some "Violation" strings lowercase, so the log messages are consistent. (Fixed by René Scheibe) - #3315946: Cmdline runner does not respect -includes and -excludes. (Fixed by René Scheibe) - #3314576: UnnecessaryPublicModifierRule: MissingPropertyException. (Fixed by René Scheibe) - #3322395: JUnitTestMethodWithoutAssert - Added support for parameters in the @Test annotation. E.g.: @Test(expected = IllegalArgumentException) and @Test(timeout = 1000). (Fixed by René Scheibe) - #3310381: Added test for all rules (in AbstractRuleTestCase) to verify that any values specified for (doNot)applyToFilesMatching are valid regular expressions. - #3325049: Change StatelessClassRule (generic) to require applyToClassNames, applyToFileNames or applyToFilesMatching to be configured. - #3361263: IllegalPackageReferenceRule: Also check constructor parameter types and type coercion (x as Type). - #3315991: Unnecessary*Instantiation (including UnnecessaryBigDecimalInstantiation): Duplicate violations. - #3351964: Include rules w/ priority > 4 in HTML report. Add getViolations() to Results interface. - #3375718: UnusedPrivateField: Recognize references to static fields through the class name. - #3380494: Automatically create report output folders. - #3376518: UnnecessaryBigDecimalInstantiation should not produce violations for new BigDecimal(42), new BigDecimal(42L) or new BigDecimal("42") - i.e., when the parameter evaluates to an integer/long. - #3376576: UnnecessaryParenthesesForMethodCallWithClosureRule: IllegalArgumentException: Start and end indexes are one based and have to be greater than zero. - #3384056: Unnecessary* rules should be priority 3. THANKS - Thanks to René Scheibe for the UnnecessaryDefInVariableDeclarationRule and enhancements to UnnecessaryDefInMethodDeclarationRule; as well as the many bug fixes. - Thanks to Dean Del Ponte for the UnnecessaryDotClass rule. - Thanks to Nick Larson, Juan Vazquez, and Jon DeJong for the AssignCollectionUnique rule. - Thanks to Jeff Beck for the BitwiseOperatorInConditional rule. - Thanks to Geli Crick and Rafael Luque for the BracesForClass, LineLength, GrailsDomainHasToString,GrailsDomainHasEquals, BracesForIfElseRule, BracesForMethod, BracesForTryCatchFinally and ClassJavadoc rules.
Source: README.txt, updated 2011-08-04