Skip to content

feat: add support for cognitive complexity analysis in Python #237

@askpt

Description

@askpt

Summary

Add support for analyzing and displaying Cognitive Complexity metrics for Python files using the Visual Studio Code extension.

Motivation

Python is a widely used language in many codebases. Supporting Python will extend the practicality of this extension and address a key user need, as many teams want to measure cognitive complexity across multi-language projects.

Acceptance Criteria

  • Cognitive Complexity analysis is available for Python files (.py).
  • Accurate analysis based on SonarSource's Cognitive Complexity specification for Python syntax.
  • CodeLens overlays show complexity scores above each function/method in Python files, with proper color coding (green/yellow/red) based on user-configurable thresholds.
  • Configuration options (thresholds, enabling/disabling CodeLens, etc.) are updated to allow/disable analysis for Python, as is currently supported for C# and Go.
  • Tests are implemented for Python analysis logic.

Out of Scope

  • Refactoring or expanding other language support (non-Python-specific changes).

Additional Notes

  • Implementation should use Tree-sitter or equivalent robust parsing to ensure accurate metric calculation for Python code, similar to existing support for C# and Go.
  • Consider potential edge cases in Python (e.g., nested functions, comprehensions).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions