Closed Bug 1074315 Opened 10 years ago Closed 9 years ago

fix bin/flake8_lint.sh script to not try to lint files that don't exist

Categories

(Input Graveyard :: Code Quality, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: willkg, Assigned: lgp171188, Mentored)

Details

(Whiteboard: u=dev c=codequality p= s=input.2014q4)

We have a flake8 pre-commit hook that runs on all files that changes in a given commit. If the commit includes removing files, currently flake8 will die when trying to lint those files because they no longer exist. E.g.:

Linting...
fjord/flags/admin.py:1:1: E902 IOError: [Errno 2] No such file or directory: 'fjord/flags/admin.py'
fjord/flags/management/commands/__init__.py:1:1: E902 IOError: [Errno 2] No such file or directory: 'fjord/flags/management/commands/__init__.py'
fjord/flags/management/commands/trainabuse.py:1:1: E902 IOError: [Errno 2] No such file or directory: 'fjord/flags/management/commands/trainabuse.py'
fjord/flags/management/__init__.py:1:1: E902 IOError: [Errno 2] No such file or directory: 'fjord/flags/management/__init__.py'
fjord/flags/spicedham_utils.py:1:1: E902 IOError: [Errno 2] No such file or directory: 'fjord/flags/spicedham_utils.py'
fjord/flags/tasks.py:1:1: E902 IOError: [Errno 2] No such file or directory: 'fjord/flags/tasks.py'
fjord/flags/tests/__init__.py:1:1: E902 IOError: [Errno 2] No such file or directory: 'fjord/flags/tests/__init__.py'
fjord/flags/tests/test_model.py:1:1: E902 IOError: [Errno 2] No such file or directory: 'fjord/flags/tests/test_model.py'
fjord/flags/tests/test_tasks.py:1:1: E902 IOError: [Errno 2] No such file or directory: 'fjord/flags/tests/test_tasks.py'

Lint errors found. Please fix the above and retry.
Alternatively, run 'git commit --no-verify' to ignore lint errors.


This bug covers fixing the lint script so it doesn't try to lint files that were removed.
One way to fix this is to also see if the file exists in this loop:

https://github.com/mozilla/fjord/blob/master/bin/flake8_lint.sh#L34
This requires knowledge of bash. I'm pretty sure the easy fix suggested in comment #1 would work fine.

The script in question is bin/flake8_lint.sh. It needs to be fixed so that if you do something like this:

    bin/flake8_lint.sh missingfile.py

it doesn't kick up IOErrors.

Marking this as a mentored bug. If you're interested in working on it, comment here or ping willkg in #input on irc.mozilla.org.
Mentor: willkg
I think Mike fixed this in https://github.com/mozilla/kitsune/pull/2252

We should look at that.
Assigning.

PR: https://github.com/mozilla/fjord/pull/408

Landed in master: b6f30e1 [bug 1074315] Ignore deleted files for linting in pre-commit hook
Assignee: nobody → lgp171188
Whiteboard: u=dev c=codequality p= s=input.2014q4
This applies to dev infrastructure, so it doesn't need to be deployed. Marking as FIXED.

Thank you!
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Product: Input → Input Graveyard
You need to log in before you can comment on or make changes to this bug.