~ubuntu-branches/ubuntu/vivid/gmetrics/vivid

« back to all changes in this revision

Viewing changes to src/site/apt/gmetrics-creating-metricset.apt

  • Committer: Package Import Robot
  • Author(s): Miguel Landaeta, Miguel Landaeta, tony mancill
  • Date: 2012-01-18 20:57:50 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120118205750-68fv86p7fs8xz470
Tags: 0.5-1
[Miguel Landaeta]
* New upstream release.
* Remove patch ftbfs_613266.diff since it was merged upstream.
* Update dates in copyright file.

[tony mancill]
* Set DMUA flag.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 
11
11
  <<GMetrics>> provides a Groovy DSL (domain-specific language) for defining <MetricSets>.
12
12
 
13
 
 
14
13
** A Sample Groovy MetricSet
15
14
~~~~~~~~~~~~~~~~~~~~~~~~~~~
16
15
 
17
 
  Here is an example of a Groovy <MetricSet> file:
 
16
  The preferred syntax for defining a <MetricSet> is to specify the list of <Metric>s using the <Metric>
 
17
  names. Here is simple example:
 
18
 
 
19
+----------------------------------------------------------------------------------------
 
20
metricset {
 
21
 
 
22
    description 'A simple MetricSet'
 
23
 
 
24
    ClassCount          // specify metric name only (note no "Metric" suffix on metric name)
 
25
 
 
26
    FieldCount {        // configure the Metric using a Closure
 
27
        functions = ['total']
 
28
    }
 
29
 
 
30
    MethodCount([functions:['total'])    // configure the Metric using a Map of properties
 
31
}
 
32
+----------------------------------------------------------------------------------------
 
33
 
 
34
  Things to note:
 
35
 
 
36
    * The Groovy <MetricSet> file itself must be accessible on the classpath.
 
37
 
 
38
    * This <MetricSet> includes the <<ClassCount>>, <<FieldCount>> and <<MethodCount>> <Metric>s.
 
39
 
 
40
    * Note that the <Metric> names do not include the "Metric" suffix (of the <Metric> implementation class name).
 
41
 
 
42
    * <Metric> properties can be configured either within a Closure (as assignments) or through a
 
43
      <Map> passed in within the parentheses (after the <Metric> name).
 
44
 
 
45
    * You can specify the <Metric> names for all <Metric>s provided with <<GMetrics>>. If you provide
 
46
      your own custom <Metric>s, then you must use the <<<metric(Class)>>> syntax instead -- see below.
 
47
 
 
48
 
 
49
** A More Comprehensive Groovy MetricSet
 
50
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
51
 
 
52
  Here is an example of a more comprehensive Groovy <MetricSet> file, illustrating specifying <Metric>s
 
53
  by <Metric> class or <Metric> name, and also nested <MetricSet> files:
18
54
 
19
55
+----------------------------------------------------------------------------------------
20
56
import org.gmetrics.metric.cyclomatic.CyclomaticComplexityMetric
21
57
 
22
58
metricset {
23
59
 
24
 
    description 'A sample MetricSet'
 
60
    description 'An example MetricSet'
25
61
 
26
62
    metricset("MyMetricSet.groovy")
27
63
 
29
65
        functions = ['average', 'maximum']
30
66
    }
31
67
 
32
 
    metric(CyclomaticComplexityMetric)
 
68
    metric(CyclomaticComplexityMetric)      // specify metric class (see import)
 
69
 
 
70
    ClassCount          // specify metric name only (note no "Metric" suffix on metric name)
 
71
 
 
72
    FieldCount {          // specify metric name only
 
73
        functions = ['total']
 
74
    }
33
75
 
34
76
    metricset("somepath/MyOtherMetricSet.groovy") {
35
77
        ClassLineCount {
81
123
      As within <<MetricSet>> statements, properties set this way can be of type <<<String>>>, <<<int>>>,
82
124
      <<<long>>> or <<<boolean>>>.
83
125
 
 
126
    * The <<ClassCount>> and <<FieldCount>> <Metric>s are included by specifying only the <Metric> name (not the class)
 
127
 
84
128
    * Setting the <<<enabled>>> property of a <Metric> turns it off so that it will not show up in the 
85
129
      output report(s).
86
130