This repository uses Radon and Xenon to analyze code complexity and maintainability. These tools help ensure your code is readable, maintainable, and within specified complexity limits.
- Radon for cyclomatic complexity (CC) and maintainability index (MI).
- Xenon for enforcing complexity thresholds.
- Runs checks both locally and in CI/CD pipelines with GitHub Actions.
👀 How to fix your Python code with Radon & Xenon before it's too late
Requirements: python >= 3.9 & pip
- Install Dependencies:
pip install radon xenon
- Cyclomatic Complexity (CC) Check:
radon cc ./ -s
- Maintainability Index (MI) Check:
radon mi ./
- Xenon Complexity Enforcement:
xenon --max-absolute B ./
This is how the result should look like:
Requirements: Docker Desktop
docker build -t code-quality-checker .
docker run -t code-quality-checker
Requirements: Github repo
This repository includes a GitHub Actions workflow that automatically checks the code quality when a pull request is opened or updated on the main branch.
GitHub Actions Workflow .github/workflows/code-quality.yml
Once the checks are completed, you'll see the results directly in the GitHub pull request under the "Checks" tab.
There's a sample pull request to check the outcome.
Cursor is an AI-powered code editor that can help you fix your code by adding comments, suggestions, and even whole functions and classes.
You can paste the code into Cursor and it will give you a summary of the code and suggestions on how to improve it. There are some screenshots on this repo for you to check how it works.
- Get tips, learnings and tricks for your Data career!
- Join the Substack newsletter to get similar content to this one and more to improve your Data career!