|
4 | 4 |
|
5 | 5 | whitespace_rules: List[Rule] = [
|
6 | 6 | # This linter should be first since bash_rules depends on it.
|
7 |
| - {"pattern": r"\s+$", "strip": "\n", "description": "Fix trailing whitespace"}, |
8 |
| - {"pattern": "\t", "strip": "\n", "description": "Fix tab-based whitespace"}, |
| 7 | + {"pattern": r"[\t ]+$", "description": "Fix trailing whitespace"}, |
| 8 | + {"pattern": r"\t", "description": "Fix tab-based whitespace"}, |
9 | 9 | ]
|
10 | 10 |
|
11 | 11 | markdown_whitespace_rules = list(
|
12 |
| - rule for rule in whitespace_rules if rule["pattern"] != r"\s+$" |
| 12 | + rule for rule in whitespace_rules if rule["pattern"] != r"[\t ]+$" |
13 | 13 | ) + [
|
14 | 14 | # Two spaces trailing a line with other content is okay--it's a markdown line break.
|
15 | 15 | # This rule finds one space trailing a non-space, three or more trailing spaces, and
|
16 | 16 | # spaces on an empty line.
|
17 | 17 | {
|
18 |
| - "pattern": r"((?<!\s)\s$)|(\s\s\s+$)|(^\s+$)", |
19 |
| - "strip": "\n", |
| 18 | + "pattern": r"((?<![\t ])[\t ]$)|([\t ][\t ][\t ]+$)|(^[\t ]+$)", |
20 | 19 | "description": "Fix trailing whitespace",
|
21 | 20 | },
|
22 | 21 | {
|
23 | 22 | "pattern": r"^#+[A-Za-z0-9]",
|
24 |
| - "strip": "\n", |
25 | 23 | "description": "Missing space after # in heading",
|
26 | 24 | },
|
27 | 25 | ]
|
28 | 26 |
|
29 | 27 | python_rules = RuleList(
|
30 | 28 | langs=["py"],
|
31 | 29 | rules=[
|
32 |
| - {"pattern": r'".*"%\([a-z_].*\)?$', "description": 'Missing space around "%"'}, |
33 |
| - {"pattern": r"'.*'%\([a-z_].*\)?$", "description": 'Missing space around "%"'}, |
34 |
| - # This rule is constructed with + to avoid triggering on itself |
35 |
| - {"pattern": r" =" + r'[^ =>~"]', "description": 'Missing whitespace after "="'}, |
36 |
| - {"pattern": r'":\w[^"]*$', "description": 'Missing whitespace after ":"'}, |
37 |
| - {"pattern": r"':\w[^']*$", "description": 'Missing whitespace after ":"'}, |
38 |
| - {"pattern": r"^\s+[#]\w", "strip": "\n", "description": 'Missing whitespace after "#"'}, |
39 | 30 | {
|
40 | 31 | "pattern": r"assertEquals[(]",
|
41 | 32 | "description": "Use assertEqual, not assertEquals (which is deprecated).",
|
|
46 | 37 | "good_lines": ["def foo (self):"],
|
47 | 38 | "bad_lines": ["def foo(self: Any):"],
|
48 | 39 | },
|
49 |
| - {"pattern": r"== None", "description": "Use `is None` to check whether something is None"}, |
50 |
| - {"pattern": r"type:[(]", "description": 'Missing whitespace after ":" in type annotation'}, |
51 |
| - {"pattern": r"# type [(]", "description": "Missing : after type in type annotation"}, |
52 |
| - {"pattern": r"#type", "description": 'Missing whitespace after "#" in type annotation'}, |
53 |
| - {"pattern": r"if[(]", "description": "Missing space between if and ("}, |
54 |
| - {"pattern": r", [)]", "description": 'Unnecessary whitespace between "," and ")"'}, |
55 |
| - {"pattern": r"% [(]", "description": 'Unnecessary whitespace between "%" and "("'}, |
56 | 40 | # This next check could have false positives, but it seems pretty
|
57 | 41 | # rare; if we find any, they can be added to the exclude list for
|
58 | 42 | # this rule.
|
|
97 | 81 | },
|
98 | 82 | *whitespace_rules,
|
99 | 83 | ],
|
100 |
| - max_length=140, |
101 | 84 | )
|
102 | 85 |
|
103 | 86 | bash_rules = RuleList(
|
|
145 | 128 | },
|
146 | 129 | ]
|
147 | 130 |
|
148 |
| -markdown_docs_length_exclude = { |
149 |
| - "zulip_bots/zulip_bots/bots/converter/doc.md", |
150 |
| -} |
151 |
| - |
152 | 131 | markdown_rules = RuleList(
|
153 | 132 | langs=["md"],
|
154 | 133 | rules=[
|
|
159 | 138 | "description": "Linkified markdown URLs should use cleaner <http://example.com> syntax.",
|
160 | 139 | },
|
161 | 140 | ],
|
162 |
| - max_length=120, |
163 |
| - length_exclude=markdown_docs_length_exclude, |
164 | 141 | )
|
165 | 142 |
|
166 | 143 | txt_rules = RuleList(
|
|
0 commit comments