mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-02 16:02:15 +02:00
Let all linters run before failing
This commit is contained in:
parent
1de4debc3e
commit
c7265285a8
1 changed files with 12 additions and 2 deletions
|
@ -3,6 +3,10 @@ from subprocess import run, CalledProcessError # nosec
|
|||
from django.core.management.base import BaseCommand, CommandError
|
||||
|
||||
|
||||
class LinterError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
"""
|
||||
Helper command for running installed linters.
|
||||
|
@ -41,6 +45,7 @@ class Command(BaseCommand):
|
|||
|
||||
def handle(self, *args, **options):
|
||||
try:
|
||||
errors = []
|
||||
for linter in self.linters.values():
|
||||
self.stdout.write(f"[manage.py lint] {linter['purpose']}. . .")
|
||||
result = run(linter["args"])
|
||||
|
@ -51,12 +56,17 @@ class Command(BaseCommand):
|
|||
f"{' '.join(linter['args'])}"
|
||||
)
|
||||
)
|
||||
raise CalledProcessError(result.returncode, linter["args"])
|
||||
errors.append(CalledProcessError(result.returncode, linter["args"]))
|
||||
else:
|
||||
self.stdout.write(
|
||||
f"[manage.py lint] {linter['purpose']} completed with success!"
|
||||
)
|
||||
except CalledProcessError as e:
|
||||
if errors:
|
||||
self.stdout.write(
|
||||
f"[manage.py lint] {len(errors)} linter(s) failed."
|
||||
)
|
||||
raise LinterError(errors)
|
||||
except (CalledProcessError, LinterError) as e:
|
||||
raise CommandError(e)
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS("[manage.py lint] All linters ran successfully.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue