Skip to content

Commit

Permalink
Adding the delta to the reports. (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
floriankraemer authored Oct 4, 2024
1 parent 35fb967 commit 5a93e4a
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 92 deletions.
51 changes: 27 additions & 24 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 0 additions & 24 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,30 +101,6 @@ Class: Doctrine\ORM\Tools\Pagination\Paginator
│ convertWhereInIdentifiersToDatabaseValues │ 11 (0) │ 1 (0) │ 1 (0) │ 5 (0.47) │ 1 (0) │ 0 (0) │ 0 (0) │ 0 (0) │ 0.47 │
└───────────────────────────────────────────┴────────┴───────────┴─────────┴───────────┴──────────┴───────┴────────────┴───────────┴────────────┘
```

### Halstead Metrics

```txt
Class: WP_Debug_Data
File: /home/florian/projects/cognitive-code-checker/tests/TestCode/FileWithTwoClasses.php
┌─────────────┬─────────────┬───────────┬──────────┬─────────┬────────────┬──────────┬────────────┬───────────┬──────────┐
│ n1 Distinct │ n2 Distinct │ Total │ Total │ Program │ Program │ Volume │ Difficulty │ Effort │ Possible │
│ Operators │ Operands │ Operators │ Operands │ Length │ Vocabulary │ │ │ │ Bugs │
├─────────────┼─────────────┼───────────┼──────────┼─────────┼────────────┼──────────┼────────────┼───────────┼──────────┤
│ 13 │ 563 │ 869 │ 2123 │ 2992 │ 576 │ 27436.42 │ 24.51 │ 672484.58 │ 9.15 │
└─────────────┴─────────────┴───────────┴──────────┴─────────┴────────────┴──────────┴────────────┴───────────┴──────────┘
Class: Doctrine\ORM\Tools\Pagination\Paginator
File: /home/florian/projects/cognitive-code-checker/tests/TestCode/FileWithTwoClasses.php
┌─────────────┬─────────────┬───────────┬──────────┬─────────┬────────────┬─────────┬────────────┬──────────┬──────────┐
│ n1 Distinct │ n2 Distinct │ Total │ Total │ Program │ Program │ Volume │ Difficulty │ Effort │ Possible │
│ Operators │ Operands │ Operators │ Operands │ Length │ Vocabulary │ │ │ │ Bugs │
├─────────────┼─────────────┼───────────┼──────────┼─────────┼────────────┼─────────┼────────────┼──────────┼──────────┤
│ 7 │ 36 │ 108 │ 161 │ 269 │ 43 │ 1459.67 │ 15.65 │ 22847.82 │ 0.49 │
└─────────────┴─────────────┴───────────┴──────────┴─────────┴────────────┴─────────┴────────────┴──────────┴──────────┘
```

## License
Copyright Florian Krämer
Expand Down
34 changes: 34 additions & 0 deletions src/Business/Cognitive/Exporter/CsvExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,23 @@ class CsvExporter implements DataExporterInterface
'Class',
'Method',
'Line Count',
'Line Count Weight',
'Line Count Weight Delta',
'Argument Count',
'Argument Count Weight',
'Argument Count Weight Delta',
'Return Count',
'Return Count Weight',
'Return Count Weight Delta',
'Variable Count',
'Variable Count Weight',
'Variable Count Weight Delta',
'Property Call Count',
'Property Call Count Weight',
'Property Call Count Weight Delta',
'If Nesting Level',
'If Nesting Level Weight',
'If Nesting Level Weight Delta',
'Else Count',
'Combined Cognitive Complexity'
];
Expand All @@ -49,13 +61,35 @@ public function export(CognitiveMetricsCollection $metrics, string $filename): v
fputcsv($file, [
$data->getClass(),
$data->getMethod(),

$data->getLineCount(),
$data->getLineCountWeight(),
(string)$data->getLineCountWeightDelta(),

$data->getArgCount(),
$data->getArgCountWeight(),
(string)$data->getArgCountWeightDelta(),

$data->getReturnCount(),
$data->getReturnCountWeight(),
(string)$data->getReturnCountWeightDelta(),

$data->getVariableCount(),
$data->getVariableCountWeight(),
(string)$data->getVariableCountWeightDelta(),

$data->getPropertyCallCount(),
$data->getPropertyCallCountWeight(),
(string)$data->getPropertyCallCountWeightDelta(),

$data->getIfNestingLevel(),
$data->getIfNestingLevelWeight(),
(string)$data->getIfNestingLevelWeightDelta(),

$data->getElseCount(),
$data->getElseCountWeight(),
(string)$data->getElseCountWeightDelta(),

$data->getScore()
]);
}
Expand Down
Loading

0 comments on commit 5a93e4a

Please sign in to comment.