feat(lang): add C and C++ language support#2746
Conversation
Wire up tree-sitter-based C and C++ language implementations including tree-sitter dependencies, language registration, file type/extension mappings, protobuf enum mappings, and integration tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add test fixtures and test registration for C language support, mirroring the existing C++ test structure. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Coverage Impact - ubuntu-latest ⬆️ Merging this pull request will increase total coverage on Modified Files with Diff Coverage (3)
🤖 Increase coverage with AI coding...🚦 See full report on Qlty Cloud » 🛟 Help
|
|
Coverage Impact - macos-15 ⬆️ Merging this pull request will increase total coverage on Modified Files with Diff Coverage (3)
🤖 Increase coverage with AI coding...🚦 See full report on Qlty Cloud » 🛟 Help
|
There was a problem hiding this comment.
Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit at claude.ai/admin-settings/claude-code.
Once credits are available, reopen this pull request to trigger a review.
There was a problem hiding this comment.
Pull request overview
Adds first-class C and C++ support to qlty’s tree-sitter-based maintainability analysis pipeline, wiring language registration/config globs and providing CLI integration fixtures to exercise the end-to-end flow.
Changes:
- Introduce new
candcpplanguage implementations inqlty-analysisand register them inALL_LANGS. - Add workspace dependencies (
tree-sitter-c,tree-sitter-cpp) and protobuf/enum + default config mappings forc/cpp. - Add CLI integration fixtures and test registration for C and C++.
Reviewed changes
Copilot reviewed 28 out of 29 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
qlty-types/src/lib.rs |
Maps "c"/"cpp" string names to protobuf Language enums. |
qlty-config/default.toml |
Adds file_types and language glob mappings for C/C++. |
qlty-cli/tests/lang/cpp/basic.toml |
Adds a basic C++ CLI integration test case. |
qlty-cli/tests/lang/cpp/basic.in/Returns.cpp |
C++ fixture for return-statements behavior. |
qlty-cli/tests/lang/cpp/basic.in/parameters.cpp |
C++ fixture for parameter counting behavior. |
qlty-cli/tests/lang/cpp/basic.in/NestedControl.cpp |
C++ fixture for nested control-flow behavior. |
qlty-cli/tests/lang/cpp/basic.in/Identical.cpp |
C++ fixture for identical-code behavior. |
qlty-cli/tests/lang/cpp/basic.in/FunctionComplexity.cpp |
C++ fixture for function complexity behavior. |
qlty-cli/tests/lang/cpp/basic.in/FileComplexity.cpp |
C++ fixture for file complexity behavior. |
qlty-cli/tests/lang/cpp/basic.in/BooleanLogic.cpp |
C++ fixture for boolean-logic behavior. |
qlty-cli/tests/lang/cpp/basic.in/.qlty/qlty.toml |
Minimal per-fixture qlty config for C++ tests. |
qlty-cli/tests/lang/cpp/basic.in/.gitignore |
Ignores generated .qlty/ outputs in C++ fixtures. |
qlty-cli/tests/lang/c/basic.toml |
Adds a basic C CLI integration test case. |
qlty-cli/tests/lang/c/basic.in/returns.c |
C fixture for return-statements behavior. |
qlty-cli/tests/lang/c/basic.in/parameters.c |
C fixture for parameter counting behavior. |
qlty-cli/tests/lang/c/basic.in/nested_control.c |
C fixture for nested control-flow behavior. |
qlty-cli/tests/lang/c/basic.in/identical.c |
C fixture for identical-code behavior. |
qlty-cli/tests/lang/c/basic.in/function_complexity.c |
C fixture for function complexity behavior. |
qlty-cli/tests/lang/c/basic.in/file_complexity.c |
C fixture for file complexity behavior. |
qlty-cli/tests/lang/c/basic.in/boolean_logic.c |
C fixture for boolean-logic behavior. |
qlty-cli/tests/lang/c/basic.in/.qlty/qlty.toml |
Minimal per-fixture qlty config for C tests. |
qlty-cli/tests/lang/c/basic.in/.gitignore |
Ignores generated .qlty/ outputs in C fixtures. |
qlty-cli/tests/lang.rs |
Registers c_tests and cpp_tests in the CLI test suite. |
qlty-analysis/src/lang/cpp.rs |
Implements C++ AST node kinds + queries and identifier extraction via tree-sitter-cpp. |
qlty-analysis/src/lang/c.rs |
Implements C AST node kinds + queries and identifier extraction via tree-sitter-c. |
qlty-analysis/src/lang.rs |
Adds mod c; mod cpp; and registers them in ALL_LANGS. |
qlty-analysis/Cargo.toml |
Adds tree-sitter-c and tree-sitter-cpp workspace dependencies. |
Cargo.toml |
Adds workspace package versions for tree-sitter-c and tree-sitter-cpp. |
Cargo.lock |
Locks new tree-sitter C/C++ crates and their transitive deps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…tegration test snapshots
Fix missing else_nodes() for both C and C++ so else-if chains no longer
incorrectly inflate nesting depth and cognitive complexity. Fix
FUNCTION_DECLARATION_QUERY to match pointer-returning functions via
pointer_declarator alternative. Fix C++ call_identifiers returning
(Some("this"), name) for free functions. Move C++ constants to associated
constants and remove dead code. Add basic.stdout snapshot files so
integration tests verify actual analysis output.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ll tracking
Move *.h from C-only to C++ file_type/language globs since C++ grammar
is a superset and C headers still parse correctly, while C++ headers
were silently producing zero analysis. Fix call_identifiers to return
Some("this") for bare function calls (matching Python/C# pattern) so
LCOM correctly tracks implicit member calls. Add field_expression to
field_nodes so explicit this->x access is also visible to LCOM.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Follow-up fix:
|
PR #2746 (a56a8f3) merged C/C++ language support to main, touching the same shared registration files this branch modifies. Add a Prerequisites section noting the rebase onto origin/main and the published-crate grammar path confirmed by the C/C++ merge, and make c_tests/cpp_tests unconditional in the Task 3 completion gate now that they exist.

Summary
ALL_LANGS, file type/extension mappings, and protobuf enum mappingsTest plan
c_testsandcpp_testscargo checkpasses cleanly🤖 Generated with Claude Code