From 32fcc5d7dba400424d50a95a51c200dfe3f8231f Mon Sep 17 00:00:00 2001 From: Rick Giles Date: Fri, 29 Aug 2003 18:44:59 +0000 Subject: [PATCH] documented CyclomaticComplexity (bug 783800) --- docs/config_metrics.html | 110 ++++++++++++++++++ docs/index.html | 1 + docs/releasenotes.html | 2 + .../metrics/CyclomaticComplexityCheck.java | 2 +- 4 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 docs/config_metrics.html diff --git a/docs/config_metrics.html b/docs/config_metrics.html new file mode 100644 index 000000000..5a3a0bfc5 --- /dev/null +++ b/docs/config_metrics.html @@ -0,0 +1,110 @@ + + + + + Metrics Checks + + + + + + + + + + +

Metrics Checks

Checkstyle Logo
+ + + + + + + + +
+ +

CyclomaticComplexity

+

Description

+ +

+Checks cyclomatic complexity against a specified limit. The complexity is +measured by the number of + if, + while, + do, + for, + ?:, + catch, + switch, + case statements, and operators + && and || (plus one) in the body of a +constructor, method, static initializer, or instance initializer. + It is a measure of the minimum number of possible paths through the +source and therefore the number of required tests. Generally 1-4 is +considered good, 5-7 ok, 8-10 consider re-factoring, and 11+ re-factor now! +

+ + +

Properties

+ + + + + + + + + + + + + +
namedescriptiontypedefault value
maxthe maximum threshold allowedinteger10
+ +

Examples

+

+ To configure the check: +

+
+<module name="CyclomaticComplexity"/>
+      
+

+ To configure the check with a threshold of 7: +

+
+<module name="CyclomaticComplexity">
+    <property name="max" value="7"/>
+</module>
+      
+      
+ +

Package

+

+ com.puppycrawl.tools.checkstyle.checks.metrics +

+ +

Parent Module

+

+ TreeWalker +

+ + + +
+
+
Back to the Checkstyle Home Page
+ + + + diff --git a/docs/index.html b/docs/index.html index 241363a9a..95729f5de 100644 --- a/docs/index.html +++ b/docs/index.html @@ -133,6 +133,7 @@
  • Usage
  • J2EE Requirements
  • Duplicate Code
  • +
  • Metrics Checks
  • Miscellaneous Checks
  • diff --git a/docs/releasenotes.html b/docs/releasenotes.html index 29bfe6078..1dea8bcb4 100644 --- a/docs/releasenotes.html +++ b/docs/releasenotes.html @@ -219,6 +219,8 @@
  • Fixed NoSuchMethodError when line wrapped at dot operator (bugid 790209)
  • Incorrect usage checks documentation (bug 790457)
  • + +
  • CyclomaticComplexityCheck not documented in docs (bug 783800)
  • diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/metrics/CyclomaticComplexityCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/metrics/CyclomaticComplexityCheck.java index 9544c8eff..63163660a 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/metrics/CyclomaticComplexityCheck.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/metrics/CyclomaticComplexityCheck.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.checks.CheckUtils; * measured by the number of "if", "while", "do", "for", "?:", "catch", * "switch", "case", "&&" and "||" statements (plus one) in the body of the * member. It is a measure of the minimum number of possible paths through the - * source and therefore the number of required tests tests. Generally 1-4 is + * source and therefore the number of required tests. Generally 1-4 is * considered good, 5-7 ok, 8-10 consider re-factoring, and 11+ re-factor now! * * @author Simon Harris