{"id":19450935,"url":"https://github.com/sourcery-ai/sourcery-analytics","last_synced_at":"2025-04-25T03:32:11.370Z","repository":{"id":37864319,"uuid":"483360909","full_name":"sourcery-ai/sourcery-analytics","owner":"sourcery-ai","description":"`sourcery-analytics` is a command line tool and library for statically analyzing Python code quality.","archived":false,"fork":false,"pushed_at":"2024-05-28T22:03:49.000Z","size":10033,"stargazers_count":16,"open_issues_count":15,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-05-29T13:01:38.990Z","etag":null,"topics":["code-quality","python"],"latest_commit_sha":null,"homepage":"https://sourcery-analytics.sourcery.ai/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sourcery-ai.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-19T18:18:24.000Z","updated_at":"2024-06-03T22:57:08.419Z","dependencies_parsed_at":"2023-10-23T20:36:52.693Z","dependency_job_id":"849b950e-3910-44c8-8a4d-af7f033c595c","html_url":"https://github.com/sourcery-ai/sourcery-analytics","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcery-ai%2Fsourcery-analytics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcery-ai%2Fsourcery-analytics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcery-ai%2Fsourcery-analytics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcery-ai%2Fsourcery-analytics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sourcery-ai","download_url":"https://codeload.github.com/sourcery-ai/sourcery-analytics/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250748113,"owners_count":21480781,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-quality","python"],"created_at":"2024-11-10T16:39:38.772Z","updated_at":"2025-04-25T03:32:10.789Z","avatar_url":"https://github.com/sourcery-ai.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sourcery Analytics\n\n\u003ca href=\"https://pypi.org/project/sourcery-analytics/\"\u003e![PyPI](https://img.shields.io/pypi/v/sourcery-analytics)\u003c/a\u003e\n![build, test, and publish docs](https://github.com/sourcery-ai/sourcery-analytics/actions/workflows/on_push_main.yml/badge.svg)\n\u003ca href=\"https://github.com/psf/black\"\u003e![code style](https://img.shields.io/badge/code%20style-black-000000.svg)\u003c/a\u003e\n\u003ca href=\"https://sourcery-analytics.sourcery.ai/\"\u003e![docs](https://img.shields.io/badge/docs-github.io-green.svg)\u003c/a\u003e\n\n---\n\n`sourcery-analytics` is a command line tool and library for statically analyzing Python code quality.\n\nGet started by installing using `pip`:\n\n```shell\npip install sourcery-analytics\n```\n\nThis will install `sourcery-analytics` as a command-line tool.\n\nTo identify code quality issues:\n\n```shell\nsourcery-analytics assess path/to/file.py\n```\n\nExample:\n\n```shell\nsourcery-analytics assess sourcery_analytics/metrics\n```\n\n```\nsourcery_analytics/metrics/cyclomatic_complexity.py:47: error: working_memory of cyclomatic_complexity is 34 exceeding threshold of 20\nFound 1 errors.\n```\n\nTo analyze a single Python file, use the `analyze` subcommand:\n\n```shell\nsourcery-analytics analyze path/to/file.py\n```\n\nExample:\n\n```shell\nsourcery-analytics analyze sourcery_analytics/analysis.py\n```\n\n```\n┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓\n┃ Method                                      ┃ length ┃ cyclomatic_complexity ┃ cognitive_complexity ┃ working_memory ┃\n┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩\n│ sourcery_analytics.analysis.analyze         │      5 │                     1 │                    0 │              8 │\n│ sourcery_analytics.analysis.analyze_methods │      4 │                     1 │                    1 │             12 │\n└─────────────────────────────────────────────┴────────┴───────────────────────┴──────────────────────┴────────────────┘\n```\n\nAlternatively, import and run analysis using the library:\n\n```python\nfrom sourcery_analytics import analyze_methods\nsource = \"\"\"\n    def cast_spell(self, spell):\n        if self.power \u003c spell.power:\n            raise InsufficientPower\n        print(f\"{self.name} cast {spell.name}!\")\n\"\"\"\nanalyze_methods(source)\n# [{'method_qualname': '.cast_spell', 'method_length': 3, 'method_cyclomatic_complexity': 1, 'method_cognitive_complexity': 1, 'method_working_memory': 6}]\n```\n\nFor more, see the [docs](https://sourcery-analytics.sourcery.ai/).\n\n### Repoanalysis.com\nYou can see how hundreds of top projects measure across different code quality metrics and see how your priojects compare at [repoanalysis.com](https://repoanalysis.com/)\n\n### Developed by Sourcery\nSourcery Analytics was originally developed by the team at [Sourcery](https://sourcery.ai/?utm_source=sourcery-analytics). Sourcery is an automated coding assistant to help Python developers review and improve their code while they work. Sourcery has a built in library of 100+ core rules and you can extend it further to create custom rules for any scenario.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourcery-ai%2Fsourcery-analytics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsourcery-ai%2Fsourcery-analytics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourcery-ai%2Fsourcery-analytics/lists"}