SONAR-26742 Add new_ncloc (New Lines of Code) core metric#299
Draft
christoph-sachse-sonarsource wants to merge 1 commit into
Draft
SONAR-26742 Add new_ncloc (New Lines of Code) core metric#299christoph-sachse-sonarsource wants to merge 1 commit into
christoph-sachse-sonarsource wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Code Review ✅ ApprovedAdds the new_ncloc metric definition to CoreMetrics to provide an accurate measure of non-commenting lines of code in the New Code period. No issues found. OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.




What
Adds a new core metric
new_ncloc("New Lines of Code") toCoreMetrics— the New Code period analog ofncloc.Why
There is currently no "lines of code on new code" metric. As a stand-in, the UI often pairs
new_linesagainstncloc, but they don't measure the same thing:ncloccounts non-commenting lines of code (a line the analyzer considers code), soncloc ≤ lines.new_linescounts all changed lines in the New Code period — code, comments, and blanks.The result is the paradox that a project can report more
new_linesthan totalncloc.new_ncloc(changed lines that are also code lines) is the honest new-code counterpart ofnclocand lets the product stop overloadingnew_lines.What's in this PR
Only the metric definition in
CoreMetrics. This is the lowest-level, most-blocking change: the Compute Engine computation, Elasticsearch indexing, and web app all referenceCoreMetrics.NEW_NCLOC_KEY, so nothing downstream compiles until this is released.The attributes mirror
NEW_LINES(andNCLOC):INT,DIRECTION_WORST, non-qualitative,DOMAIN_SIZE,deleteHistoricalData(true). As a size measure it intentionally has nobestValue/optimizedBestValue(consistent withncloc/new_lines; settingoptimizedBestValuewould drop the measure on files with 0 new code lines, reintroducing the absent-vs-0 inconsistency this metric is meant to remove).No DB migration is needed: metrics are auto-registered from
CoreMetricsby reflection at server startup (RegisterMetrics).Sequencing (this PR blocks the rest)
sonar-plugin-apiand bumppluginApiVersionin the consumers.new_nclocin the Compute Engine —sonar-enterpriseandsonarcloud-cleancode(NewSizeMeasuresStep:ncloc_data ∩ changed lines).ProjectMeasuresIndexerIteratorinsonar-enterpriseandsonarcloud-core.sonarcloud-webapp(MetricKey, l10n, Measures → Size domain).Out of scope here and tracked separately: application/portfolio aggregation, ES range facet + project-search filtering, and the frontend rework that replaces
new_lineswhere it stands in as thencloccounterpart.Validation
CoreMetricsTestpasses; built locally against a JDK 11 toolchain.Ticket: SONAR-26742
🤖 Generated with Claude Code