Skip to content

Conversation

mcserep
Copy link
Collaborator

@mcserep mcserep commented Jul 25, 2025

#801 improved the performance for Lack of Cohesion metric, by refactoring 3 level nested query loop to 2 level.

However, SQLite has a fixed-size recursive descent parser, and each logical operator (like OR) adds a level to the parser's stack. Constructing queries with many ORs can lead to a stack overflow.

@mcserep mcserep added Kind: Refactor 🔃 Plugin: C++ Issues related to the parsing and presentation of C++ projects. Plugin: Metrics Issues related to the code metrics plugin. Kind: Bug ⚠️ labels Jul 25, 2025
@mcserep mcserep added this to Roadmap Jul 25, 2025
@mcserep mcserep added this to the Upcoming Release milestone Jul 25, 2025
@github-project-automation github-project-automation bot moved this to In progress in Roadmap Jul 25, 2025
@mcserep mcserep self-assigned this Jul 25, 2025
@mcserep mcserep requested a review from Copilot July 25, 2025 08:39
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 addresses SQLite's recursive descent parser limitation by implementing conditional compilation to handle large OR queries that can cause stack overflow. The change splits the Lack of Cohesion metric calculation into two approaches: a safer iterative approach for SQLite and an optimized query-based approach for more robust database engines.

  • Added conditional compilation (#ifdef DATABASE_SQLITE) to use different query strategies based on database type
  • Moved field counting outside the conditional blocks for code reuse
  • Implemented a simpler query approach for SQLite that avoids constructing queries with many OR statements
Comments suppressed due to low confidence (1)

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

  • The fieldCount variable declaration was moved outside the conditional blocks but is still being removed from the non-SQLite branch. This creates duplicate variable declarations since fieldCount is now declared at line 318. Remove this duplicate declaration.
        // Counter variables.

@mcserep mcserep merged commit d5c6671 into Ericsson:master Jul 25, 2025
8 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in Roadmap Jul 25, 2025
@mcserep mcserep deleted the lackofcohesion-sqlite branch July 26, 2025 06:56
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.

1 participant