Skip to content

Comments

feat: add code complexity analysis#39

Merged
JaeAeich merged 1 commit intomainfrom
radon
Jan 8, 2025
Merged

feat: add code complexity analysis#39
JaeAeich merged 1 commit intomainfrom
radon

Conversation

@JaeAeich
Copy link
Collaborator

@JaeAeich JaeAeich commented Jan 3, 2025

Description

Use ruff and mccabe to check code complexity.

Checklist

  • My code follows the contributing guidelines of this
    project, including, in particular, with regard to any style guidelines
  • The title of my PR complies with the Conventional Commits
    specification
    ; in particular, it clearly indicates
    that a change is a breaking change
  • I acknowledge that all my commits will be squashed into a single commit,
    using the PR title as the commit message
  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have updated the user-facing documentation to describe any new or
    changed behavior
  • I have added type annotations for all function/class/method interfaces
    or updated existing ones (only for Python, TypeScript, etc.)
  • I have provided appropriate documentation (Google-style Python
    docstrings
    ) for all packages/modules/functions/classes/
    methods or updated existing ones
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature
    works
  • New and existing unit tests pass locally with my changes
  • I have not reduced the existing code coverage

Comments

Lets just move on before we find another noble gas named pypi package :).

Summary by Sourcery

Add code complexity analysis using xenon.

CI:

  • Add a CI job to check code complexity.

Tests:

  • Add code complexity thresholds.

Summary by Sourcery

Build:

  • Add mccabe to pyproject.toml.

@sourcery-ai
Copy link

sourcery-ai bot commented Jan 3, 2025

Reviewer's Guide by Sourcery

This pull request introduces code complexity analysis using xenon. It sets up a new GitHub Actions workflow to run xenon with specified complexity thresholds and adds a Makefile target for local execution.

State diagram for code complexity levels

stateDiagram-v2
    [*] --> ComplexityAnalysis

    state ComplexityAnalysis {
        state "Level A (1-10)" as A
        state "Level B (11-20)" as B
        state "Level C (21-30)" as C
        state "Level D (31-40)" as D
        state "Level E (41+)" as E

        A --> B : Increasing Complexity
        B --> C : Increasing Complexity
        C --> D : Increasing Complexity
        D --> E : Increasing Complexity

        note right of A : Ideal
        note right of B : Acceptable
        note right of C : Needs Refactoring
        note right of D : Immediate Attention
        note right of E : Critical
    }
Loading

File-Level Changes

Change Details Files
Added xenon to the project dependencies and updated the Makefile with targets for code complexity analysis.
  • Added xenon to the pyproject.toml file.
  • Added a code-complexity target to the Makefile to run xenon locally.
  • Added a shortcut cc target for the code-complexity target in the Makefile.
pyproject.toml
Makefile
Integrated xenon into the CI pipeline.
  • Added a new job complexity-check to the code_quality.yaml workflow.
  • The new job checks out the repository, sets up the environment using poetry, and runs xenon with the defined thresholds.
.github/workflows/code_quality.yaml

Assessment against linked issues

Issue Objective Addressed Explanation
#29 Incorporate code complexity analysis via a suitable tool
#29 Establish a threshold of complexity tolerance for code quality

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@JaeAeich JaeAeich requested a review from uniqueg January 3, 2025 15:45
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @JaeAeich - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Member

@uniqueg uniqueg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine, but please update the PR description before you merge.

@JaeAeich
Copy link
Collaborator Author

JaeAeich commented Jan 8, 2025

@sourcery-ai summary

@JaeAeich JaeAeich merged commit 16c0758 into main Jan 8, 2025
@JaeAeich JaeAeich deleted the radon branch January 8, 2025 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

imp: code complexity check

2 participants