Skip to content

PLUGINAPI-189 Add new metrics#289

Merged
OrlovAlexander85 merged 1 commit into
masterfrom
task/orlov/SC-47805/new-metrics
May 7, 2026
Merged

PLUGINAPI-189 Add new metrics#289
OrlovAlexander85 merged 1 commit into
masterfrom
task/orlov/SC-47805/new-metrics

Conversation

@OrlovAlexander85
Copy link
Copy Markdown
Contributor

@OrlovAlexander85 OrlovAlexander85 commented May 5, 2026

Validation from SQC:
image

Severity values added to be align with severity of metrics added by SCA recently

For SonarSourcers:

Check before making the PR ready for review

  • Create a JIRA ticket if the API is impacted
  • Prefix the commit message with the ticket number
  • Document the change in CHANGELOG.md
  • When adding a new API:
    • Explain in the JavaDoc the purpose of the new API
    • Add a @since X.Y in the JavaDoc
  • When deprecating an API:
    • Annotate the deprecated element with @Deprecated
    • Add a @deprecated since X.Y in the JavaDoc
    • Document the replacement in the JavaDoc (if any)
  • When dropping an API:
  • Make sure the tests adhere to the convention:
    • All test method names should use snake_case, for example: test_validate_input. It can also start with the methodName
  • Make sure checks are green: build passes, Quality Gate is green
  • Merge after getting approval by at least one member of the guild
    • If no review is made within 3 days, gently ping the reviewers
    • The guild member reviewing the code can explicitly request someone else (typically another guild member representing another team) to check the impact on the specific product
    • In some cases, the guild may deem it necessary that multiple or even all members approve a PR. This is more likely in complex changes or changes directly impacting all teams using the API.

For external contributors:

Please be aware that we are not actively looking for feature contributions. The truth is that it's extremely difficult for someone outside SonarSource to comply with our roadmap and expectations. Therefore, we typically only accept minor cosmetic changes and typo fixes. If you would like to see a new feature, please create a new thread in the forum "Suggest new features".

With that in mind, if you would like to submit a code contribution, make sure that you adhere to the following guidelines and all tests are passing:

Please explain your motives to contribute this change: what problem you are trying to fix, what improvement you are trying to make
Use the following formatting style: SonarSource/sonar-developer-toolset
Provide a unit test for any code you changed
If there is a JIRA ticket available, please make your commits and pull request start with the ticket ID (PLUGINAPI-XXXX)

Please note that opening the PR will notify all the squad members. Please make sure you keep it in DRAFT and mark it ready, when all the checks are green.

We will try to give you feedback on your contribution as quickly as possible.

Thank You! The SonarSource Team

@hashicorp-vault-sonar-prod
Copy link
Copy Markdown

hashicorp-vault-sonar-prod Bot commented May 5, 2026

PLUGINAPI-189

@OrlovAlexander85 OrlovAlexander85 force-pushed the task/orlov/SC-47805/new-metrics branch from 414de65 to 7f37fb1 Compare May 5, 2026 12:01
@OrlovAlexander85 OrlovAlexander85 changed the title SC-47805 Add new metrics PLUGINAPI-189 Add new metrics May 5, 2026
@OrlovAlexander85 OrlovAlexander85 force-pushed the task/orlov/SC-47805/new-metrics branch from 7f37fb1 to 52f7d4d Compare May 5, 2026 12:15
@OrlovAlexander85 OrlovAlexander85 marked this pull request as ready for review May 6, 2026 07:11
@OrlovAlexander85 OrlovAlexander85 requested a review from a team as a code owner May 6, 2026 07:11
@sonar-review-alpha
Copy link
Copy Markdown

sonar-review-alpha Bot commented May 6, 2026

Summary

This PR adds six new severity-based metrics to track the worst severity level of issues in new code, across both the MQR (Reliability/Security/Maintainability) and standard SonarQube quality models. A new SeverityValues utility class provides integer constants (0, 5, 10, 15, 20, 25) representing severity levels (NO_ISSUES through BLOCKER), with guidance on quality gate configuration. CHANGELOG is updated.

What reviewers should know

Where to start: Check CoreMetrics.java line 1050+ and line 1209+ for the three pairs of new metrics (6 total). Then review the new SeverityValues.java to understand the severity integer mapping.

Key patterns to verify:

  • All six new metrics follow the same pattern: key constant + Metric<Integer> object with matching configuration
  • All use DIRECTION_WORST (higher value = worse), setDeleteHistoricalData(true), and best/worst values tied to SeverityValues constants
  • Severity integers are spaced by 5; the comment in SeverityValues explains why (quality gate thresholds use value - 1 with GREATER_THAN)

Watch for:

  • Consistency across the three metric pairs—verify all have the same builder configuration
  • The severity constant values (0, 5, 10, 15, 20, 25) and the quality gate guidance in the Javadoc are aligned
  • The @since 13.6 tags are correct

Integration note: These metrics expose severity distribution data rather than just counts; confirm this aligns with how SonarQube/SonarCloud will populate these metrics in practice.


  • Generate Walkthrough
  • Generate Diagram

🗣️ Give feedback

sonar-review-alpha[bot]

This comment was marked as resolved.

@OrlovAlexander85 OrlovAlexander85 requested a review from zipengwu May 6, 2026 07:14
@OrlovAlexander85 OrlovAlexander85 force-pushed the task/orlov/SC-47805/new-metrics branch from 52f7d4d to d8eba75 Compare May 6, 2026 12:27
sonar-review-alpha[bot]

This comment was marked as outdated.

@OrlovAlexander85 OrlovAlexander85 force-pushed the task/orlov/SC-47805/new-metrics branch from d8eba75 to c0d5ecb Compare May 6, 2026 12:43
Copy link
Copy Markdown

@sonar-review-alpha sonar-review-alpha Bot left a comment

Choose a reason for hiding this comment

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

Some previously flagged issues are still open.

🗣️ Give feedback

@sonarqube-next
Copy link
Copy Markdown

sonarqube-next Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

@antoine-vinot-sonarsource antoine-vinot-sonarsource left a comment

Choose a reason for hiding this comment

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

LGTM!

@OrlovAlexander85 OrlovAlexander85 merged commit ff33cbe into master May 7, 2026
12 checks passed
@OrlovAlexander85 OrlovAlexander85 deleted the task/orlov/SC-47805/new-metrics branch May 7, 2026 13:18
public static final int MEDIUM = 15;
public static final int HIGH = 20;
public static final int BLOCKER = 25;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This library is used in all our products, we need to add mapping with RuleSeverity and ImpactSeverity here.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants