-
Notifications
You must be signed in to change notification settings - Fork 234
Improve process label linting #2227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
46fcedf
7849dcc
2915f2e
c57dbf3
556e100
38b5603
c5b3e4d
ee0b95b
d593f86
18b6d1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -236,25 +236,53 @@ def check_process_section(self, lines, fix_version, progress_bar): | |
|
|
||
| # Check that process labels are correct | ||
| correct_process_labels = ["process_single", "process_low", "process_medium", "process_high", "process_long"] | ||
| process_label = [l for l in lines if l.lstrip().startswith("label")] | ||
| if len(process_label) > 0: | ||
| try: | ||
| process_label = re.search("process_[A-Za-z]+", process_label[0]).group(0) | ||
| except AttributeError: | ||
| process_label = re.search("'([A-Za-z_-]+)'", process_label[0]).group(0) | ||
| finally: | ||
| if not process_label in correct_process_labels: | ||
| all_labels = [l for l in lines if l.lstrip().startswith("label ")] | ||
|
||
| bad_labels = [] | ||
awgymer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| good_labels = [] | ||
| if len(all_labels) > 0: | ||
| for label in all_labels: | ||
| try: | ||
| label = re.match("^label\s+([a-zA-Z0-9_-]+)", label).group(1) | ||
| except AttributeError: | ||
| self.warned.append( | ||
| ( | ||
| "process_standard_label", | ||
| f"Process label ({process_label}) is not among standard labels: `{'`,`'.join(correct_process_labels)}`", | ||
| f"Specified label appears to contain non-alphanumerics: {label}", | ||
| self.main_nf, | ||
| ) | ||
| ) | ||
| continue | ||
| if label not in correct_process_labels: | ||
| bad_labels.append(label) | ||
| else: | ||
| self.passed.append(("process_standard_label", "Correct process label", self.main_nf)) | ||
| good_labels.append(label) | ||
| if len(good_labels) > 1: | ||
| self.warned.append( | ||
| ( | ||
| "process_standard_label", | ||
| f"Conflicting process labels found: `{'`,`'.join(good_labels)}`", | ||
| self.main_nf, | ||
| ) | ||
| ) | ||
| elif len(good_labels) == 1: | ||
| self.passed.append(("process_standard_label", "Correct process label", self.main_nf)) | ||
| else: | ||
| self.warned.append(("process_standard_label", "Standard process label not found", self.main_nf)) | ||
| if len(bad_labels) > 0: | ||
| self.warned.append( | ||
| ("process_standard_label", f"Non-standard labels found: `{'`,`'.join(good_labels)}`", self.main_nf) | ||
| ) | ||
| if len(all_labels) > len(set(all_labels)): | ||
| self.warned.append( | ||
| ( | ||
| "process_standard_label", | ||
| f"Duplicate labels found: `{'`,`'.join(sorted(all_labels))}`", | ||
| self.main_nf, | ||
| ) | ||
| ) | ||
|
|
||
| else: | ||
| self.warned.append(("process_standard_label", "Process label unspecified", self.main_nf)) | ||
| self.warned.append(("process_standard_label", "Process label not specified", self.main_nf)) | ||
| for i, l in enumerate(lines): | ||
| url = None | ||
| l = l.strip(" '\"") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.