Biblioteca Python para análise de qualidade e saúde de código
Project description
CodeHealthAnalyzer
Biblioteca Python para análise de saúde de código com foco em três frentes:
- violações de tamanho em módulos, classes, funções e templates
- CSS/JS inline em templates HTML
- erros de linting coletados via Ruff
O que a biblioteca entrega hoje
- API Python com
CodeAnalyzer,ViolationsAnalyzer,TemplatesAnalyzereErrorsAnalyzer - CLI com os comandos
analyze,violations,templates,errors,score,info,dashboard,formatelint - relatórios em
json,html,markdownecsv - dashboard FastAPI opcional com métricas agregadas
- contrato de relatório tipado e versão centralizada
Instalação
pip install codehealthanalyzer
Com dashboard:
pip install "codehealthanalyzer[web]"
Para desenvolvimento:
pip install -e ".[dev,web]"
Uso rápido
CLI
codehealthanalyzer analyze .
codehealthanalyzer analyze . --format all --output reports
codehealthanalyzer violations . --format csv
codehealthanalyzer templates . --config config.json
codehealthanalyzer errors . --no-json --format markdown
codehealthanalyzer dashboard .
API Python
from codehealthanalyzer import CodeAnalyzer
analyzer = CodeAnalyzer(".", config={"target_dir": ".", "templates_dir": ["templates"]})
report = analyzer.generate_full_report(output_dir="reports")
print(report["summary"]["quality_score"])
Configuração
Exemplo de config.json:
{
"limits": {
"python_function": { "yellow": 30, "red": 50 },
"python_class": { "yellow": 300, "red": 500 },
"python_module": { "yellow": 500, "red": 1000 },
"html_template": { "yellow": 150, "red": 200 },
"test_file": { "yellow": 400, "red": 600 }
},
"target_dir": ".",
"templates_dir": ["templates", "app/templates"],
"exclude_dirs": ["legacy", "vendor"],
"ruff_fix": false,
"no_default_excludes": false
}
Campos suportados:
limits: sobrescreve limites de tamanhotarget_dir: diretório analisado pelo Rufftemplates_dir: string ou lista de diretórios de templatesexclude_dirs: string ou lista de diretórios extras a ignorarruff_fix: rodaruff check --fixantes da coletano_default_excludes: desabilita as exclusões padrão
Contrato de relatório
O relatório consolidado sempre contém:
{
"metadata": {...},
"summary": {...},
"violations": {...},
"templates": {...},
"errors": {...},
"priorities": [...],
"quality_score": 0,
}
Os schemas tipados ficam em codehealthanalyzer/schemas.py.
Desenvolvimento
pytest -q
ruff check codehealthanalyzer tests
black --check codehealthanalyzer tests
isort --check-only codehealthanalyzer tests
Limitações atuais
- a análise de erros depende do executável
ruffestar disponível no ambiente - o dashboard mostra métricas agregadas, não histórico persistente completo
- a análise de templates é baseada em heurísticas simples de HTML e regex
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codehealthanalyzer-1.2.2.tar.gz.
File metadata
- Download URL: codehealthanalyzer-1.2.2.tar.gz
- Upload date:
- Size: 59.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d766bed1962ce37a5d5d48649ea959386e733b5107b42b37596435222bf3a38e
|
|
| MD5 |
18d9e148f17707c93d4b21af0b34537c
|
|
| BLAKE2b-256 |
d5f2766d898786bb365d70a1cc7e5e1dc3bc09ba3cd26e74aa4c3c395db04cf1
|
Provenance
The following attestation bundles were made for codehealthanalyzer-1.2.2.tar.gz:
Publisher:
python-publish.yml on imparcialista/codehealthanalyzer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codehealthanalyzer-1.2.2.tar.gz -
Subject digest:
d766bed1962ce37a5d5d48649ea959386e733b5107b42b37596435222bf3a38e - Sigstore transparency entry: 1291308404
- Sigstore integration time:
-
Permalink:
imparcialista/codehealthanalyzer@fa35fcfd98735bfe6b75fd285505b00ac1093b6b -
Branch / Tag:
refs/tags/v1.2.2 - Owner: https://github.com/imparcialista
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@fa35fcfd98735bfe6b75fd285505b00ac1093b6b -
Trigger Event:
push
-
Statement type:
File details
Details for the file codehealthanalyzer-1.2.2-py3-none-any.whl.
File metadata
- Download URL: codehealthanalyzer-1.2.2-py3-none-any.whl
- Upload date:
- Size: 50.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7cbb025a133e833266cfcdaf09d73eb3bcce8b2a2f03dbf7a669da358e5f19dc
|
|
| MD5 |
88d035e862a8e687060895a9a491a2b7
|
|
| BLAKE2b-256 |
26c620f0141a05565a2df195487bbf4598fc01d67dac0c7883b96966e3dfa970
|
Provenance
The following attestation bundles were made for codehealthanalyzer-1.2.2-py3-none-any.whl:
Publisher:
python-publish.yml on imparcialista/codehealthanalyzer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codehealthanalyzer-1.2.2-py3-none-any.whl -
Subject digest:
7cbb025a133e833266cfcdaf09d73eb3bcce8b2a2f03dbf7a669da358e5f19dc - Sigstore transparency entry: 1291308502
- Sigstore integration time:
-
Permalink:
imparcialista/codehealthanalyzer@fa35fcfd98735bfe6b75fd285505b00ac1093b6b -
Branch / Tag:
refs/tags/v1.2.2 - Owner: https://github.com/imparcialista
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@fa35fcfd98735bfe6b75fd285505b00ac1093b6b -
Trigger Event:
push
-
Statement type: