diff --git a/bear-requirements.txt b/bear-requirements.txt index 25c0c5f74f..e440afb70d 100644 --- a/bear-requirements.txt +++ b/bear-requirements.txt @@ -15,6 +15,7 @@ munkres3~=1.0 mypy-lang~=0.4.6 nbformat~=4.1 nltk~=3.2 +planemo~=0.36 proselint~=0.7.0 pycodestyle~=2.2 pydocstyle~=1.1 diff --git a/bears/planemo/PlanemoLintBear.py b/bears/planemo/PlanemoLintBear.py new file mode 100644 index 0000000000..b6f784302c --- /dev/null +++ b/bears/planemo/PlanemoLintBear.py @@ -0,0 +1,34 @@ +import os +import shlex + +from coalib.bearlib.abstractions.Linter import linter +from dependency_management.requirements.PipRequirement import PipRequirement +from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY +from coalib.settings.Setting import typed_list + + +@linter(executable='planemo', + output_format='regex', + output_regex=r'..\s(?P\w*:)(?P.*)', + severity_map={'WARNING:': RESULT_SEVERITY.MAJOR, + 'CHECK:': RESULT_SEVERITY.NORMAL, + 'INFO:': RESULT_SEVERITY.INFO}) +class PlanemoLintBear: + """ + Checks the code with planemo lint. This will run planemo lint over each file + separately. + """ + LANGUAGES = {'xml'} + REQUIREMENTS = {PipRequirement('planemo', '0.36')} + AUTHORS = {'The coala developers'} + AUTHORS_EMAILS = {'coala-devel@googlegroups.com'} + ASCIINEMA_URL = 'https://asciinema.org/a/0kiduzg55d59nxhm8wuwfvl3n' + LICENSE = 'AGPL-3.0' + CAN_DETECT = {'Syntax'} + + @staticmethod + def create_arguments(filename, file, config_file): + + args = ('lint',) + + return args + (filename,) diff --git a/bears/planemo/__init__.py b/bears/planemo/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/planemo/PlanemoLintBearTest.py b/tests/planemo/PlanemoLintBearTest.py new file mode 100644 index 0000000000..b76773f623 --- /dev/null +++ b/tests/planemo/PlanemoLintBearTest.py @@ -0,0 +1,36 @@ +import os +import re +from queue import Queue +from shutil import which +from unittest.case import skipIf + +from bears.planemo.PlanemoLintBear import PlanemoLintBear +from coalib.testing.LocalBearTestHelper import LocalBearTestHelper +from coalib.settings.Section import Section +from coalib.settings.Setting import Setting + + +@skipIf(which('planemo') is None, 'Planemo is not installed') +class PlanemoLintBearTest(LocalBearTestHelper): + + def setUp(self): + self.section = Section('test section') + self.uut = PlanemoLintBear(self.section, Queue()) + self.test_file = os.path.join(os.path.dirname(__file__), + 'test_files', + 'planemolint_test.xml') + + def test_run(self): + self.check_validity( + self.uut, + [], # Doesn't matter, planemo lint will parse the file + self.test_file, + valid=False) + self.test_file = os.path.join(os.path.dirname(__file__), + 'test_files', + 'valid_planemo_test.xml') + self.check_validity( + self.uut, + [], # Doesn't matter, planemo lint will parse the file + self.test_file, + valid=True) diff --git a/tests/planemo/__init__.py b/tests/planemo/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/planemo/test_files/planemolint_test.xml b/tests/planemo/test_files/planemolint_test.xml new file mode 100644 index 0000000000..4db05340b4 --- /dev/null +++ b/tests/planemo/test_files/planemolint_test.xml @@ -0,0 +1,24 @@ + + from a file + random_lines_two_pass.py "${input}" "${out_file1}" "${num_lines}" + #if str( $seed_source.seed_source_selector ) == "set_seed": + --seed "${seed_source.seed}" + #end if + + + + + + + + + + + + + + + + + + diff --git a/tests/planemo/test_files/valid_planemo_test.xml b/tests/planemo/test_files/valid_planemo_test.xml new file mode 100644 index 0000000000..bd3da8a1b5 --- /dev/null +++ b/tests/planemo/test_files/valid_planemo_test.xml @@ -0,0 +1,7 @@ + + + Tove + Jani + Reminder + Don't forget me this weekend! + \ No newline at end of file