Skip to content

Conversation

@barnabasdomozi
Copy link
Collaborator

Previously, we calculated metrics for functions inside anonymous lambda objects. This has now been fixed.

@mcserep mcserep added Kind: Bug ⚠️ Kind: Refactor 🔃 Plugin: C++ Issues related to the parsing and presentation of C++ projects. Plugin: Metrics Issues related to the code metrics plugin. labels Dec 6, 2025
@mcserep mcserep added this to the Upcoming Release milestone Dec 6, 2025
@mcserep mcserep added this to Roadmap Dec 6, 2025
@github-project-automation github-project-automation bot moved this to In progress in Roadmap Dec 6, 2025
@mcserep mcserep requested review from Copilot and mcserep December 6, 2025 00:03
@mcserep mcserep changed the title Fix cppmetrics-ignore-lambdas flag Fix ignoring lambda expression in C++ plugin Dec 6, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 inLambdaObject field to CppFunction model 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 use CohesionCppRecordView for 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.

@barnabasdomozi barnabasdomozi force-pushed the fix_metrics_lambdas branch 2 times, most recently from 141df43 to 5f4af75 Compare December 8, 2025 17:38
Previously, we calculated metrics for functions inside
anonymous lambda objects. This has now been fixed.
Copy link
Collaborator

@mcserep mcserep left a comment

Choose a reason for hiding this comment

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

@barnabasdomozi Thanks for the requested explanations on the changes, LGTM! 🚀

@mcserep mcserep merged commit c7f9a24 into Ericsson:master Dec 18, 2025
10 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in Roadmap Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Kind: Bug ⚠️ Kind: Refactor 🔃 Plugin: C++ Issues related to the parsing and presentation of C++ projects. Plugin: Metrics Issues related to the code metrics plugin.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants