+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

### Linting

- ignore files in gitignore also for pipeline_if_empty_null lint test ([#3722](https://github.com/nf-core/tools/pull/3722))

### Modules

- Support modules with `exec:` blocks ([#3633](https://github.com/nf-core/tools/pull/3633))
Expand Down
22 changes: 11 additions & 11 deletions nf_core/pipelines/lint/pipeline_if_empty_null.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import logging
import os
import re
from pathlib import Path

from nf_core.utils import get_wf_files

log = logging.getLogger(__name__)


Expand All @@ -26,16 +27,15 @@ def pipeline_if_empty_null(self, root_dir=None):
if root_dir is None:
root_dir = self.wf_path

for root, dirs, files in os.walk(root_dir, topdown=True):
for fname in files:
try:
with open(Path(root, fname), encoding="latin1") as fh:
for line in fh:
if re.findall(pattern, line):
warned.append(f"`ifEmpty(null)` found in `{fname}`: _{line}_")
file_paths.append(Path(root, fname))
except FileNotFoundError:
log.debug(f"Could not open file {fname} in pipeline_if_empty_null lint test")
for file in get_wf_files(root_dir):
try:
with open(Path(file), encoding="latin1") as fh:
for line in fh:
if re.findall(pattern, line):
warned.append(f"`ifEmpty(null)` found in `{file}`: _{line}_")
file_paths.append(Path(file))
except FileNotFoundError:
log.debug(f"Could not open file {file} in pipeline_if_empty_null lint test")

if len(warned) == 0:
passed.append("No `ifEmpty(null)` strings found")
Expand Down
9 changes: 6 additions & 3 deletions nf_core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1574,9 +1574,12 @@ def get_wf_files(wf_path: Path):

wf_files = []

with open(Path(wf_path, ".gitignore")) as f:
lines = f.read().splitlines()
ignore = [line for line in lines if line and not line.startswith("#")]
try:
with open(Path(wf_path, ".gitignore")) as f:
lines = f.read().splitlines()
ignore = [line for line in lines if line and not line.startswith("#")]
except FileNotFoundError:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a unit test for this case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't! I can add it with another PR

ignore = []

for path in Path(wf_path).rglob("*"):
if any(fnmatch.fnmatch(str(path), pattern) for pattern in ignore):
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载