{"id":18441546,"url":"https://github.com/zokis/functionlengthanalyzer","last_synced_at":"2025-04-14T17:56:16.455Z","repository":{"id":197318202,"uuid":"698437309","full_name":"zokis/FunctionLengthAnalyzer","owner":"zokis","description":"Analyze Python project or files to find large functions.","archived":false,"fork":false,"pushed_at":"2023-09-30T00:02:14.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-16T11:27:25.791Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zokis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-09-29T23:32:48.000Z","updated_at":"2023-09-29T23:34:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"12cc9656-8add-4059-9144-7389d1fbcfc7","html_url":"https://github.com/zokis/FunctionLengthAnalyzer","commit_stats":null,"previous_names":["zokis/functionlengthanalyzer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zokis%2FFunctionLengthAnalyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zokis%2FFunctionLengthAnalyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zokis%2FFunctionLengthAnalyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zokis%2FFunctionLengthAnalyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zokis","download_url":"https://codeload.github.com/zokis/FunctionLengthAnalyzer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248932657,"owners_count":21185365,"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":[],"created_at":"2024-11-06T06:38:20.149Z","updated_at":"2025-04-14T17:56:16.432Z","avatar_url":"https://github.com/zokis.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Function Length Analyzer\n\nFunction Length Analyzer is a Python tool that analyzes your Python project to find functions that are too long based on specified or default line limits. Functions exceeding a warning line limit are printed as warnings, and those exceeding an error line limit are printed as errors. The script walks through all Python files in a given directory, parses the AST (Abstract Syntax Tree) to identify functions, and calculates their lengths.\n\n## Features\n\n- Analyze single file or entire directory.\n- Set custom error and warning line limits.\n- Option to ignore test files.\n- Supports configuration from `pyproject.toml`.\n- Prints the result (warning/error) with the function name, file path, and lines count.\n  \n## Requirements\n\n- Python 3.6+\n  \nTo use the `toml` configuration, you need to install `toml`:\n```bash\npip install toml\n```\n\n## Installation\n\n\n\n## Usage\n\n### Command Line\n\nRun the script using the following command:\n\n```bash\npython function_length_analyzer [path...] [options]\n```\n\n#### Positional Arguments:\n\n- `path`: Path of the Python project or file to analyze. Accepts multiple paths.\n\n#### Options:\n\n- `--ignore_test`: Ignore files starting with 'test_'.\n- `--line_limit \u003cint\u003e`: Set the line limit error for functions. Default is from config or 60.\n- `--warning_line_limit \u003cint\u003e`: Set the line limit warning for functions. Default is from config or 50.\n- `--disable_output \u003cbool\u003e`: Enable or disable output.\n\n### Configuration File\n\nYou can use a `pyproject.toml` file to configure the Function Length Analyzer. Here is an example configuration:\n\n```toml\n[tool.FunctionLengthAnalyzer]\nerror_line_limit = 80\nwarning_line_limit = 60\nenable_output = true\nignore_directories = [\".git\", \".venv\", \"node_modules\"]\nignore_files = [\"conftest.py\", \"fixtures.py\"]\n```\n\nIn the absence of a `pyproject.toml` file, the script uses the following default configuration:\n\n```python\nDEFAULT_CONFIG = {\n    \"error_line_limit\": 60,\n    \"warning_line_limit\": 50,\n    \"enable_output\": True,\n    \"ignore_directories\": [\".git\", \".venv\", \"node_modules\"],\n    \"ignore_files\": [\"conftest.py\", \"fixtures.py\"],\n}\n```\n\n## Example\n\n```bash\npython function_length_analyzer.py ./myproject --ignore_test --line_limit 80 --warning_line_limit 40\n```\n\nThis command will analyze all Python files in `./myproject`, ignoring test files, with a warning limit of 40 lines and an error limit of 80 lines.\n\n## Exit Status\n\nThe script exits with a status of `1` if any function exceeds the error line limit, allowing it to be used in CI/CD pipelines to enforce function length constraints.\n\n## License\n\nFeel free to use, modify, and distribute this script as you see fit.\n\n## Contributing\n\nIf you have suggestions for improving the script, please create an issue or a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzokis%2Ffunctionlengthanalyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzokis%2Ffunctionlengthanalyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzokis%2Ffunctionlengthanalyzer/lists"}