fosslight_dependency_scanner
fosslight_dependency_scanner copied to clipboard
Add Pre-Commit Hooks for Code Linting and Formatting
Is your feature request related to a problem? Please describe. I'm always frustrated when inconsistent code styles and formatting issues are committed to the repository. These inconsistencies can make the codebase harder to read and maintain. Additionally, they can lead to avoidable errors that could have been caught by automated linting tools.
Describe the solution you'd like I propose adding pre-commit hooks to our repository that will automatically run code linting and formatting tools before any commit is made. This will ensure that all code committed adheres to a consistent style and quality standard. Specifically, we can integrate tools like flake8 for Python linting, black for code formatting, isort for sorting imports, and autoflake for removing unused imports and variables.
Describe alternatives you've considered
- Manual Code Reviews: Relying on manual code reviews to catch linting and formatting issues, but this is time-consuming and prone to human error.
- Post-commit Checks: Implementing post-commit checks, but this means issues are only caught after the code is already in the repository, potentially affecting builds or deployments.
Additional context Adding pre-commit hooks will streamline our development process and improve overall code quality. It will also save time during code reviews, as reviewers can focus on logic and functionality rather than style issues. Below are some additional resources and examples of how to set up pre-commit hooks with flake8, black, isort, and autoflake: