GMetrics

  • Authors : null
1 vote
Dependency :
compile ":gmetrics:0.3.1"

Documentation

Summary

Installation

grails install-plugin gmetrics

Description

Gmetrics Plugin

The Gmetrics Plugin provides static code analysis for Groovy code. It uses the Gmetrics] library.

The GMetrics project provides calculation and reporting of size and complexity metrics for Groovy source code. GMetrics scans Groovy source code, applying a set of metrics, and generates an HTML report of the results.

Total and average values for the following metrics are provided:

  • Cyclomatic Complexity.
  • ABC Size/Complexity. Also see the C2 Wiki page.
  • Lines per method
  • Lines per class

Installation

To integrate the plugin into your application just run the 'install-plugin' Grails script, e.g.

grails install-plugin gmetrics

Usage

The plugin provides a script 'gmetrics' that will analyze your code and write its results to an HTML file. Run

grails gmetrics
to perform the analysis.

Customization

The plugin requires no customization to run. By default it will analyze all Groovy files in

  • src/groovy
  • grails-app/controllers
  • grails-app/domain
  • grails-app/services
  • grails-app/taglib
  • grails-app/utils
  • test/unit
  • test/integration
and use a default title and report name. You can restrict which folders are included or add extra ones. The (optional) "gmetrics.properties" file can be located in the project base directory. The following table lists settings that will be read from grails-app/Config.groovy and used if available:

PropertyDefault ValueMeaning
gmetrics.outputFiletarget/GMetricsReport.htmlthe path and name of the analysis report file
gmetrics.reportTypeorg.gmetrics.report.BasicHtmlReportWriterthe report type; valid values are 'html', 'xml' and 'text', or the fully-qualified class name of a ReportWriter class
gmetrics.reportTitleGMetrics Reportthe report title
gmetrics.processSrcGroovytruewhether to analyze source in src/groovy
gmetrics.processControllerstruewhether to analyze source in grails-app/controllers
gmetrics.processDomaintruewhether to analyze source in grails-app/domain
gmetrics.processServicestruewhether to analyze source in grails-app/services
gmetrics.processTaglibtruewhether to analyze source in grails-app/taglib
gmetrics.processTestUnittruewhether to analyze source in test/unit
gmetrics.processTestIntegrationtruewhether to analyze source in test/integration
gmetrics.extraIncludeDirsnoneextra source directories to include; for example to include Quartz job files, specify
gmetrics.extraIncludeDirs=['grails-app/jobs']
to add the pattern 'grails-app/jobs//*.groovy' to the analysis fileset

See GMetrics for more information on Gmetrics configuration options.

Please report any issues to the Grails User mailing list and/or write up an issue in JIRA at http://jira.codehaus.org/browse/GRAILSPLUGINS under the Grails-Gmetrics component.

License

Licensed under the Apache License, Version 2.0. See http://www.apache.org/licenses/LICENSE-2.0.

History

  • January 11, 2011 (Version 0.3.1)
    • Change default target to gmetrics from default
  • August 11, 2010 (version 0.3)
    • Support for version 0.3 of gmetrics
    • Change dependency to provided so it is no longer packaged in the war
  • June 3, 2010 (version 0.2.1)
    • Support for report name and output file name as configurable parameters
  • June 1, 2010 (version 0.2)
    • released initial version 0.2