Skip to content

Commit

Permalink
Feature/2474/risk profile calculation for every language (#2679)
Browse files Browse the repository at this point in the history
* Refactor implementation of risk profile and calculate all occurring programming languages in selected map for risk profile
#2474

* Adjust tests
#2474

* Adjust html for risk profile
#2474

* Adjust and add new tests
#2474

* Update CHANGELOG.md
#2474

* Implement interface for language thresholds and refactor
#2474

* Implement default view model
#2474

* Finalize tests
#2474
  • Loading branch information
Hall-Ma committed Mar 1, 2022
1 parent 796554c commit bde4caa
Show file tree
Hide file tree
Showing 8 changed files with 278 additions and 171 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/)

## [unreleased] (Added 🚀 | Changed | Removed 🗑 | Fixed 🐞 | Chore 👨‍💻 👩‍💻)

### Changed

- Risk profile is now calculated for every occurring programming languages in selected file(s)[#2679](https://github.com/MaibornWolff/codecharta/pull/2679)

## [1.91.1] - 2022-02-25

### Fixed 🐞
Expand All @@ -25,6 +29,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/)
### Fixed 🐞

- Improve loading times by reducing the size of JavaScript files [#2667](https://github.com/MaibornWolff/codecharta/pull/2667)
- Fix loading of files without edge metric never finished [#2680](https://github.com/MaibornWolff/codecharta/issues/2680)

### Chore 👨‍💻 👩‍💻

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ArtificialIntelligenceController on files selection changed should calculate risk profile for not excluded files only 1`] = `
exports[`ArtificialIntelligenceController calculate should calculate risk profile but skip files with missing metrics 1`] = `
Object {
"highRisk": 0,
"lowRisk": 0,
"moderateRisk": 0,
"veryHighRisk": 0,
}
`;

exports[`ArtificialIntelligenceController calculate should calculate risk profile for not excluded files only 1`] = `
Object {
"highRisk": 50,
"lowRisk": 27,
Expand All @@ -9,7 +18,16 @@ Object {
}
`;

exports[`ArtificialIntelligenceController on files selection changed should calculate suspicious metrics sorted by isOutlier 1`] = `
exports[`ArtificialIntelligenceController calculate should calculate risk profile only for valid file extensions 1`] = `
Object {
"highRisk": 0,
"lowRisk": 0,
"moderateRisk": 0,
"veryHighRisk": 0,
}
`;

exports[`ArtificialIntelligenceController calculate should calculate suspicious metrics sorted by isOutlier 1`] = `
Array [
Object {
"from": 365,
Expand Down Expand Up @@ -37,17 +55,73 @@ Array [
]
`;

exports[`ArtificialIntelligenceController on files selection changed should calculate suspicious metrics sorted by isOutlier 2`] = `
exports[`ArtificialIntelligenceController calculate should calculate suspicious metrics sorted by isOutlier 2`] = `
Array [
"rloc (real lines of code)",
]
`;

exports[`ArtificialIntelligenceController on files selection changed should clear and calculate risk profile for Java map 1`] = `
exports[`ArtificialIntelligenceController on experimental features enabled changed should calculate suspicious metrics when experimental features are enabled 1`] = `
Object {
"highRisk": 37,
"lowRisk": 46,
"moderateRisk": 17,
"veryHighRisk": 0,
"analyzedProgrammingLanguage": "java",
"riskProfile": Object {
"highRisk": 37,
"lowRisk": 46,
"moderateRisk": 17,
"veryHighRisk": 0,
},
"suspiciousMetricSuggestionLinks": Array [
Object {
"from": 365,
"isOutlier": true,
"max": 0,
"metric": "loc",
"min": 0,
"to": 554,
},
Object {
"from": 29,
"isOutlier": true,
"max": 0,
"metric": "functions",
"min": 0,
"to": 44,
},
Object {
"from": 48,
"max": 0,
"metric": "mcc",
"min": 0,
"to": 71,
},
],
"unsuspiciousMetrics": Array [
"rloc (real lines of code)",
],
}
`;

exports[`ArtificialIntelligenceController on files selection changed should recalculate suspicious metrics 1`] = `
Object {
"analyzedProgrammingLanguage": "ts",
"riskProfile": Object {
"highRisk": 0,
"lowRisk": 0,
"moderateRisk": 0,
"veryHighRisk": 100,
},
"suspiciousMetricSuggestionLinks": Array [
Object {
"from": 50,
"isOutlier": true,
"max": 0,
"metric": "mcc",
"min": 0,
"to": 70,
},
],
"unsuspiciousMetrics": Array [
"rloc (real lines of code)",
],
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,24 @@
</md-button>

<md-menu-content class="ai-drop-down summary">
<md-menu-item class="title">
<p ng-show="$ctrl._viewModel.analyzedProgrammingLanguage.length">
Risk Profile for {{ $ctrl._viewModel.analyzedProgrammingLanguage }} code (most frequent programming language in project)
</p>
<md-menu-item class="title" ng-show="$ctrl._viewModel.analyzedProgrammingLanguage.length">
<p>Risk Profile</p>
<p>Calculations are always based on mcc (cyclomatic complexity)</p>
</md-menu-item>

<md-menu-item class="suspicious-metrics-summary">
<ul ng-show="$ctrl._viewModel.riskProfile !== undefined">
<ul ng-show="$ctrl._viewModel.analyzedProgrammingLanguage.length">
<li>{{ $ctrl._viewModel.riskProfile.lowRisk }}% of overall code is in files with low complexity</li>
<li>{{ $ctrl._viewModel.riskProfile.moderateRisk }}% of overall code is in files with moderate complexity</li>
<li>{{ $ctrl._viewModel.riskProfile.highRisk }}% of overall code is in files with high complexity</li>
<li>{{ $ctrl._viewModel.riskProfile.veryHighRisk }}% of overall code is in files with extreme complexity</li>
</ul>
<span ng-show="$ctrl._viewModel.riskProfile === undefined">
<span ng-show="$ctrl._viewModel.analyzedProgrammingLanguage === undefined">
Could not calculate Risk Profile. Metrics rloc and mcc not available.
</span>
</md-menu-item>

<md-menu-item class="risk-profiles" ng-show="$ctrl._viewModel.riskProfile !== undefined">
<md-menu-item class="risk-profiles" ng-show="$ctrl._viewModel.analyzedProgrammingLanguage.length">
<div
ng-if="$ctrl._viewModel.riskProfile.lowRisk > 0"
title="Low Risk ({{ $ctrl._viewModel.riskProfile.lowRisk }}% of code)"
Expand Down

0 comments on commit bde4caa

Please sign in to comment.