Repository: nf-core/tools

Issue:
Linting should check pipeline names for guidelines
https://github.com/nf-core/ICGC-featureCounts/issues/8


Discussion:
Is the pipeline name following the lowercase convention an absolute requirement?
This becomes less important with new `nf-core create` name validation in https://github.com/nf-core/tools/pull/175 (but could still be nice and should be easy)
> _Is the pipeline name following the lowercase convention an absolute requirement?_

Up for discussion - the reason for this was that docker images are always lower case and without punctuation, so makes everything more consistent. Also just easier to remember if everything is always lower case.

NB: I remember way back thinking that the lint tool could be useful for people doing pipelines outside of nf-core (eg. forks). This test could be annoying there, so maybe good as a warning instead of a fail?
Yes, I think a warning is already sufficient, giving people feedback instead of just failing is better in such a case 👍 


Resolving patch:
diff --git a/nf_core/lint.py b/nf_core/lint.py
--- a/nf_core/lint.py
+++ b/nf_core/lint.py
@@ -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
@@ -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',
@@ -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 ''


Test patch:
diff --git a/tests/lint_examples/minimal_working_example/.travis.yml b/tests/lint_examples/minimalworkingexample/.travis.yml
similarity index 100%
rename from tests/lint_examples/minimal_working_example/.travis.yml
rename to tests/lint_examples/minimalworkingexample/.travis.yml
diff --git a/tests/lint_examples/minimal_working_example/CHANGELOG.md b/tests/lint_examples/minimalworkingexample/CHANGELOG.md
similarity index 100%
rename from tests/lint_examples/minimal_working_example/CHANGELOG.md
rename to tests/lint_examples/minimalworkingexample/CHANGELOG.md
diff --git a/tests/lint_examples/minimal_working_example/Dockerfile b/tests/lint_examples/minimalworkingexample/Dockerfile
similarity index 100%
rename from tests/lint_examples/minimal_working_example/Dockerfile
rename to tests/lint_examples/minimalworkingexample/Dockerfile
diff --git a/tests/lint_examples/minimal_working_example/LICENSE b/tests/lint_examples/minimalworkingexample/LICENSE
similarity index 100%
rename from tests/lint_examples/minimal_working_example/LICENSE
rename to tests/lint_examples/minimalworkingexample/LICENSE
diff --git a/tests/lint_examples/minimal_working_example/README.md b/tests/lint_examples/minimalworkingexample/README.md
similarity index 100%
rename from tests/lint_examples/minimal_working_example/README.md
rename to tests/lint_examples/minimalworkingexample/README.md
diff --git a/tests/lint_examples/minimal_working_example/conf/base.config b/tests/lint_examples/minimalworkingexample/conf/base.config
similarity index 100%
rename from tests/lint_examples/minimal_working_example/conf/base.config
rename to tests/lint_examples/minimalworkingexample/conf/base.config
diff --git a/tests/lint_examples/minimal_working_example/docs/README.md b/tests/lint_examples/minimalworkingexample/docs/README.md
similarity index 100%
rename from tests/lint_examples/minimal_working_example/docs/README.md
rename to tests/lint_examples/minimalworkingexample/docs/README.md
diff --git a/tests/lint_examples/minimal_working_example/docs/output.md b/tests/lint_examples/minimalworkingexample/docs/output.md
similarity index 100%
rename from tests/lint_examples/minimal_working_example/docs/output.md
rename to tests/lint_examples/minimalworkingexample/docs/output.md
diff --git a/tests/lint_examples/minimal_working_example/docs/usage.md b/tests/lint_examples/minimalworkingexample/docs/usage.md
similarity index 100%
rename from tests/lint_examples/minimal_working_example/docs/usage.md
rename to tests/lint_examples/minimalworkingexample/docs/usage.md
diff --git a/tests/lint_examples/minimal_working_example/environment.yml b/tests/lint_examples/minimalworkingexample/environment.yml
similarity index 100%
rename from tests/lint_examples/minimal_working_example/environment.yml
rename to tests/lint_examples/minimalworkingexample/environment.yml
diff --git a/tests/lint_examples/minimal_working_example/main.nf b/tests/lint_examples/minimalworkingexample/main.nf
similarity index 100%
rename from tests/lint_examples/minimal_working_example/main.nf
rename to tests/lint_examples/minimalworkingexample/main.nf
diff --git a/tests/lint_examples/minimal_working_example/nextflow.config b/tests/lint_examples/minimalworkingexample/nextflow.config
similarity index 100%
rename from tests/lint_examples/minimal_working_example/nextflow.config
rename to tests/lint_examples/minimalworkingexample/nextflow.config
diff --git a/tests/lint_examples/minimal_working_example/tests/run_test.sh b/tests/lint_examples/minimalworkingexample/tests/run_test.sh
similarity index 100%
rename from tests/lint_examples/minimal_working_example/tests/run_test.sh
rename to tests/lint_examples/minimalworkingexample/tests/run_test.sh
diff --git a/tests/test_bump_version.py b/tests/test_bump_version.py
--- a/tests/test_bump_version.py
+++ b/tests/test_bump_version.py
@@ -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)
diff --git a/tests/test_download.py b/tests/test_download.py
--- a/tests/test_download.py
+++ b/tests/test_download.py
@@ -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):
 
diff --git a/tests/test_lint.py b/tests/test_lint.py
--- a/tests/test_lint.py
+++ b/tests/test_lint.py
@@ -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
 
@@ -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)
\ No newline at end of file