CodeNarc Change Log
-------------------------------------------------------------------------------
http://www.codenarc.org

Changes in version 0.9 (10 May 2010)
------------------------------------
BUG FIXES
- Fix bug #2985592: MissingPropertyException: No such property: W3C_XML_SCHEMA_NS_URI.
- XML RuleSet: Allow wildcards (*) in <include> and <exclude>.
- WildcardPattern: Escape plus sign ('+').
- NestedBlockDepthRule: Ignore first level of closure for Closure Fields (since they are really equivalent to methods).
NEW SIZE/COMPLEXITY RULES
- AbcComplexityRule - Check ABC size/complexity score against threshold for method and class average (size)
- CyclomaticComplexityRule - Check Cyclomatic Complexity against threshold for method and class average (size)
NEW CONCURRENCY RULES
- NestedSynchronizationRule (concurrency - Hamlet DArcy)
- RunFinalizersOnExitRule (concurrency - Hamlet DArcy)
- SynchronizedMethodRule (concurrency - Hamlet DArcy) 
- SynchronizedOnThisRule (concurrency - Hamlet DArcy)
- ThreadLocalNotStaticFinalRule (concurrency - Hamlet DArcy)
- ThreadYieldRule: (concurrency - Hamlet DArcy)
- VolatileLongOrDoubleFieldRule: (concurrency - Hamlet DArcy)
NEW BASIC RULES
- CloneableWithoutCloneRule (basic - Hamlet D'Arcy & Ren Grschke)
- ConstantIfExpressionRule: if(true) or if(false). Or literal constant. (basic)
- ConstantTernaryExpressionRule: true ? x : y or false, null or literal.(basic)
- UnnecessaryTernaryExpressionRule: x ? true : false. Or Boolean.TRUE. Or where both expressions are the same. (basic)
OTHER CHANGES
- Deprecate GrailsSessionReferenceRule. Default enabled to false. Note in online docs.
- StatelessClassRule: Add setAddToIgnoreFieldNames() method (adds to ignoreFieldNames).
- Add new <rule>.description.html property for each rule. Change the HtmlReportWriter to look for *.description.html first; if not defined, use *.description. Continue to use *.description in XML report. Potential BREAKAGE: If you have overridden the <rule>.description message for a predefined rule in a codenarc-messages.properties file, you will have to change those message keys to <rule>.description.html.
- Do not include disabled rules in list of rules at bottom of HTML/XML report.
- HtmlReportWriter: Dont log warning if "codenarc-messages.properties" contains *.description but not *.description.html.
- UnusedVariableRule: Fix limitation: Does not recognize variable references on the same line as the variable declaration.
- GroovyDslRuleSet: Throw MissingPropertyException if a non-existent property is set within a Groovy RuleSet DSL.
- CodeNarcRunner: Add System.out println of summary counts.
- MethodSizeRule: Apply to constructors as well.
- WildcardPattern: Trim pattern values. This includes property values such as common rule properties applyToFileNames/doNotApplyToFileNames, applyToClassNames/doNotApplyToClassNames. Or many rule-specific properties such as ignoreMethodNames for the MethodSizeRule.
- PropertiesFileRuleSetConfigurer: Log warning if rule name not found.
- TESTS: AbstractRuleTestCase: Add assertViolations(String source, Map[] violationMaps) helper method.
- TESTS: Fix tests broken on Linux.


Changes in version 0.8.1 (2 Feb 2010)
------------------------------------
BUG FIXES
- Fix Bug #2943025: NestedBlockDepthRule: Produces erroneous results on Groovy 1.6.x. https://sourceforge.net/tracker/?func=detail&aid=2943025&group_id=250145&atid=1126573
- Fix Bug #2943028: PackageNameRule may show incorrect violations for classes within the default package when running in Groovy 1.6.x. https://sourceforge.net/tracker/?func=detail&aid=2943028&group_id=250145&atid=1126573
- Fix Bug #2935587 "Building CodeNarc 0.8 fails." - Problem from Joern Huxhorn (Jan 18, 2010)  Unable to build from the downloaded CodeNarc-0.8-bin.tar.gz.  http://sourceforge.net/tracker/?func=detail&aid=2935587&group_id=250145&atid=1126573. See CodeNarc - Unable to Build From TarGZip.doc. Remove platform/locale dependencies: AbstractReportWriterTest, UrlResourceTest, GrailsSessionReferenceRuleTest, GrailsPublicControllerMethodRuleTest, GrailsServletContextReferenceRuleTest, GrailsStatelessServiceRuleTest. [Jan 24]
- Fix StackOverflow in Groovy 1.7.0 for some rules: All rules that implement the visitVariableExpression(VariableExpression expression) visitor method: UnusedVariableRule, UnusedPrivateFieldRule, GrailsSessionReferenceRule, GrailsServletContextReferenceRule  Removed call to super.visitVariableExpression(expression) since that seems to cause problems (StackOverflow) in Groovy 1.7.0.
- Fix tests broken when running in Groovy 1.6 or Groovy 1.7.
- DuplicateImportRule: Document that this rule does not work when running under Groovy 1.7 (i.e., will not produce any violations), and does not distinguish between multiple duplicate imports for the same class.


Changes in version 0.8 (17 Jan 2010)
------------------------------------
BUG FIXES
- Fix Bug #2930886: "Cannot load rules when groovy is in different classloader".  XmlReaderRuleSet, ReportWriterFactory: Replace calls to Class.forName() with getClass().classLoader.loadClass(). https://sourceforge.net/tracker/?func=detail&atid=1126573&aid=2930886&group_id=250145.
- Fix Bug #2847520: "UnusedVariableRule: Closure variable must be invoked". UnusedVariableRule: Referencing an (explicit) Closure variable without invoking it is not recognized as a valid reference. e.g., final CLOSURE = { .. }; return CLOSURE. https://sourceforge.net/tracker/?func=detail&aid=2847520&group_id=250145&atid=1126573
- Fix false positive: Local closures: If a closure is assigned to a local variable, then used later in the method, CodeNarc report the variable unused. [I think this has already been resolved, perhaps as part of Bug #2847520]. (reported by Donal Murtagh)
- Fix false positive: Default arguments: If a constant is only used as the value of a default argument, CodeNarc reports this constant unused. (reported by Donal Murtagh)
REPORTS
- Create XmlReportWriter for wrting out an XML report ("xml"). (beta)
- Create TextReportWriter. Writes out text report with violations by file and priority and summary counts.
- Enable configuring all provided ReportWriters (HtmlReportWriter, XmlReportWriter, TextReportWriter) to write to the stdout (console).
- Enable specifying the full class name of a custom ReportWriter class.
- CodeNarcTask: Add support for <option> nested elements under the <report> element.
- HtmlReportWriter: Externalize strings to resource bundle.
- Remove setTitle() and setOutputFile() from ReportWriter interface.
- ReportWriter: Rename writeOutReport() method to writeReport().
- Create AbstractReportWriter.
RULES
- Create new NestedBlockDepthRule. Checks for nesting of all types of block statements (and closures), including for, if, while, try and switch statements. (design)
- MethodSizeRule: Add support for "ignoreMethodNames" property to enable filtering.
- AbstractRule: Enhance applyToFileNames to handle optional path (e.g. abc/def/MyClass.groovy).
- AbstractRule: The (previously deprecated) applyToFilenames and doNotApplyToFilenames properties now throw an UnsupportedOperationException.
- AbstractRule: Add optional description property; Use it in report if specified.
OTHER CHANGES
- Allow spaces within comma-separated list of ruleset files. Applies when specifying ruleset files for the CodeNarc Ant Task or the CodeNarc script.
- CodeNarcRunner: Dont require that reportWriters is non-empty.
- AntFileSetSourceAnalyzer: Specify sourceDirectories relative to project base directory.
- Reorganize web site. Add Reports section. Add pages for HTML, XML and and text reports.
- Add support and documentation for running CodeNarc as part of an automated test suite (e.g. JUnit).
- Add List getSourceDirectories() to SourceAnalyzer interface and implementation classes.
- Change codenarc-version.txt to contain only the version number.
- Rename AbstractTest to AbstractTestCase.


Changes in version 0.7 (25 Aug 2009)
------------------------------------
BUG FIXES
- Fix Bug #2825698: UnusedVariableRule: stops after 1st unused variable per name. https://sourceforge.net/tracker/?func=detail&aid=2825698&group_id=250145&atid=1126573.
- Fix Bug #2828696: UnusedImport rule with fully qualified class reference   https://sourceforge.net/tracker/?func=detail&atid=1126573&aid=2828696&group_id=250145.
- UnusedImportRule: Add support for static imports. Document known limitation: will not work on imports with wildcards.
- UnnecessaryGroovyImportRule: Add java.net as another automatically included package.
NEW FEATURES AND INFRASTRUCTURE
- Groovy DSL for defining RuleSets. (GroovyDslRuleSet and RuleSetBuilder).
- Enable optional prefix of file:, http: or any other standard URL prefix for resource files, including ruleset files, codenarc.properties and rule scripts.
    * Addresses Tracker Issue #2828616: Allow ruleset file to be specified as a file or url https://sourceforge.net/tracker/?func=detail&atid=1126575&aid=2828616&group_id=250145.
- CodeNarcTask and AntFileSetSourceAnalyzer: Allow more than one FileSet to be added.
    * Addresses Tracker Issue #2831255: Ant task should accept any ResourceCollection for source  https://sourceforge.net/tracker/?func=detail&aid=2831255&group_id=250145&atid=1126575.
- HtmlReportWriter: Show rule name in color according to priority.
- CompositeRuleSet: Rename add(RuleSet) to addRuleSet(RuleSet). Add addRule(Rule).
RULES
- Create new PropertyNameRule. (naming)
- FieldNameRule: Do not apply to property fields.


Changes in version 0.6 (17 Jul 2009)
------------------------------------
BUG FIXES
- Fix BUG #2798845 : StringIndexOutOfBoundsException https://sourceforge.net/tracker/?func=detail&atid=1126573&aid=2798845&group_id=250145
- Fix BUG #2799752: GrailsPublicControllerMethodRule - should only apply itself to methods within classes that have suffix "Controller". (see email from Jason Anderson, May 26, 2009) https://sourceforge.net/tracker/?func=detail&aid=2799752&group_id=250145&atid=1126573
- Fix BUG #2796953: StatelessClassRule requires applyToFileNames or applyToFilesMatching.  https://sourceforge.net/tracker/?func=detail&atid=1126573&aid=2796953&group_id=250145
- Fix BUG #2811213: FieldNameRule: Names for final fields - not be all caps. FieldNameRule: Field names for final instance fields should not default to be all caps like static final fields. For instance: final List sentEmails = []. Rather, If a property is declared final the private field is created final and no setter is generated. (http://groovy.codehaus.org/Groovy+Beans). So, they should be named with normal naming conventions. Re-purpose the finalRegex property to just apply to final instance fields and default to null so that final field names use same convention as non-final. https://sourceforge.net/tracker/?func=detail&aid=2811213&group_id=250145&atid=1126573.
- Fix: GrailsStatelessServiceRule: Should only apply to *Service classes.
RULES
- Implement UnusedVariableRule. (unused)
- Implement UnusedPrivateMethodRule. (unused)
- Implement UnusedPrivateFieldRule. (unused).
- MethodNameRule: Add support for ignoreMethodNames.
- ParameterNameRule: Add support for ignoreParameterNames.
- VariableNameRule: Add support for ignoreVariableNames.
- FieldNameRule: Add support for ignoreFieldNames.
- IllegalRegexRule: Include line numbers in rule violations.
INFRASTRUCTURE
- Allow setting custom name and path for codenarc.properties file using codenarc.properties.file system property.
- WildcardPattern: Add optional defaultMatches constructor parameter to specify return value of matches() when the pattern string is null or empty.
- HtmlReportWriter: Show rules with priority 4. This enables configuring rules to be included in the report but not fail the build.
- SourceCode: Add int getLineNumberForCharacterIndex(int charIndex).
- CodeNarcRunner: Dont mandate that reportWriters is non-empty.
OTHER
- Publish CodeNarc to Maven repository.


Changes in version 0.5 (24 May 2009)
------------------------------------
BUG FIXES
- FIX: IllegalRegexRule: Dont stop after first violation.
- FIX: VariableNameRule processing enums: ArrayIndexOutOfBoundsException: Negative array index [-3] too large for array size 1.
- FIX: BooleanInstantiationRule, VariableNameRule: Error parsing code with Enums.
- FIX: Rules sometimes produce two violations for a single line. (e.g. EmptyElseBlockRule, PrintlnRule)
POTENTIAL BREAKING CHANGES
- Normalize all path separators (/,\) in SourceCode paths.
- SourceCodeCriteria: Change applyToFilenames and doNotApplyToFilenames to applyToFileNames and doNotApplyToFileNames.
- DirectorySourceAnalyzer: Change applyToFilenames and doNotApplyToFilenames to applyToFileNames and doNotApplyToFileNames.
RULES
- Created new "grails" RuleSet and nine new Rules:
   * GrailsStatelessServiceRule (Specially-configured StatelessClassRule) (grails)
   * GrailsPublicControllerMethodRule (grails)
   * GrailsServletContextReferenceRule (grails)
   * GrailsSessionReferenceRule (grails)
   * StatelessClassRule (generic)
   * EmptySynchronizedStatementRule (basic).
   * EmptySwitchStatementRule (basic).
   * EqualsAndHashCodeRule (basic)
   * JUnitPublicNonTestMethodRule (junit).
- Change JUnit rules to use applyToClassNames=*Test,*Tests.
- ClassSizeRule: Dont include package name in violation message.
INFRASTRUCTURE
- Support running CodeNarc as a command-line application (org.codenarc.CodeNarc).
- Add support for Groovy rule scripts.
- AbstractAstVisitorRule: Add applyToClassNames and doNotApplyToClassNames. Filter rules based on class and/or package.
- AbstractRule. Add applyToFileNames and doNotApplyToFileNames (deprecate applyToFilenames and doNotApplyToFilenames).
- Normalize all separators (/,\) in SourceCode paths to '/'.
- AbstractRule: Enable setting violationMessage to empty string to turn it off.
- HtmlReportWriter: Log output report filename.
- Include number (index) of rule in Rule Descriptions section of HTML report.
- Create CodeNarcRunner class; refactor CodeNarc and CodeNarcTask to use it.
- HtmlReportWriter: Shrink font size of the rule descriptions at the end of the HTML report.
- HtmlReportWriter: Remove Source Directories section.
- Create FilesystemSourceAnalyzer.
- Refactor WildcardPattern to (optionally) support comma-separated list of patterns.
- Change WildcardPattern to support Ant-style ** wildcards.
- Refactor AbstractRule and AbstractAstVisitor add/create Violation and source line helper methods.
- Add createViolation(SourceCode, ASTNode) method to AbstractRule.
- Add line(int) method to SourceCode to return trimmed source line.
- Add createViolation() convenience method(s) to AbstractRule.
- AbstractAstVisitor: Replace isAlreadyVisited() and registerAsVisited() with isFirstVisit().
DEPRECATIONS
- AbstractRule: Deprecated applyToFilenames and doNotApplyToFilenames (replace with applyToFileNames and doNotApplyToFileNames).
- Deprecated DirectorySourceAnalyzer.
DOCUMENTATION
- Create Create Rule document.
- Add section in Configuring Rules on Turning Off a Rule.


Changes in version 0.4 (31 Mar 2009)
------------------------------------
INFRASTRUCTURE
- Support for wildcards (*,?) in RuleSet <include> and <exclude>, and in Rule.applyToFilenames.
- Fix for configuration from properties files - allow setting superclass fields.
- Add better logging, including stacktrace, when an error occurs during processing.
- Format (and truncate) source line within the HtmlReportWriter.
- Improve violation information for imports - line number and actual source line.
- Make version at the bottom of the HTML report a link to the web site.
- Refactor SourceCodeUtil to a SourceCodeCriteria class.
- CodeNarcTask: Log elapsed time after analysis is complete.
- CodeNarcTask: Dont fail build until after reports are generated.
- Create WildcardPattern class.
- Create AstUtil. Move isBlock() and isEmptyBlock() from AbstractAstVisitor.
RULES
- Created new "junit" and "logging" RuleSets and a bunch of new Rules:
   * JUnitAssertAlwaysSuccedsRule (junit)
   * JUnitAssertAlwaysFailsRule (junit)
   * JUnitTearDownCallsSuperRule (junit)
   * JUnitSetUpCallsSuperRule (junit)
   * SystemErrPrintRule. (logging)
   * SystemOutPrintRule. (logging)
   * PrintlnRule. (logging)
   * PrintStackTraceRule. (logging)
   * CatchNullPointerExceptionRule. (exceptions)
   * CatchExceptionRule. (exceptions)
   * CatchRuntimeExceptionRule. (exceptions)
   * CatchErrorRule. (exceptions)
   * ThrowThrowableRule (exceptions)
   * ThrowExceptionRule (exceptions)
   * ThrowNullPointerExceptionRule (exceptions)
   * ThrowRuntimeExceptionRule (exceptions)
   * ThrowErrorRule (exceptions)
- BooleanInstantiationRule: Also check for Boolean.valueOf(true/false).
DOCUMENTATION
- Add example reports for open source Groovy projects: Grails, Griffon and Gradle.


Changes in version 0.3 (02 Mar 2009)
------------------------------------
INFRASTRUCTURE
- Read rules configuration from optional "codenarc.properties" file. (PropertiesRuleSetConfigurer).
- CodeNarcTask: Add support for maxPriority3Violations property, etc.
- AbstractRule: Add applyToFilenames and doNotApplyToFilenames - available to all rules (subclasses).
- HtmlReportWriter: Display sourceLine and message on separate lines with named bullets.
RULES
- Created new "naming" RuleSets and new Rules:
   * AbstractClassNameRule. (naming)
   * ClassNameRule. (naming)
   * FieldNameRule. (naming)
   * InterfaceNameRule. (naming)
   * MethodNameRule. (naming)
   * PackageNameRule. (naming)
   * ParameterNameRule. (naming)
   * VariableNameRule. (naming)
MINOR FIXES/ENHANCEMENTS
- Fix NullPointerException for compiler errors from import rules.
- AbstractRule: Introduce violationMessage property. Overrides default message if set.
- Rename Violation description property to message.
- Rename HtmlReportWriter CSS file to 'codenarc-htmlreport.css'.
- Change SourceCodeUtil.shouldApplyTo() to take a Map of criteria.
- Add setName() and setPriority() to AbstractRule.
DOCUMENTATION
- Add info to online docs re: standard rule properties.
- Reorganize docs  separate doc for each RuleSet; section for each rule; table for properties.
- Update RuleSets doc with info about configuring using properties file.
- Create Configuring Rules document (adapt existing custom-rule-descriptions.apt).


Changes in version 0.2 (07 Feb 2009)
------------------------------------
- Create XML Schema Definition (XSD) for XML RuleSet file.
    * NOTE: RuleSet files MUST declare this schema
    * NOTE: RuleSet files are validated against this schema
- More powerful and flexible RuleSet definition, including:
    * Nested RuleSets
    * Use <include> and <exclude> to filter rules from nested RuleSets
    * Use <rule-config> to configure rules from nested RuleSets

- Created new "generic", "braces", and "size" RuleSets
- Created new Rules:
   * IllegalRegexRule. (generic)
   * RequiredRegexRule. (generic)
   * ElseBlockBracesRule. (braces)
   * ForStatementBracesRule. (braces)
   * IfStatementBracesRule. (braces)
   * WhileStatementBracesRule. (braces)
   * MethodSizeRule. (size)
   * ClassSizeRule. (size)

- Rule: Rename "id" property to "name".
    * NOTE: This is a potential breakage if you have defined custom Rules.
- Flexible customization and localization of rule descriptions. ("codenarc-messages.properties")
- HtmlReportWriter: Add setTitle(), setOutputFile() to ReportWriter interface.


Changes in version 0.1 (24 Jan 2009)
------------------------------------
- Initial release. Includes 16 Rules; HtmlReportWriter; CodeNarcAntTask, DirectorySourceAnalyzer; XML RuleSets, etc..


