forked from SonarOpenCommunity/sonar-cxx
-
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.
Redesign of language-specific metrics The following problems were identified and solved: PROBLEM 1 * CxxLanguage::MetricsCache was not filled while construction of CxxLanguage object but only in CxxSquidSensor::CxxSquidSensor() SOLUTION * Introduce CxxMetricsFactory. * It has no dependencies to sensors. * It creates language-dependent metrics in the constructor of CxxSquidSensor PROBLEM 2 * During the test MetricsCache was almost always empty. In order to prevent warnings (?) missing metrics' lookups were just ignored SOLUTON * Introduce `protected abstract Optional<CxxMetricsFactory.Key> CxxReportSensor::getMetricKey();` * By means of Optional<> semantic sensors show if metric is required or not * CxxLanguage::getMetric() checks thows an exception if metric hasn't been found PROBLEM 3 * CxxLanguage::getMetric(<required metric key>) expected the key to be typed as String * In order to fill the MetricsCache the format {METRIC_KEY} was used * Cache lookups were done however in the format {LANG_PROP_KEY}-{METRIC_KEY} SOLUTION * In order to make the lookup key type-safe and less error-prone I introduced the type `CxxMetricsFactory.Key` PROBLEM 4a * The plugin-specific metrics for public API were missing on module level All CoreMetrics (incls. former Public API) have automatic aggregation: 1. ComputeEngine implements some server-side task 2. This task iterates over the project hierarchy `FILE -> DIRECTORY/MODULE -> ... -> ... -> PROJECT` and performs a recursive sum for all metrics raised on children component 3. This sum is stored as aggregated metric for the parent component 4. The number of hierarchy levels can be arbitrary 5. Starting with version 6.2 the public API metrics were deprecated and Sonar-CXX introduces its own plugin-specific public API metrics 6. These custom metrics are not aggregated automatically anymore PROBLEM 4b * PR SonarOpenCommunity#1398 introduced 9 new complexity metrics They supported the aggregation of the file-level metrics. The aggregation was implemeted inside of the `AstVisitor`, however the aggregation was done for the parent module only. Ths solution worked for the simple SonarQube projects only. Due to hierarchy depth == 2, aggregated results were stored on the project level. Multi-module projects however might have an arbitrary depth. So there was no proper aggregation for such projects. After public API metrics were deprecated as CoreMetrics the automatic aggregation It was not enough to set them on the file level. One had to aggregate these measurements and set the result on the module level. Otherwise they were not displayed in the SonarQube's Activity UI SOLUTION * Unify implementation of custom metrics for Public-API and complexity * Implement 2 Compute Engine tasks (see `MeasureComputer`), which perform the aggregation and computation of these metrics * Computaton/aggregation works for both types of SonarQube project - the simple and the multi-module ones PROBLEM 5 * The metric `CoreMetrics.COGNITIVE_COMPLEXITY` was measured but not persisted MISC * Test has been added * Minor refactoring and comments
- Loading branch information
1 parent
e082c4a
commit 6e08f1c
Showing
63 changed files
with
1,837 additions
and
1,583 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
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
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
210 changes: 0 additions & 210 deletions
210
.../main/java/org/sonar/cxx/sensors/functioncomplexity/CxxFunctionComplexitySquidSensor.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.