django-DefectDojo icon indicating copy to clipboard operation
django-DefectDojo copied to clipboard

Pre-Commit to update code with PEP8 standards

Open ajtortolero opened this issue 3 years ago • 2 comments

Be informative Add a mechanism to update code with PEP8 standars using tool pre-commit-hooks

Feature Description This feature include 6 hooks to help developers for identifying simple issues formatting with standars PEP8 before submission to code review.

Additional context In some cases developers will require manual intervention in formating code, but this tool help to reconize what files require this intervention.

Form example In project root folder run following command

pre-commit run --files dojo/tools/anchore_grype/*

Result of this process would be something like following

check yaml...........................................(no files to check)Skipped fix end of files.........................................................Passed trim trailing whitespace.................................................Passed check json...........................................(no files to check)Skipped python tests naming..................................(no files to check)Skipped don't commit to branch...................................................Passed black....................................................................Failed

  • hook id: black
  • files were modified by this hook

reformatted dojo/tools/anchore_grype/parser.py

All done! ✨ 🍰 ✨ 1 file reformatted, 1 file left unchanged.

autopep8.................................................................Passed bandit...................................................................Passed autoflake................................................................Passed flake8...................................................................Failed

  • hook id: flake8
  • exit code: 1

dojo/tools/anchore_grype/parser.py:21:121: E501 line too long (122 > 120 characters)

The output is indicating that the dojo/tools/anchore_grype/parser.py file has more than 120 characters on line 21.

This file was not modified by flake8 and requires manual intervention to comply with PEP8 standards.

ajtortolero avatar May 03 '23 07:05 ajtortolero

I guess this can be closed @mtesauro as I run flake8 always over the whole project before I push. This exact line is not reported to me if I run flake8.

manuel-sommer avatar Jan 29 '24 05:01 manuel-sommer

Agreed. We also recently added the ruff linter to our GHA so we have reasonable coverage for this situation.

mtesauro avatar Jan 29 '24 15:01 mtesauro