Skip to content

Commit e5ec63b

Browse files
authored
Merge pull request #3541 from toniher/addressing-3530
Linting: Addressing more cases than can happen when processing input and output values
2 parents bf71309 + 622ace0 commit e5ec63b

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- Fix default linting of nf-core components when `nf-core pipelines lint` is ran ([#3480](https://github.com/nf-core/tools/pull/3480))
2424
- Fix the unexpected warning and sychronize the `README.md` and `RO-crate-metadata.json` ([#3493](https://github.com/nf-core/tools/pull/3493))
2525
- Adapt the linter to the new notation used to include the centralized nf-core configs ([#3491](https://github.com/nf-core/tools/pull/3491))
26+
- Addressing more cases than can happen when processing input and output values ([#3541](https://github.com/nf-core/tools/pull/3541))
2627

2728
### Modules
2829

nf_core/components/nfcore_component.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,10 @@ def get_inputs_from_main_nf(self) -> None:
216216
elif match.group(4):
217217
input_val = match.group(4).split(",")[0] # handle `files, stageAs: "inputs/*"` cases
218218
if input_val:
219-
input_val = re.sub(r"\s*\,\s*arity\s*\:\s*\w+\s*", "", input_val).strip() # remove arity
220-
input_val = input_val.strip("'").strip('"') # remove quotes
219+
input_val = re.split(r',(?=(?:[^\'"]*[\'"][^\'"]*[\'"])*[^\'"]*$)', input_val)[
220+
0
221+
] # Takes only first part, avoid commas in quotes
222+
input_val = input_val.strip().strip("'").strip('"') # remove quotes and whitespaces
221223
channel_elements.append({input_val: {}})
222224
if len(channel_elements) > 0:
223225
inputs.append(channel_elements)
@@ -263,8 +265,10 @@ def get_outputs_from_main_nf(self):
263265
elif match_element.group(4):
264266
output_val = match_element.group(4)
265267
if output_val:
266-
output_val = re.sub(r"\s*\,\s*arity\s*\:\s*\w+\s*", "", output_val).strip() # remove arity
267-
output_val = output_val.strip("'").strip('"') # remove quotes
268+
output_val = re.split(r',(?=(?:[^\'"]*[\'"][^\'"]*[\'"])*[^\'"]*$)', output_val)[
269+
0
270+
] # Takes only first part, avoid commas in quotes
271+
output_val = output_val.strip().strip("'").strip('"') # remove quotes and whitespaces
268272
output_channel[match_emit.group(1)].append({output_val: {}})
269273
outputs.append(output_channel)
270274
log.debug(f"Found {len(outputs)} outputs in {self.main_nf}")

tests/modules/test_lint.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,15 @@ def test_modules_lint_trimgalore(self):
187187
assert len(module_lint.passed) > 0
188188
assert len(module_lint.warned) >= 0
189189

190+
def test_modules_lint_trinity(self):
191+
"""Test linting the Trinity module"""
192+
self.mods_install.install("trinity")
193+
module_lint = nf_core.modules.lint.ModuleLint(directory=self.pipeline_dir)
194+
module_lint.lint(print_results=False, module="trinity")
195+
assert len(module_lint.failed) == 0, f"Linting failed with {[x.__dict__ for x in module_lint.failed]}"
196+
assert len(module_lint.passed) > 0
197+
assert len(module_lint.warned) >= 0
198+
190199
def test_modules_lint_tabix_tabix(self):
191200
"""Test linting the tabix/tabix module"""
192201
self.mods_install.install("tabix/tabix")

0 commit comments

Comments
 (0)