Skip to content
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

Fix #85 #475

Merged
merged 15 commits into from
Dec 9, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
### Linting

* Adjusted linting to enable `patch` branches from being tested
* Warn if pipeline name contains upper case letters or non alphabetical characters [#85](https://github.com/nf-core/tools/issues/85)

### Template

Expand Down
4 changes: 4 additions & 0 deletions docs/lint_errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,7 @@ This lint test runs through all files in the pipeline and searches for these lin
## Error #11 - Singularity file found ##{#11}

As we are relying on [Docker Hub](https://https://hub.docker.com/) instead of Singularity and all containers are automatically pulled from there, repositories should not have a `Singularity` file present.

## Error #12 - Pipeline name ## {#12}

In order to ensure consistent naming, pipeline names should contain only lower case, alphabetical characters. Otherwise a warning is displayed.
16 changes: 15 additions & 1 deletion nf_core/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ def lint_pipeline(self, release_mode=False):
'check_readme',
'check_conda_env_yaml',
'check_conda_dockerfile',
'check_pipeline_todos'
'check_pipeline_todos',
'check_pipeline_name'
]
if release_mode:
self.release_mode = True
Expand Down Expand Up @@ -333,6 +334,7 @@ def check_nextflow_config(self):
and print all config variables.
NB: Does NOT parse contents of main.nf / nextflow script
"""

# Fail tests if these are missing
config_fail = [
'manifest.name',
Expand Down Expand Up @@ -802,6 +804,18 @@ def check_pipeline_todos(self):
l = '{}..'.format(l[:50-len(fname)])
self.warned.append((10, "TODO string found in '{}': {}".format(fname,l)))

def check_pipeline_name(self):
"""Check whether pipeline name adheres to lower case/no hyphen naming convention"""

if self.pipeline_name.islower() and self.pipeline_name.isalpha():
self.passed.append((12, "Name adheres to nf-core convention"))
if not self.pipeline_name.islower():
self.warned.append((12, "Naming does not adhere to nf-core conventions: Contains uppercase letters"))
if not self.pipeline_name.isalpha():
self.warned.append((12, "Naming does not adhere to nf-core conventions: Contains non alphabetical characters"))



def print_results(self):
# Print results
rl = "\n Using --release mode linting tests" if self.release_mode else ''
Expand Down
2 changes: 1 addition & 1 deletion tests/test_bump_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import nf_core.lint, nf_core.bump_version

WD = os.path.dirname(__file__)
PATH_WORKING_EXAMPLE = os.path.join(WD, 'lint_examples/minimal_working_example')
PATH_WORKING_EXAMPLE = os.path.join(WD, 'lint_examples/minimalworkingexample')


@pytest.mark.datafiles(PATH_WORKING_EXAMPLE)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import tempfile
import unittest

PATH_WORKING_EXAMPLE = os.path.join(os.path.dirname(__file__), 'lint_examples/minimal_working_example')
PATH_WORKING_EXAMPLE = os.path.join(os.path.dirname(__file__), 'lint_examples/minimalworkingexample')

class DownloadTest(unittest.TestCase):

Expand Down
21 changes: 19 additions & 2 deletions tests/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ def pf(wd, path):
WD = os.path.dirname(__file__)
PATH_CRITICAL_EXAMPLE = pf(WD, 'lint_examples/critical_example')
PATH_FAILING_EXAMPLE = pf(WD, 'lint_examples/failing_example')
PATH_WORKING_EXAMPLE = pf(WD, 'lint_examples/minimal_working_example')
PATH_WORKING_EXAMPLE = pf(WD, 'lint_examples/minimalworkingexample')
PATH_MISSING_LICENSE_EXAMPLE = pf(WD, 'lint_examples/missing_license_example')
PATHS_WRONG_LICENSE_EXAMPLE = [pf(WD, 'lint_examples/wrong_license_example'),
pf(WD, 'lint_examples/license_incomplete_example')]

# The maximum sum of passed tests currently possible
MAX_PASS_CHECKS = 61
MAX_PASS_CHECKS = 62
# The additional tests passed for releases
ADD_PASS_RELEASE = 1

Expand Down Expand Up @@ -423,3 +423,20 @@ def test_pip_dependency_fails(self):
lint_obj.check_conda_env_yaml()
expectations = {"failed": 1, "warned": 0, "passed": 2}
self.assess_lint_status(lint_obj, **expectations)

def test_pipeline_name_pass(self):
"""Tests pipeline name good pipeline example: lower case, no punctuation"""
#good_lint_obj = nf_core.lint.run_linting(PATH_WORKING_EXAMPLE)
good_lint_obj = nf_core.lint.PipelineLint(PATH_WORKING_EXAMPLE)
good_lint_obj.pipeline_name = 'tools'
good_lint_obj.check_pipeline_name()
expectations = {"failed": 0, "warned": 0, "passed": 1}
self.assess_lint_status(good_lint_obj, **expectations)

def test_pipeline_name_critical(self):
"""Tests that warning is returned for pipeline not adhering to naming convention"""
critical_lint_obj = nf_core.lint.PipelineLint(PATH_WORKING_EXAMPLE)
critical_lint_obj.pipeline_name = 'Tools123'
critical_lint_obj.check_pipeline_name()
expectations = {"failed": 0, "warned": 2, "passed": 0}
self.assess_lint_status(critical_lint_obj, **expectations)