Skip to main content
Glama

check_const_correctness

Analyze C++ code to identify missing const qualifiers and provide improvement suggestions for const correctness.

Instructions

检查 C++ 代码中的 const 正确性 参数: code: 要检查的 C++ 代码 返回: const 正确性检查报告,包括缺少 const 的地方和改进建议

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes

Implementation Reference

  • Core handler function that implements the logic for checking const correctness in C++ code. It orchestrates multiple specialized checks and generates a formatted report.
    def check_const_correctness(self, code: str) -> Tuple[List[Dict], str]: """ 检查代码中的 const 正确性 Args: code: 要检查的 C++ 代码 Returns: (问题列表, 格式化的检查报告) """ issues = [] # 检查各种 const 使用问题 issues.extend(self._check_member_functions(code)) issues.extend(self._check_parameters(code)) issues.extend(self._check_return_values(code)) issues.extend(self._check_variables(code)) issues.extend(self._check_pointers_refs(code)) # 生成报告 report = self._generate_report(issues) return issues, report
  • Registration of the MCP tool 'check_const_correctness' using the @mcp.tool() decorator. This wrapper function calls the core checker implementation.
    @mcp.tool() def check_const_correctness(code: str) -> str: """ 检查 C++ 代码中的 const 正确性 参数: code: 要检查的 C++ 代码 返回: const 正确性检查报告,包括缺少 const 的地方和改进建议 """ checker = get_const_checker() issues, report = checker.check_const_correctness(code) return report
  • Singleton factory function that provides the global ConstCorrectnessChecker instance used by the tool.
    # 全局实例 _checker = None def get_checker() -> ConstCorrectnessChecker: """获取全局 const 正确性检查器实例""" global _checker if _checker is None: _checker = ConstCorrectnessChecker() return _checker

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/SongJiangzhou/cpp_guidelines'

If you have feedback or need assistance with the MCP directory API, please join our Discord server