Fix ignoring lambda expression in C++ plugin#816
Merged
mcserep merged 1 commit intoEricsson:masterfrom Dec 18, 2025
Merged
Conversation
a5a5b30 to
fbd2cdf
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the cppmetrics-ignore-lambdas flag to properly exclude functions inside lambda objects from metrics calculations. Previously, function-level metrics (McCabe complexity and Bumpy Road) were incorrectly calculated for functions inside anonymous lambda objects.
Key changes:
- Added
inLambdaObjectfield toCppFunctionmodel to track if a function is inside a lambda - Introduced
getFunctionQuery()template method to apply lambda filtering when the flag is set - Refactored
typeMcCabe()to useCohesionCppRecordViewfor more consistent type querying
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
plugins/cpp/model/include/model/cppfunction.h |
Added inLambdaObject boolean field to track lambda membership |
plugins/cpp/parser/src/clangastvisitor.h |
Set inLambdaObject flag when parsing method declarations inside lambda classes |
plugins/cpp_metrics/parser/include/cppmetricsparser/cppmetricsparser.h |
Added getFunctionQuery() template to filter lambda functions based on configuration |
plugins/cpp_metrics/parser/src/cppmetricsparser.cpp |
Applied getFunctionQuery() to functionMcCabe() and functionBumpyRoad(), refactored typeMcCabe() to use CohesionCppRecordView |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
plugins/cpp_metrics/parser/include/cppmetricsparser/cppmetricsparser.h
Outdated
Show resolved
Hide resolved
mcserep
reviewed
Dec 6, 2025
mcserep
reviewed
Dec 6, 2025
mcserep
reviewed
Dec 6, 2025
141df43 to
5f4af75
Compare
Previously, we calculated metrics for functions inside anonymous lambda objects. This has now been fixed.
5f4af75 to
0a2ae4d
Compare
mcserep
approved these changes
Dec 18, 2025
Collaborator
mcserep
left a comment
There was a problem hiding this comment.
@barnabasdomozi Thanks for the requested explanations on the changes, LGTM! 🚀
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.
Previously, we calculated metrics for functions inside anonymous lambda objects. This has now been fixed.