Skip to content

Commit

Permalink
Remove whitelist_errors.
Browse files Browse the repository at this point in the history
This simplifies the code flow, gets rid of a global variable. It might even be
slightly faster, as it doesn't need to check the global variable, and call
through another closure.
  • Loading branch information
Ms2ger committed May 8, 2016
1 parent 8095bbd commit 9a8cbfc
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions lint/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,6 @@ def filter_whitelist_errors(data, path, errors):

return [item for i, item in enumerate(errors) if not whitelisted[i]]


_whitelist_fn = None
def whitelist_errors(path, errors):
global _whitelist_fn

if _whitelist_fn is None:
data = parse_whitelist_file(os.path.join(repo_root, "lint.whitelist"))

def inner(path, errors):
return filter_whitelist_errors(data, path, errors)

_whitelist_fn = inner
return _whitelist_fn(path, errors)

class Regexp(object):
pattern = None
file_extensions = None
Expand Down Expand Up @@ -281,8 +267,10 @@ def lint(paths):
error_count = defaultdict(int)
last = None

whitelist = parse_whitelist_file(os.path.join(repo_root, "lint.whitelist"))

def run_lint(path, fn, last, *args):
errors = whitelist_errors(path, fn(path, *args))
errors = filter_whitelist_errors(whitelist, path, fn(path, *args))
if errors:
last = (errors[-1][0], path)

Expand Down

0 comments on commit 9a8cbfc

Please sign in to comment.