apache / apache/cloudstack

16 essential tools that can be run as wrappers for pre-commit, primarily targeting Python and Shell. Gemini can make mistakes, so double-check it

Abierto
#11,323 2 comentarios 1 reacción 0 asignados Ver en GitHub
long-term-plan
Lenguaje dominante
Java
Estrellas
3.1k
Forks
1.4k
Merge medio
6 d 19 h
PR fusionados (30 d)
32

Descripción

To enhance code quality, consistency, and catch common errors early in the development cycle, integrating pre-commit hooks into your workflow is incredibly effective. For projects that heavily utilize Python and Shell scripting, like many infrastructure or automation platforms, leveraging the right tools as `pre-commit` wrappers can significantly streamline development.

Here are the first 16 essential tools that can be run as wrappers for `pre-commit`, primarily targeting **Python** and **Shell** scripting:

---

### Python Specific Hooks

#### Formatters

- [ ] 1. **Black**: This uncompromising Python code formatter ensures your code adheres to a consistent style, making it highly readable and uniform across your codebase.
- [ ] 2. **Ruff (Formatter)**: An exceptionally fast Rust-powered formatter that's 100% compatible with Black. It's a fantastic choice for quickly standardizing your Python code's appearance.
- [ ] 3. **isort**: Automatically sorts your Python imports alphabetically and groups them into logical sections, cleaning up your import statements.
- [ ] 4. **autoflake**: A utility that intelligently removes unused imports and unused variables from your Python code, based on reports from Pyflakes.
- [ ] 5. **docformatter**: Formats Python docstrings to conform to PEP 257, ensuring consistent and readable documentation within your code.

#### Linters & Static Analysis

- [x] 6. **Flake8**: A versatile wrapper that combines PyFlakes (for basic syntax errors), pycodestyle (for PEP 8 compliance), and McCabe complexity checker (for code complexity).
- [ ] 7. **Ruff (Linter)**: A blazing-fast Python linter written in Rust. It can replace a multitude of other linters like Flake8, isort, pydocstyle, pyupgrade, and autoflake, offering significant speed advantages.
- [ ] 8. **Mypy**: A static type checker for Python. It helps catch type-related errors before runtime, improving code robustness and maintainability.
- [ ] 9. **Pylint**: A highly customizable and comprehensive Python linter that checks for errors, enforces coding standards, and identifies potential code smells.
- [ ] 10. **Bandit**: Focuses on security, designed to find common security issues in your Python code, helping to prevent vulnerabilities.
- [ ] 11. **Pyupgrade**: Automatically upgrades Python syntax to newer versions, such as converting older string formatting to f-strings or adding modern type hints.
- [ ] 12. **debug-statements**: Catches accidental `print()` statements, `pdb.set_trace()` calls, or `breakpoint()` calls that might be left in production code.
- [ ] 13. **check-ast**: Performs a simple check to ensure that your Python files can be parsed as valid Python code, catching basic syntax errors.

---

### Shell Script Specific Hooks

- [ ] 14. **ShellCheck**: A powerful static analysis tool for shell scripts (Bash, sh, ksh). It catches common syntax errors, logical flaws, and stylistic issues, making your scripts more reliable.
- [ ] 15. **bashate**: A dedicated code style enforcement tool specifically for Bash programs, commonly used in large-scale projects to maintain consistent scripting practices.
- [ ] 16. **shfmt**: An opinionated formatter for shell scripts that automatically formats your scripts according to a consistent style, improving readability.

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Empieza revisando la configuración de pre-commit existente en el repositorio y el elemento de Flake8 que está marcado actualmente. Evalúa las herramientas restantes de Python y Shell como wrappers de pre-commit y, a continuación, actualiza la configuración y la lista de comprobación para que los hooks seleccionados queden integrados y puedan utilizarse.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python, shell
Área
tooling
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.