Skip to content

Commit

Permalink
Add 2 new compliance rules for metrics 'ComplexityHighest' and 'Nesti…
Browse files Browse the repository at this point in the history
…ngDepthHighest'
  • Loading branch information
MathieuBuisson committed Jul 16, 2017
1 parent 6d29117 commit b22c999
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
28 changes: 26 additions & 2 deletions docs/Metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ The later a defect is detected, the more expensive (in time and money) it is to
- Fail : greater than 12

### Complexity
This is the cyclomatic complexity of a given function. Cyclomatic complexity measures the number of possible execution paths through a given section of code. This is intended to evaluation code complexity.
This is the cyclomatic complexity of a given function. Cyclomatic complexity measures the number of possible execution paths through a given section of code. This is intended to evaluate code complexity.

Lower is better, because complex code tends to have the following properties :
- Difficult to read/understand
Expand Down Expand Up @@ -195,7 +195,7 @@ The later a defect is detected, the more expensive (in time and money) it is to
- Fail : greater than 400

### ComplexityAverage
This is the average cyclomatic complexity per function. Cyclomatic complexity measures the number of possible execution paths through a given section of code. This is intended to evaluation code complexity.
This is the average cyclomatic complexity per function. Cyclomatic complexity measures the number of possible execution paths through a given section of code. This is intended to evaluate code complexity.

Lower is better, because complex code tends to have the following properties :
- Difficult to read/understand
Expand All @@ -210,6 +210,20 @@ Lower is better, because complex code tends to have the following properties :

For more details on how the cyclomatic complexity is calculated, please refer to [this article](http://theshellnut.com/measuring-powershell-code-complexity-why-and-how/).

### ComplexityHighest
This is the cyclomatic complexity of the function which has the highest complexity value in the health report. Cyclomatic complexity measures the number of possible execution paths through a given section of code. This is intended to evaluate code complexity.

Lower is better, because complex code tends to have the following properties :
- Difficult to read/understand
- Difficult to test
- More prone to defects
- Make defects more difficult to identify
- More difficult and risky to change/refactor/maintain

#### Default thresholds : the double of the average ([Source](http://www.ndepend.com/docs/code-metrics#CC))
- Warning : greater than 30
- Fail : greater than 60

### NestingDepthAverage
This is the average of **MaximumNestingDepth** per function.
MaximumNestingDepth is the depth of the most deeply nested code in a given function. This measures a different aspect of complexity from the "cyclomatic complexity", so these 2 metrics are complementary. The nesting depth of a piece of code is an indication of the complexity of its context.
Expand All @@ -221,3 +235,13 @@ Again, lower is better.
- Fail : greater than 8

For more details on how the maximum nesting depth is calculated, please refer to [this article](http://theshellnut.com/measuring-powershell-code-complexity-why-and-how/).

### NestingDepthHighest
This is the **MaximumNestingDepth** of the function which has the highest value in the health report.
MaximumNestingDepth is the depth of the most deeply nested code in a given function. This measures a different aspect of complexity from the "cyclomatic complexity", so these 2 metrics are complementary. The nesting depth of a piece of code is an indication of the complexity of its context.

Again, lower is better.

#### Default thresholds : the double of the average ([Source](http://www.ndepend.com/docs/code-metrics#ILNestingDepth))
- Warning : greater than 8
- Fail : greater than 16
4 changes: 2 additions & 2 deletions docs/Release.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# 2017-06-18
# 2017-07-16

- Add a 'FailedTestsDetails' property to health reports
- Add 2 new compliance rules for metrics "ComplexityHighest" and "NestingDepthHighest"

0 comments on commit b22c999

Please sign in to comment.