Skip to content

Conversation

barnabasdomozi
Copy link
Collaborator

  • Changed CppRecord parsing: we now also store an isLambda and context attribute
  • Changed CppServiceHandler::getProperties to display the new attributes
  • Added CLI options --cppmetrics-ignore-lambdas and --cppmetrics-ignore-nested-classes to skip C++ metrics calculations in those cases
  • These new CLI options are considered when calculating: lackOfCohesion, efferentTypeLevel, afferentTypeLevel

@barnabasdomozi barnabasdomozi force-pushed the cpp_metrics_nested_classes branch from c47ea96 to 12c72cd Compare June 25, 2025 13:54
@barnabasdomozi barnabasdomozi force-pushed the cpp_metrics_nested_classes branch from 12c72cd to f1a4546 Compare June 27, 2025 11:20
@mcserep mcserep added Kind: Enhancement 🌟 Plugin: C++ Issues related to the parsing and presentation of C++ projects. Plugin: Metrics Issues related to the code metrics plugin. labels Jul 8, 2025
@mcserep mcserep added this to the Upcoming Release milestone Jul 8, 2025
@mcserep mcserep added this to Roadmap Jul 8, 2025
@github-project-automation github-project-automation bot moved this to In progress in Roadmap Jul 8, 2025
@mcserep mcserep requested review from mcserep and Copilot July 8, 2025 02:23
Copy link
Contributor

@Copilot 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 introduces the ability to skip certain C++ metrics (lack of cohesion, efferent/afferent coupling) for lambdas and nested classes via two new CLI options. It updates the parser to record isLambda and declaration context, filters queries based on the new options, surfaces the new attributes in the service output, and adds corresponding test changes.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
plugins/cpp_metrics/parser/src/cppmetricsparser.cpp Added getCohesionRecordQuery, integrated option‐based filters, and registered two new CLI flags
plugins/cpp_metrics/parser/include/cppmetricsparser/cppmetricsparser.h Declared getCohesionRecordQuery and added required includes
plugins/cpp/service/src/cppservice.cpp Extended getProperties to include Lambda and Context fields
plugins/cpp/parser/src/clangastvisitor.h Populated CppRecord::isLambda and context based on parent DeclContext
plugins/cpp/model/include/model/cpprecord.h Added isLambda, Context enum, and getContextString()
plugins/cpp/test/src/cpppropertiesservicetest.cpp Updated expected properties to include Context
Comments suppressed due to low confidence (3)

plugins/cpp/service/src/cppservice.cpp:337

  • [nitpick] The property key "Lambda" is less descriptive compared to other boolean flags (e.g., "Abstract type", "POD type"). Consider renaming it to something like "Is Lambda" or "Lambda expression" for consistency and clarity.
            return_["Lambda"] = "true";

plugins/cpp/test/src/cpppropertiesservicetest.cpp:83

  • There are no tests verifying the new Lambda property when type.isLambda is true. Consider adding a test case that simulates a lambda record and checks for "Lambda" : "true" in the output map.
TEST_F(CppPropertiesServiceTest, ClassPropertiesTest)

plugins/cpp_metrics/parser/src/cppmetricsparser.cpp:717

  • [nitpick] The CLI option descriptions mention skipping specific metrics but could be clearer about all three metrics affected. Consider rephrasing to explicitly list or group the three metrics affected for both options.
      "Skip Efferent/Afferent Coupling, Lack of Cohesion C++ metrics calculations for lambdas.")

@@ -72,6 +85,18 @@ struct CppRecord : CppEntity

return ret;
}

std::string getContextString() const
Copy link
Preview

Copilot AI Jul 8, 2025

Choose a reason for hiding this comment

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

The switch in getContextString() covers all enum cases but has no default or final return, which can trigger a missing-return warning. Consider adding a default case or a return after the switch to handle unexpected values.

Copilot uses AI. Check for mistakes.

@mcserep
Copy link
Collaborator

mcserep commented Jul 8, 2025

Great work! 👏

@mcserep mcserep merged commit b4f435c into Ericsson:master Jul 8, 2025
10 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in Roadmap Jul 8, 2025
@barnabasdomozi barnabasdomozi deleted the cpp_metrics_nested_classes branch July 30, 2025 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Kind: Enhancement 🌟 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