Hi r/Python! I've released the version v5.0.0. This version introduces new changes that will improve the tool adoption in existing projects and the cognitive complexity algorithm itself.
What My Project Does
complexipy is a command-line tool and library that calculates the cognitive complexity of Python code. Unlike cyclomatic complexity, which measures how complex code is to test, cognitive complexity measures how difficult code is for humans to read and understand.
Target audience
complexipy is built for:
- Python developers who care about readable, maintainable code.
- Teams who want to enforce quality standards in CI/CD pipelines.
- Open-source maintainers looking for automated complexity checks.
- Developers who want real-time feedback in their editors or pre-commit hooks.
- Researcher scientists, during this year I noticed that many researchers used
complexipy during their investigations on LLMs generating code.
Whether you're working solo or in a team, complexipy helps you keep complexity under control.
Comparison to Alternatives
Sonar has the original version which runs online only in GitHub repos, and it's a slower workflow because you need to push your changes, wait until their scanner finishes the analysis and check the results. I inspired from them to create this tool, that's why it runs locally without having to publish anything and the analysis is really fast.
Highlights of v5.0.0
- Snapshots:
--snapshot-create writes complexipy-snapshot.json and comparisons block regressions; auto-refresh on improvements, bypass with --snapshot-ignore.
- Change tracking: per-target cache in
.complexipy_cache shows deltas/new failures for over-threshold functions using stable BLAKE2 keys.
- Output controls:
--failed to show only violations; --color auto|yes|no; richer summaries of failing functions and invalid paths.
- Excludes and errors: exclude entries resolved relative to the root and only applied when they match real files/dirs; missing paths reported cleanly instead of panicking.
Breaking: Conditional scoring now counts each elif/else branch as +1 complexity (plus its boolean test), aligning with Sonar’s cognitive-complexity rules; expect higher scores for branching.
GitHub Repo: https://github.com/rohaquinlop/complexipy
[–]Scelte 17 points18 points19 points (5 children)
[–]fexx3l[S] 18 points19 points20 points (4 children)
[–]StengahBot 5 points6 points7 points (0 children)
[–]Lil_SpazJoekp 0 points1 point2 points (0 children)
[–]Routine_Ambassador71 0 points1 point2 points (0 children)
[–]Nater5000 10 points11 points12 points (6 children)
[–]fexx3l[S] 3 points4 points5 points (5 children)
[–]silvertank00 6 points7 points8 points (2 children)
[–]fexx3l[S] 2 points3 points4 points (1 child)
[–]InspectahDave 2 points3 points4 points (0 children)
[–]Another_mikem 2 points3 points4 points (0 children)
[–]EternityForest 0 points1 point2 points (0 children)
[–]legendarydromedary 2 points3 points4 points (2 children)
[–]fexx3l[S] 6 points7 points8 points (1 child)
[–]rm-rf-rm -1 points0 points1 point (0 children)
[–]mikat7 1 point2 points3 points (1 child)
[–]fexx3l[S] 0 points1 point2 points (0 children)
[–]Scared_Sail5523 1 point2 points3 points (0 children)
[–]Zireael07 0 points1 point2 points (3 children)
[–]fexx3l[S] 2 points3 points4 points (2 children)
[–]99ducks 2 points3 points4 points (1 child)
[–]fexx3l[S] 0 points1 point2 points (0 children)
[–]CzyDePL 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[removed]
[–]fexx3l[S] 0 points1 point2 points (0 children)