-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2686 from mirpedrol/lint-ignore-files
Linting: allow ignoring specific files when linting template_strings
- Loading branch information
Showing
7 changed files
with
101 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import subprocess | ||
from pathlib import Path | ||
|
||
import nf_core.create | ||
import nf_core.lint | ||
|
||
|
||
def test_template_strings(self): | ||
"""Tests finding a template string in a file fails linting.""" | ||
new_pipeline = self._make_pipeline_copy() | ||
# Add template string to a file | ||
txt_file = Path(new_pipeline) / "docs" / "test.txt" | ||
with open(txt_file, "w") as f: | ||
f.write("my {{ template_string }}") | ||
subprocess.check_output(["git", "add", "docs"], cwd=new_pipeline) | ||
lint_obj = nf_core.lint.PipelineLint(new_pipeline) | ||
lint_obj._load() | ||
result = lint_obj.template_strings() | ||
print(result["failed"]) | ||
assert len(result["failed"]) == 1 | ||
assert len(result["ignored"]) == 0 | ||
|
||
|
||
def test_template_strings_ignored(self): | ||
"""Tests ignoring template_strings""" | ||
new_pipeline = self._make_pipeline_copy() | ||
# Ignore template_strings test | ||
nf_core_yml = Path(new_pipeline) / ".nf-core.yml" | ||
with open(nf_core_yml, "w") as f: | ||
f.write("repository_type: pipeline\nlint:\n template_strings: False") | ||
lint_obj = nf_core.lint.PipelineLint(new_pipeline) | ||
lint_obj._load() | ||
lint_obj._lint_pipeline() | ||
assert len(lint_obj.failed) == 0 | ||
assert len(lint_obj.ignored) == 1 | ||
|
||
|
||
def test_template_strings_ignore_file(self): | ||
"""Tests ignoring template_strings file""" | ||
new_pipeline = self._make_pipeline_copy() | ||
# Add template string to a file | ||
txt_file = Path(new_pipeline) / "docs" / "test.txt" | ||
with open(txt_file, "w") as f: | ||
f.write("my {{ template_string }}") | ||
subprocess.check_output(["git", "add", "docs"], cwd=new_pipeline) | ||
# Ignore template_strings test | ||
nf_core_yml = Path(new_pipeline) / ".nf-core.yml" | ||
with open(nf_core_yml, "w") as f: | ||
f.write("repository_type: pipeline\nlint:\n template_strings:\n - docs/test.txt") | ||
lint_obj = nf_core.lint.PipelineLint(new_pipeline) | ||
lint_obj._load() | ||
result = lint_obj.template_strings() | ||
assert len(result["failed"]) == 0 | ||
assert len(result["ignored"]) == 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters