-
-
Notifications
You must be signed in to change notification settings - Fork 29
Add support for maximum or average values in metrics #669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
akash-manna-sky
wants to merge
7
commits into
jenkinsci:main
Choose a base branch
from
akash-manna-sky:JENKINS-75323
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
242bcd4
Add support for maximum or average values in metrics
akash-manna-sky e553fb7
Refactor CoverageQualityGateEvaluator to use simplified imports for M…
akash-manna-sky 86aeedd
Enhance CoverageQualityGateEvaluator to support maximum and average a…
akash-manna-sky 2361e1f
add legacy complexity maximum constant and refactor usage in Coverage…
akash-manna-sky e5953fa
add Javadoc comments to fix checkstyle warnings
akash-manna-sky 49ea836
refactor MetricAggregation to simplify getDefault method by removing …
akash-manna-sky 01b5cf6
add @CheckForNull annotation to rootNode for null safety
akash-manna-sky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
43 changes: 43 additions & 0 deletions
43
plugin/src/main/java/io/jenkins/plugins/coverage/metrics/model/MetricAggregation.java
This file contains hidden or 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,43 @@ | ||
| package io.jenkins.plugins.coverage.metrics.model; | ||
|
|
||
| import edu.hm.hafner.coverage.Metric; | ||
|
|
||
| /** | ||
| * Defines the aggregation mode for software metrics that can be aggregated in different ways (e.g., cyclomatic | ||
| * complexity can be reported as total, maximum, or average). For coverage metrics, this aggregation is not applicable | ||
| * and will be ignored. | ||
| * | ||
| * @author Akash Manna | ||
| */ | ||
| public enum MetricAggregation { | ||
| /** The total value of the metric (sum of all values). */ | ||
| TOTAL, | ||
| /** The maximum value of the metric. */ | ||
| MAXIMUM, | ||
| /** The average value of the metric. */ | ||
| AVERAGE; | ||
|
|
||
| /** | ||
| * Returns whether the specified metric supports aggregation modes. | ||
| * | ||
| * @param metric | ||
| * the metric to check | ||
| * | ||
| * @return {@code true} if the metric supports aggregation modes, {@code false} otherwise | ||
| */ | ||
| public static boolean isSupported(final Metric metric) { | ||
| return !metric.isCoverage(); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the default aggregation mode for the specified metric. | ||
| * | ||
| * @param metric | ||
| * the metric to get the default aggregation for | ||
| * | ||
| * @return the default aggregation mode | ||
| */ | ||
| public static MetricAggregation getDefault(final Metric metric) { | ||
| return TOTAL; | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
1 change: 1 addition & 0 deletions
1
...resources/io/jenkins/plugins/coverage/metrics/steps/CoverageQualityGate/config.properties
This file contains hidden or 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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| title.threshold=Threshold | ||
| title.baseline=Baseline | ||
| title.metric=Metric | ||
| title.aggregation=Aggregation | ||
| title.warning=Step or Build Result |
11 changes: 11 additions & 0 deletions
11
...urces/io/jenkins/plugins/coverage/metrics/steps/CoverageQualityGate/help-aggregation.html
This file contains hidden or 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,11 @@ | ||
| <div> | ||
| Defines how to aggregate the metric values for software metrics (e.g., cyclomatic complexity). | ||
| <ul> | ||
| <li><strong>TOTAL</strong>: Sum of all values (default)</li> | ||
| <li><strong>MAXIMUM</strong>: Maximum value found in any method or class</li> | ||
| <li><strong>AVERAGE</strong>: Average value across all methods or classes</li> | ||
| </ul> | ||
| This setting is only applicable for software metrics like cyclomatic complexity, cognitive complexity, and NPath | ||
| complexity. For coverage metrics (e.g., line coverage), this setting is ignored and the aggregated coverage | ||
| percentage is always used. | ||
| </div> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.