|
57 | 57 | # We check for and disallow any comments linking to the single-page HTML spec because it takes a long time to load. |
58 | 58 | SINGLE_PAGE_HTML_SPEC_LINK = re.compile("//.*https://html\\.spec\\.whatwg\\.org/#") |
59 | 59 |
|
| 60 | +# We similarily check and disallow AD-HOCs and FIXMEs that aren't followed by a colon. |
| 61 | +INVALID_AD_HOC_OR_FIXME = re.compile(r'^(?:[\s\d./\-(*]+(?:AD-HOC|FIXME)[^:]|.*"FIXME[^:"]).*$', re.MULTILINE) |
| 62 | + |
60 | 63 |
|
61 | 64 | def should_check_file(filename): |
62 | 65 | if not filename.endswith(".cpp") and not filename.endswith(".h"): |
@@ -97,6 +100,7 @@ def run(): |
97 | 100 | errors_include_missing_local = [] |
98 | 101 | errors_include_bad_complex = [] |
99 | 102 | errors_single_page_html_spec = [] |
| 103 | + errors_invalid_ad_hoc_or_fixme = {} |
100 | 104 |
|
101 | 105 | for filename in find_files_here_or_argv(): |
102 | 106 | with open(filename, mode="r", encoding="utf-8") as f: |
@@ -146,6 +150,9 @@ def run(): |
146 | 150 | errors_include_missing_local.append(filename) |
147 | 151 | if SINGLE_PAGE_HTML_SPEC_LINK.search(file_content): |
148 | 152 | errors_single_page_html_spec.append(filename) |
| 153 | + invalid_ad_hocs_or_fixmes = INVALID_AD_HOC_OR_FIXME.findall(file_content) |
| 154 | + if invalid_ad_hocs_or_fixmes: |
| 155 | + errors_invalid_ad_hoc_or_fixme[filename] = invalid_ad_hocs_or_fixmes |
149 | 156 |
|
150 | 157 | have_errors = False |
151 | 158 | if errors_license: |
@@ -184,6 +191,10 @@ def run(): |
184 | 191 | if errors_single_page_html_spec: |
185 | 192 | print("Files with links to the single-page HTML spec:", " ".join(errors_single_page_html_spec)) |
186 | 193 | have_errors = True |
| 194 | + if errors_invalid_ad_hoc_or_fixme: |
| 195 | + for file in errors_invalid_ad_hoc_or_fixme: |
| 196 | + print(f"{file} contains invalid AD-HOC or FIXME usages:", "".join(errors_invalid_ad_hoc_or_fixme[file])) |
| 197 | + have_errors = True |
187 | 198 |
|
188 | 199 | if have_errors: |
189 | 200 | sys.exit(1) |
|
0 commit comments