lint: Move shebang_rules out of RuleList class to generalize it.

shebang_rules was moved to custom_check.py. Also add shebang_rules only
to those rules which need it.
This commit is contained in:
Aman Agrawal
2019-06-12 22:07:03 +05:30
committed by Tim Abbott
parent db25c0c2ca
commit dcd46f1c11
2 changed files with 20 additions and 15 deletions

View File

@@ -54,6 +54,20 @@ FILES_WITH_LEGACY_SUBJECT = {
'zerver/tests/test_narrow.py',
}
shebang_rules = [
{'pattern': '^#!',
'description': "zerver library code shouldn't have a shebang line.",
'include_only': set(['zerver/'])},
# /bin/sh and /usr/bin/env are the only two binaries
# that NixOS provides at a fixed path (outside a
# buildFHSUserEnv sandbox).
{'pattern': '^#!(?! *(?:/usr/bin/env|/bin/sh)(?: |$))',
'description': "Use `#!/usr/bin/env foo` instead of `#!/path/foo`"
" for interpreters other than sh."},
{'pattern': '^#!/usr/bin/env python$',
'description': "Use `#!/usr/bin/env python3` instead of `#!/usr/bin/env python`."}
] # type: Rule
trailing_whitespace_rule = {
'pattern': r'\s+$',
'strip': '\n',
@@ -505,6 +519,7 @@ python_rules = RuleList(
},
]) + whitespace_rules + comma_whitespace_rule,
max_length=110,
shebang_rules=shebang_rules,
)
bash_rules = RuleList(
@@ -521,6 +536,7 @@ bash_rules = RuleList(
'scripts/setup/configure-rabbitmq'
]), },
]) + whitespace_rules[0:1],
shebang_rules=shebang_rules,
)
css_rules = RuleList(