mcpField
C
code-checker

code-checker

github.com/openharmonyinsightTesting & quality3597 installsUpdated 11w ago
Repository

About code-checker

code-checker is a skill for developers assessing maintainability in C/C++ code. It scans for oversized files and functions and detects circular dependencies between directory modules.

Key features

  1. 01Analyze file and function size
  2. 02Detect circular dependencies between modules
  3. 03Parse include paths from GN build files
  4. 04Configure thresholds and save reports
  5. 05Provide refactoring references

Use cases

  1. 01Find oversized source files or functions
  2. 02Check for circular module includes
  3. 03Generate a code-check report

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill code-checker

After installing, type/code-checkerin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
circular-deps.md
refactoring.md
scripts/
circular_header_check.py
scan_cpp_size.py

Details

From the project README

C/C++ Code Checker

Analyzes C/C++ code for maintainability issues: extra large files/functions and circular dependencies between modules.

Workflow

  1. Identify scan target - If the user doesn't specify a file or directory, ask: "Which directory or file should I scan?"
  2. Determine check type - Ask or infer which checks to run:
    • File/Function size analysis
    • Circular dependency detection
    • Both (default for full analysis)
  3. Run the scan - Execute the appropriate script(s)
  4. Present findings - Show the report and summarize key issues
  5. Offer help - Ask if the user wants refactoring assistance

Size Analysis

Scan for extra large files and functions:

scripts/scan_cpp_size.py <path> [options]

Options:

  • -o, --output <file> - Write report to file
  • -f, --file-threshold <n> - Large file threshold (default: 2000 effective lines)
  • -F, --function-threshold <n> - Large function threshold (default: 50 effective lines)

Example:

scripts/scan_cpp_size.py ./src --file-threshold 1500 --function-threshold 40 -o size_report.md

Circular Dependency Detection

Detect circular dependencies between directory modules:

scripts/circular_header_check.py <path> [options]

Options:

  • -o, --output <file> - Write report to file
  • -v, --verbose - Verbose output
  • --no-gn - Skip GN build file parsing

Example:

scripts/circular_header_check.py ./src -o circular_report.md

The circular dependency checker:

  • Parses GN build files (BUILD.gn, *.gni) for include paths
  • Groups files by directory modules (handles src/ and include/ as one component)
  • Detects when module A includes files from module B, which includes A

After Finding Issues

When issues are found:

  1. Prioritize by impact - Start with the largest issues first
  2. Understand context - Read the code to understand responsibility
  3. Ask the user - "Would you like help refactoring this?"

Refactoring Guidance

Issue TypeReference
Large functionsreferences/refactoring.md
Circular dependenciesSee references/circular-deps.md

What Counts as "Large"?

CategoryDefault ThresholdRationale
Files2000 effective linesHard to navigate, understand
Functions50 effective linesBeyond cognitive fit, hard to test

Effective lines exclude blank lines, comments, and preprocessor directives.

File Extensions Scanned

.c, .cpp, .cc, .cxx, .c++, .h, .hpp, .hh, .hxx, .h++, .inl, .inc

Comments

Markdown supported