-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring Config, Adding Baseline (#4)
* Refactoring the configuration handling * Refactoring the report generation * Fixing the output table * Updating readme.md * Refining the HTML Report
- Loading branch information
1 parent
9bc428c
commit 9c34982
Showing
21 changed files
with
509 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Project name | ||
projectName: "Test" | ||
|
||
# Directories and files for analysis relative to the configuration files directory. | ||
# By default, it is "." | ||
include: | ||
- "./src" | ||
|
||
# Directories and files excluded from analysis. | ||
# Please note that for correct work, you need to add a slash at the end | ||
# so that only the necessary folders are excluded, and not all that have the same value in the path. | ||
# | ||
# For example: | ||
# "src/utils" can exclude both the desired "src/utils" folder and the "src/utilsForMe" folder for example. | ||
# | ||
# By default, it is empty | ||
# exclude: | ||
# - "" | ||
|
||
# The port on which the server will be launched | ||
# to interact with the analyzer from other programs. | ||
# By default, it is 8080 | ||
port: 8080 | ||
|
||
# The path where the cache will be stored. | ||
# Caching can significantly speed up data collection. | ||
# By default, it is set to the value of the temporary folder + /phpstats. | ||
cacheDir: "" | ||
|
||
# Disables caching. | ||
# By default, it is false | ||
disableCache: false | ||
|
||
# Path to the project relative to which all imports are allowed. | ||
# By default, it is equal to the analyzed directory. | ||
projectPath: "" | ||
|
||
# File extensions to be included in the analysis. | ||
# By default, it is php, inc, php5, phtml. | ||
extensions: | ||
- "php" | ||
- "inc" | ||
- "php5" | ||
- "phtml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,11 +20,12 @@ class HtmlExporter implements DataExporterInterface | |
'Method', | ||
'Line Count', | ||
'Argument Count', | ||
'If Count', | ||
'If Nesting Level', | ||
'Else Count', | ||
'Return Count', | ||
'Variable Count', | ||
'Property Call Count', | ||
'If Nesting Level', | ||
'Else Count', | ||
'Combined Cognitive Complexity' | ||
]; | ||
|
||
|
@@ -65,8 +66,8 @@ private function generateHtml(CognitiveMetricsCollection $metrics): string | |
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"> | ||
</head> | ||
<body> | ||
<div class="container mt-5"> | ||
<h1 class="mb-4">Metrics Report</h1> | ||
<div class="container-fluid"> | ||
<h1 class="mb-4">Cognitive Metrics Report</h1> | ||
<table class="table table-bordered table-striped"> | ||
<thead> | ||
<tr> | ||
|
@@ -81,14 +82,15 @@ private function generateHtml(CognitiveMetricsCollection $metrics): string | |
<tr> | ||
<td><?php echo htmlspecialchars($data->getClass(), ENT_QUOTES, 'UTF-8'); ?></td> | ||
<td><?php echo htmlspecialchars($data->getMethod(), ENT_QUOTES, 'UTF-8'); ?></td> | ||
<td><?php echo htmlspecialchars((string)$data->getLineCount(), ENT_QUOTES, 'UTF-8'); ?></td> | ||
<td><?php echo htmlspecialchars((string)$data->getArgCount(), ENT_QUOTES, 'UTF-8'); ?></td> | ||
<td><?php echo htmlspecialchars((string)$data->getReturnCount(), ENT_QUOTES, 'UTF-8'); ?></td> | ||
<td><?php echo htmlspecialchars((string)$data->getVariableCount(), ENT_QUOTES, 'UTF-8'); ?></td> | ||
<td><?php echo htmlspecialchars((string)$data->getPropertyCallCount(), ENT_QUOTES, 'UTF-8'); ?></td> | ||
<td><?php echo htmlspecialchars((string)$data->getIfNestingLevel(), ENT_QUOTES, 'UTF-8'); ?></td> | ||
<td><?php echo htmlspecialchars((string)$data->getElseCount(), ENT_QUOTES, 'UTF-8'); ?></td> | ||
<td><?php echo htmlspecialchars((string)$data->getScore(), ENT_QUOTES, 'UTF-8'); ?></td> | ||
<td><?php echo htmlspecialchars((string)$data->getLineCount(), ENT_QUOTES, 'UTF-8') . ' (' . number_format($data->getLineCountWeight(), 3) . ')'; ?></td> | ||
<td><?php echo htmlspecialchars((string)$data->getArgCount(), ENT_QUOTES, 'UTF-8') . ' (' . number_format($data->getArgCountWeight(), 3) . ')'; ?></td> | ||
<td><?php echo htmlspecialchars((string)$data->getIfCount(), ENT_QUOTES, 'UTF-8') . ' (' . number_format($data->getIfCountWeight(), 3) . ')'; ?></td> | ||
<td><?php echo htmlspecialchars((string)$data->getIfNestingLevel(), ENT_QUOTES, 'UTF-8') . ' (' . number_format($data->getIfNestingLevelWeight(), 3) . ')'; ?></td> | ||
<td><?php echo htmlspecialchars((string)$data->getElseCount(), ENT_QUOTES, 'UTF-8') . ' (' . number_format($data->getElseCountWeight(), 3) . ')'; ?></td> | ||
<td><?php echo htmlspecialchars((string)$data->getReturnCount(), ENT_QUOTES, 'UTF-8') . ' (' . number_format($data->getReturnCountWeight(), 3) . ')'; ?></td> | ||
<td><?php echo htmlspecialchars((string)$data->getVariableCount(), ENT_QUOTES, 'UTF-8') . ' (' . number_format($data->getVariableCountWeight(), 3) . ')'; ?></td> | ||
<td><?php echo htmlspecialchars((string)$data->getPropertyCallCount(), ENT_QUOTES, 'UTF-8') . ' (' . number_format($data->getPropertyCallCountWeight(), 3) . ')'; ?></td> | ||
<td><?php echo number_format($data->getScore(), 3); ?></td> | ||
</tr> | ||
<?php endforeach; ?> | ||
<?php endforeach; ?> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Phauthentic\CodeQualityMetrics\Business\Cognitive; | ||
|
||
/** | ||
* Enum to represent the metric names. | ||
*/ | ||
enum MetricNames: string | ||
{ | ||
case LINE_COUNT = 'lineCount'; | ||
case ARG_COUNT = 'argCount'; | ||
case RETURN_COUNT = 'returnCount'; | ||
case VARIABLE_COUNT = 'variableCount'; | ||
case PROPERTY_CALL_COUNT = 'propertyCallCount'; | ||
case IF_COUNT = 'ifCount'; | ||
case IF_NESTING_LEVEL = 'ifNestingLevel'; | ||
case ELSE_COUNT = 'elseCount'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.