codehealthanalyzer 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. codehealthanalyzer-1.0.0/LICENSE +21 -0
  2. codehealthanalyzer-1.0.0/MANIFEST.in +18 -0
  3. codehealthanalyzer-1.0.0/PKG-INFO +406 -0
  4. codehealthanalyzer-1.0.0/README.md +355 -0
  5. codehealthanalyzer-1.0.0/codehealthanalyzer/__init__.py +101 -0
  6. codehealthanalyzer-1.0.0/codehealthanalyzer/analyzers/__init__.py +13 -0
  7. codehealthanalyzer-1.0.0/codehealthanalyzer/analyzers/errors.py +221 -0
  8. codehealthanalyzer-1.0.0/codehealthanalyzer/analyzers/templates.py +329 -0
  9. codehealthanalyzer-1.0.0/codehealthanalyzer/analyzers/violations.py +306 -0
  10. codehealthanalyzer-1.0.0/codehealthanalyzer/cli/__init__.py +9 -0
  11. codehealthanalyzer-1.0.0/codehealthanalyzer/cli/main.py +299 -0
  12. codehealthanalyzer-1.0.0/codehealthanalyzer/i18n.py +176 -0
  13. codehealthanalyzer-1.0.0/codehealthanalyzer/reports/__init__.py +10 -0
  14. codehealthanalyzer-1.0.0/codehealthanalyzer/reports/formatter.py +232 -0
  15. codehealthanalyzer-1.0.0/codehealthanalyzer/reports/generator.py +284 -0
  16. codehealthanalyzer-1.0.0/codehealthanalyzer/utils/__init__.py +11 -0
  17. codehealthanalyzer-1.0.0/codehealthanalyzer/utils/categorizer.py +267 -0
  18. codehealthanalyzer-1.0.0/codehealthanalyzer/utils/helpers.py +362 -0
  19. codehealthanalyzer-1.0.0/codehealthanalyzer/utils/validators.py +286 -0
  20. codehealthanalyzer-1.0.0/codehealthanalyzer.egg-info/PKG-INFO +406 -0
  21. codehealthanalyzer-1.0.0/codehealthanalyzer.egg-info/SOURCES.txt +29 -0
  22. codehealthanalyzer-1.0.0/codehealthanalyzer.egg-info/dependency_links.txt +1 -0
  23. codehealthanalyzer-1.0.0/codehealthanalyzer.egg-info/entry_points.txt +3 -0
  24. codehealthanalyzer-1.0.0/codehealthanalyzer.egg-info/requires.txt +14 -0
  25. codehealthanalyzer-1.0.0/codehealthanalyzer.egg-info/top_level.txt +1 -0
  26. codehealthanalyzer-1.0.0/example.py +153 -0
  27. codehealthanalyzer-1.0.0/locale/en/LC_MESSAGES/codehealthanalyzer.po +95 -0
  28. codehealthanalyzer-1.0.0/locale/pt_BR/LC_MESSAGES/codehealthanalyzer.po +95 -0
  29. codehealthanalyzer-1.0.0/requirements.txt +4 -0
  30. codehealthanalyzer-1.0.0/setup.cfg +4 -0
  31. codehealthanalyzer-1.0.0/setup.py +99 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Luarco Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,18 @@
1
+ # Include documentation and license files
2
+ include README.md
3
+ include LICENSE
4
+ include requirements.txt
5
+ include example.py
6
+
7
+ # Include package data
8
+ recursive-include codehealthanalyzer *.py
9
+ recursive-include codehealthanalyzer *.json
10
+ recursive-include codehealthanalyzer *.txt
11
+
12
+ # Exclude development and cache files
13
+ global-exclude __pycache__
14
+ global-exclude *.py[co]
15
+ global-exclude *.egg-info
16
+ global-exclude .git*
17
+ global-exclude .DS_Store
18
+ global-exclude *.log
@@ -0,0 +1,406 @@
1
+ Metadata-Version: 2.4
2
+ Name: codehealthanalyzer
3
+ Version: 1.0.0
4
+ Summary: Biblioteca Python para análise de qualidade e saúde de código
5
+ Home-page: https://github.com/imparcialista/codehealthanalyzer
6
+ Author: Luarco Team
7
+ Author-email: contato@luarco.com.br
8
+ Project-URL: Bug Reports, https://github.com/imparcialista/codehealthanalyzer/issues
9
+ Project-URL: Source, https://github.com/imparcialista/codehealthanalyzer
10
+ Project-URL: Documentation, https://codehealthanalyzer.readthedocs.io/
11
+ Keywords: code-quality,static-analysis,code-health,linting,python,html,css,javascript,ruff,analysis,metrics,reporting
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Topic :: Software Development :: Quality Assurance
15
+ Classifier: Topic :: Software Development :: Testing
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: ruff>=0.1.0
27
+ Requires-Dist: click>=8.0.0
28
+ Requires-Dist: rich>=12.0.0
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
31
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
32
+ Requires-Dist: black>=22.0.0; extra == "dev"
33
+ Requires-Dist: isort>=5.0.0; extra == "dev"
34
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
35
+ Provides-Extra: docs
36
+ Requires-Dist: sphinx>=5.0.0; extra == "docs"
37
+ Requires-Dist: sphinx-rtd-theme>=1.0.0; extra == "docs"
38
+ Dynamic: author
39
+ Dynamic: author-email
40
+ Dynamic: classifier
41
+ Dynamic: description
42
+ Dynamic: description-content-type
43
+ Dynamic: home-page
44
+ Dynamic: keywords
45
+ Dynamic: license-file
46
+ Dynamic: project-url
47
+ Dynamic: provides-extra
48
+ Dynamic: requires-dist
49
+ Dynamic: requires-python
50
+ Dynamic: summary
51
+
52
+ # 🔍 CodeHealthAnalyzer
53
+
54
+ > Uma biblioteca Python completa para análise de qualidade e saúde de código
55
+
56
+ 🇧🇷 Português | [🇺🇸 English](README_EN.md)
57
+
58
+ [![Python Version](https://img.shields.io/badge/python-3.8+-blue.svg)](https://python.org)
59
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
60
+ [![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
61
+
62
+ ## 🚀 Visão Geral
63
+
64
+ CodeHealthAnalyzer é uma biblioteca Python moderna e abrangente para análise de qualidade de código. Ela combina múltiplas ferramentas de análise em uma interface unificada, fornecendo insights detalhados sobre a saúde do seu código.
65
+
66
+ ### ✨ Principais Funcionalidades
67
+
68
+ - **🚨 Análise de Violações**: Detecta funções, classes e módulos que excedem limites de tamanho
69
+ - **🎨 Análise de Templates**: Identifica CSS/JS inline em templates HTML que podem ser extraídos
70
+ - **⚠️ Integração com Ruff**: Analisa erros de linting e os categoriza por prioridade
71
+ - **📊 Score de Qualidade**: Calcula um score de 0-100 baseado na saúde geral do código
72
+ - **🎯 Priorização Inteligente**: Sugere ações baseadas na criticidade dos problemas
73
+ - **📈 Relatórios Múltiplos**: Gera relatórios em JSON, HTML, Markdown e CSV
74
+ - **🖥️ CLI Amigável**: Interface de linha de comando completa e intuitiva
75
+ - **🔧 Altamente Configurável**: Personalize limites, regras e categorias
76
+
77
+ ## 📦 Instalação
78
+
79
+ ### Instalação via pip (recomendado)
80
+
81
+ ```bash
82
+ pip install codehealthanalyzer
83
+ ```
84
+
85
+ ### Instalação para desenvolvimento
86
+
87
+ ```bash
88
+ git clone https://github.com/imparcialista/codehealthanalyzer.git
89
+ cd codehealthanalyzer
90
+ pip install -e .
91
+ ```
92
+
93
+ ### Dependências
94
+
95
+ - Python 3.8+
96
+ - ruff >= 0.1.0
97
+ - click >= 8.0.0
98
+ - rich >= 12.0.0 (opcional, para saída colorida)
99
+
100
+ ## 🎯 Uso Rápido
101
+
102
+ ### CLI (Interface de Linha de Comando)
103
+
104
+ ```bash
105
+ # Análise completa do projeto atual
106
+ codehealthanalyzer analyze .
107
+
108
+ # Análise com saída em HTML
109
+ codehealthanalyzer analyze . --format html --output reports/
110
+
111
+ # Apenas score de qualidade
112
+ codehealthanalyzer score .
113
+
114
+ # Informações do projeto
115
+ codehealthanalyzer info .
116
+
117
+ # Análise específica de violações
118
+ codehealthanalyzer violations . --output violations.json
119
+ ```
120
+
121
+ ### API Python
122
+
123
+ ```python
124
+ from codehealthanalyzer import CodeAnalyzer
125
+
126
+ # Inicializa o analisador
127
+ analyzer = CodeAnalyzer('/path/to/project')
128
+
129
+ # Gera relatório completo
130
+ report = analyzer.generate_full_report(output_dir='reports/')
131
+
132
+ # Obtém score de qualidade
133
+ score = analyzer.get_quality_score()
134
+ print(f"Score de Qualidade: {score}/100")
135
+
136
+ # Análises individuais
137
+ violations = analyzer.analyze_violations()
138
+ templates = analyzer.analyze_templates()
139
+ errors = analyzer.analyze_errors()
140
+ ```
141
+
142
+ ## 📊 Exemplo de Saída
143
+
144
+ ```
145
+ 📊 RESUMO DA ANÁLISE
146
+ ==================================================
147
+ ✅ Score de Qualidade: 85/100 - Excelente!
148
+ 📁 Arquivos analisados: 124
149
+ ⚠️ Arquivos com violações: 8
150
+ 🎨 Templates: 15
151
+ 🔍 Erros Ruff: 0
152
+ 🔥 Issues de alta prioridade: 2
153
+
154
+ 🎯 PRIORIDADES DE AÇÃO:
155
+ 1. 🔴 Violações de Alta Prioridade (2)
156
+ 2. 🟡 Templates com Muito CSS/JS Inline (3)
157
+ ```
158
+
159
+ ## 🔧 Configuração
160
+
161
+ ### Arquivo de Configuração JSON
162
+
163
+ ```json
164
+ {
165
+ "limits": {
166
+ "python_function": {"yellow": 30, "red": 50},
167
+ "python_class": {"yellow": 300, "red": 500},
168
+ "python_module": {"yellow": 500, "red": 1000},
169
+ "html_template": {"yellow": 150, "red": 200},
170
+ "test_file": {"yellow": 400, "red": 600}
171
+ },
172
+ "target_dir": "src/",
173
+ "file_rules": {
174
+ "critical_files": ["main.py", "core.py"],
175
+ "skip_patterns": [".git", "__pycache__", "node_modules"]
176
+ }
177
+ }
178
+ ```
179
+
180
+ ### Uso com Configuração
181
+
182
+ ```bash
183
+ codehealthanalyzer analyze . --config config.json
184
+ ```
185
+
186
+ ```python
187
+ import json
188
+ from codehealthanalyzer import CodeAnalyzer
189
+
190
+ with open('config.json') as f:
191
+ config = json.load(f)
192
+
193
+ analyzer = CodeAnalyzer('/path/to/project', config)
194
+ ```
195
+
196
+ ## 📈 Tipos de Análise
197
+
198
+ ### 🚨 Análise de Violações
199
+
200
+ Detecta:
201
+ - Funções muito longas (> 50 linhas)
202
+ - Classes muito grandes (> 500 linhas)
203
+ - Módulos muito extensos (> 1000 linhas)
204
+ - Templates HTML muito longos (> 200 linhas)
205
+
206
+ ### 🎨 Análise de Templates
207
+
208
+ Identifica:
209
+ - CSS inline em atributos `style`
210
+ - JavaScript inline em eventos (`onclick`, etc.)
211
+ - Tags `<style>` com muito conteúdo
212
+ - Tags `<script>` com muito código
213
+
214
+ ### ⚠️ Análise de Erros
215
+
216
+ Integra com Ruff para detectar:
217
+ - Erros de sintaxe
218
+ - Problemas de estilo
219
+ - Imports não utilizados
220
+ - Variáveis não definidas
221
+ - Complexidade excessiva
222
+
223
+ ## 📊 Score de Qualidade
224
+
225
+ O score é calculado baseado em:
226
+ - **Violações de alta prioridade**: -10 pontos cada
227
+ - **Erros de linting**: -2 pontos cada
228
+ - **Templates problemáticos**: -5 pontos cada
229
+ - **Base**: 100 pontos
230
+
231
+ ### Interpretação
232
+ - **80-100**: 🟢 Excelente
233
+ - **60-79**: 🟡 Bom
234
+ - **0-59**: 🔴 Precisa melhorar
235
+
236
+ ## 🎯 Categorização Inteligente
237
+
238
+ ### Arquivos
239
+ - **Arquivo Crítico**: Arquivos essenciais do sistema
240
+ - **Views Admin**: Interfaces administrativas
241
+ - **Blueprint Crítico**: Rotas críticas da aplicação
242
+ - **Template Base**: Templates fundamentais
243
+
244
+ ### Prioridades
245
+ - **Alta**: Problemas que afetam funcionalidade
246
+ - **Média**: Problemas de manutenibilidade
247
+ - **Baixa**: Melhorias recomendadas
248
+
249
+ ## 📋 Formatos de Relatório
250
+
251
+ ### JSON
252
+ ```json
253
+ {
254
+ "metadata": {
255
+ "generated_at": "2024-01-15T10:30:00",
256
+ "generator": "CodeHealthAnalyzer v1.0.0"
257
+ },
258
+ "summary": {
259
+ "quality_score": 85,
260
+ "total_files": 124,
261
+ "violation_files": 8
262
+ },
263
+ "priorities": [...],
264
+ "violations": [...],
265
+ "templates": [...],
266
+ "errors": [...]
267
+ }
268
+ ```
269
+
270
+ ### HTML
271
+ Relatório interativo com gráficos e métricas visuais.
272
+
273
+ ### Markdown
274
+ Relatório em formato Markdown para documentação.
275
+
276
+ ### CSV
277
+ Dados tabulares para análise em planilhas.
278
+
279
+ ## 🛠️ API Avançada
280
+
281
+ ### Analisadores Individuais
282
+
283
+ ```python
284
+ from codehealthanalyzer.analyzers import (
285
+ ViolationsAnalyzer,
286
+ TemplatesAnalyzer,
287
+ ErrorsAnalyzer
288
+ )
289
+
290
+ # Análise específica de violações
291
+ violations_analyzer = ViolationsAnalyzer('/path/to/project')
292
+ violations_report = violations_analyzer.analyze()
293
+
294
+ # Análise específica de templates
295
+ templates_analyzer = TemplatesAnalyzer('/path/to/project')
296
+ templates_report = templates_analyzer.analyze()
297
+
298
+ # Análise específica de erros
299
+ errors_analyzer = ErrorsAnalyzer('/path/to/project')
300
+ errors_report = errors_analyzer.analyze()
301
+ ```
302
+
303
+ ### Geração de Relatórios
304
+
305
+ ```python
306
+ from codehealthanalyzer.reports import ReportGenerator, ReportFormatter
307
+
308
+ generator = ReportGenerator()
309
+ formatter = ReportFormatter()
310
+
311
+ # Gera relatório consolidado
312
+ full_report = generator.generate_full_report(
313
+ violations=violations_report,
314
+ templates=templates_report,
315
+ errors=errors_report,
316
+ output_dir='reports/'
317
+ )
318
+
319
+ # Converte para diferentes formatos
320
+ html_content = generator.generate_html_report(full_report, 'report.html')
321
+ markdown_content = formatter.to_markdown(full_report, 'report.md')
322
+ formatter.to_csv(full_report, 'report.csv')
323
+ ```
324
+
325
+ ### Utilitários
326
+
327
+ ```python
328
+ from codehealthanalyzer.utils import (
329
+ Categorizer,
330
+ PathValidator,
331
+ FileHelper,
332
+ ColorHelper
333
+ )
334
+
335
+ # Categorização
336
+ categorizer = Categorizer()
337
+ category = categorizer.categorize_file(Path('src/main.py'))
338
+ priority = categorizer.determine_priority('file', {'lines': 150, 'type': 'python'})
339
+
340
+ # Validação
341
+ validator = PathValidator()
342
+ is_valid = validator.is_python_project('/path/to/project')
343
+ project_info = validator.get_project_info('/path/to/project')
344
+
345
+ # Helpers
346
+ file_helper = FileHelper()
347
+ data = file_helper.read_json('config.json')
348
+ file_helper.write_json(data, 'output.json')
349
+
350
+ # Cores para terminal
351
+ print(ColorHelper.success("Sucesso!"))
352
+ print(ColorHelper.error("Erro!"))
353
+ print(ColorHelper.warning("Aviso!"))
354
+ ```
355
+
356
+ ## 🧪 Testes
357
+
358
+ ```bash
359
+ # Instala dependências de desenvolvimento
360
+ pip install -e ".[dev]"
361
+
362
+ # Executa testes
363
+ pytest
364
+
365
+ # Executa testes com cobertura
366
+ pytest --cov=codehealthanalyzer
367
+
368
+ # Executa linting
369
+ ruff check codehealthanalyzer/
370
+ black --check codehealthanalyzer/
371
+ ```
372
+
373
+ ## 🤝 Contribuição
374
+
375
+ 1. Fork o projeto
376
+ 2. Crie uma branch para sua feature (`git checkout -b feature/AmazingFeature`)
377
+ 3. Commit suas mudanças (`git commit -m 'Add some AmazingFeature'`)
378
+ 4. Push para a branch (`git push origin feature/AmazingFeature`)
379
+ 5. Abra um Pull Request
380
+
381
+ ### Diretrizes de Contribuição
382
+
383
+ - Siga o estilo de código existente
384
+ - Adicione testes para novas funcionalidades
385
+ - Atualize a documentação quando necessário
386
+ - Use commits semânticos
387
+
388
+ ## 📄 Licença
389
+
390
+ Este projeto está licenciado sob a Licença MIT - veja o arquivo [LICENSE](LICENSE) para detalhes.
391
+
392
+ ## 🙏 Agradecimentos
393
+
394
+ - [Ruff](https://github.com/astral-sh/ruff) - Linter Python ultrarrápido
395
+ - [Click](https://click.palletsprojects.com/) - Framework para CLI
396
+ - [Rich](https://github.com/Textualize/rich) - Formatação rica para terminal
397
+
398
+ ## 📞 Suporte
399
+
400
+ - 📧 Email: contato@luarco.com.br
401
+ - 🐛 Issues: [GitHub Issues](https://github.com/imparcialista/codehealthanalyzer/issues)
402
+ - 📖 Documentação: [ReadTheDocs](https://codehealthanalyzer.readthedocs.io/)
403
+
404
+ ---
405
+
406
+ **Feito com ❤️ pela equipe Imparcialista**