Skip to content

Add support for maximum or average values in metrics#669

Open
akash-manna-sky wants to merge 9 commits intojenkinsci:mainfrom
akash-manna-sky:JENKINS-75323
Open

Add support for maximum or average values in metrics#669
akash-manna-sky wants to merge 9 commits intojenkinsci:mainfrom
akash-manna-sky:JENKINS-75323

Conversation

@akash-manna-sky
Copy link
Contributor

Add support for maximum or average values in metrics

Fixes #639

Testing done

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

@akash-manna-sky akash-manna-sky marked this pull request as ready for review February 1, 2026 05:15
@uhafner uhafner added the enhancement Enhancement of existing functionality label Feb 7, 2026
Copy link
Member

@uhafner uhafner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for restoring this functionality. The Jenkins code looks good, but I think the code that computes the actual values (while it looks good) should be moved to the coverage-model, so that it can be used by other backends as well.

I will create an issue there, I need to spend some time on how to design the new API there. If you like, you then can continue there. (But I would fully understand if you would better like me to design the API in the coverage model, then you just need to adapt this PR).

Comment on lines +98 to +100
if (MetricAggregation.isSupported(metric)) {
this.aggregation = aggregation;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this statement is save: when the metric is set after the aggregation, it will fail. Can't we set the aggregation in any case and ignore it later on?

var aggregation = qualityGate.getAggregation();

Optional<Value> possibleValue;
if (MetricAggregation.isSupported(metric) && aggregation != MetricAggregation.TOTAL && rootNode != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can the node get null?

Suggested change
if (MetricAggregation.isSupported(metric) && aggregation != MetricAggregation.TOTAL && rootNode != null) {
if (MetricAggregation.isSupported(metric) && aggregation != MetricAggregation.TOTAL) {

Comment on lines +5 to +6
<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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to check an example, but shouldn't these options work on the method level only?

result.add(qualityGate, QualityGateStatus.INACTIVE, "n/a");
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code after this line actually should be part of the coverage model.

@github-actions github-actions bot requested a review from uhafner February 15, 2026 03:32
@akash-manna-sky
Copy link
Contributor Author

Then what should I do now? Should I open a new PR in Coverage Model or should I wait untill you open the issue there? Or anything else? Please suggest me. @uhafner

@uhafner
Copy link
Member

uhafner commented Feb 15, 2026

I think I need more time to investigate on how to integrate this functionality. I started to document it in jenkinsci/coverage-model#270.

@akash-manna-sky
Copy link
Contributor Author

I think I need more time to investigate on how to integrate this functionality. I started to document it in jenkinsci/coverage-model#270.

Okay, please take your time. Once everything is sorted out, and if you think it’s appropriate to assign the issue to me, I would be happy to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Enhancement of existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[JENKINS-75323] Add support for maximum or average values in metrics

2 participants