Browse files

More linting configurablity.

Add --skip argument to lint and shed_lint to pass in modules to skip while linting - I think the common ones are going to be citations and xml_order - so that would be --skip 'citations,xml_order' for instance. (TODO: Probably worth still catching unknown top-level tags even if xml_order is disabled - so those should be split out I guess).

A default value for skip can be specified by specifing a list of items in ``~/.planemo.yml`` under a ``lint_skip`` key.

Also improves the display of linting so the short name is what is display - e.g. user will now see "Applying linter citations" and not "Appling linter lint_citations".
  • Loading branch information...
jmchilton committed Apr 24, 2015
1 parent e7886d8 commit 26e3cdb11a0317ace4c270e3a27ac32c8535d904
@@ -13,12 +13,13 @@
def cli(ctx, path, **kwds):
"""Check specified tool(s) for common errors and adherence to best
lint_args = build_lint_args(**kwds)
lint_args = build_lint_args(ctx, **kwds)
exit = lint_tools_on_path(ctx, path, lint_args)
@@ -278,6 +278,17 @@ def report_level_option():

def skip_option():
return click.option(
help=("Comma-separated list of lint tests to skip (e.g send ."
"--skip 'citations,xml_order' to skip linting of citations "
"and best-practice XML ordering.")

def fail_level_option():
return click.option(
@@ -39,7 +39,7 @@

def lint_repository(ctx, path, **kwds):
info("Linting repository %s" % path)
lint_args = build_lint_args(**kwds)
lint_args = build_lint_args(ctx, **kwds)
lint_ctx = LintContext(lint_args["level"])
@@ -38,13 +38,21 @@ def yield_tool_xmls(ctx, path):
yield (tool_path, tool_xml)

def build_lint_args(**kwds):
def build_lint_args(ctx, **kwds):
report_level = kwds.get("report_level", "all")
fail_level = kwds.get("fail_level", "warn")
skip = kwds.get("skip", None)
if skip is None:
skip = ctx.global_config.get("lint_skip", "")
if isinstance(skip, list):
skip = ",".join(skip)

skip_types = [s.strip() for s in skip.split(",")]
lint_args = dict(
return lint_args

@@ -7,8 +7,8 @@
LEVEL_ERROR = "error"

def lint_xml(tool_xml, level=LEVEL_ALL, fail_level=LEVEL_WARN, extra_modules=[]):
lint_context = LintContext(level=level)
def lint_xml(tool_xml, level=LEVEL_ALL, fail_level=LEVEL_WARN, extra_modules=[], skip_types=[]):
lint_context = LintContext(level=level, skip_types=skip_types)
lint_xml_with(lint_context, tool_xml, extra_modules)
return not lint_context.failed(fail_level)

@@ -25,13 +25,16 @@ def lint_xml_with(lint_context, tool_xml, extra_modules=[]):

class LintContext(object):

def __init__(self, level):
def __init__(self, level, skip_types=[]):
self.skip_types = skip_types
self.level = level
self.found_errors = False
self.found_warns = False

def lint(self, name, lint_func, lint_target):
name = name.replace("tsts", "tests")
name = name.replace("tsts", "tests")[len("lint_"):]
if name in self.skip_types:
self.printed_linter_info = False
self.valid_messages = []
self.info_messages = []
@@ -42,7 +45,6 @@ def lint(self, name, lint_func, lint_target):
if self.error_messages:
status = "FAIL"
elif self.warn_messages:

status = "WARNING"
status = "CHECK"
@@ -0,0 +1,26 @@
<tool id="copy" name="Copy Dataset" version="1.0">
<description>copies a dataset</description>
cp $input $output
<param name="input1" type="data" format="txt" label="Concatenate Dataset"/>
<data name="output" format="txt"/>
<test expect_failure="true" expect_exit_code="1">
<param name="input1" value="1.bed"/>
<has_line line="Indexed 0 sequences" />
<has_line line="Identifier 'gi|16127999|ref|NP_414546.1|' not found in sequence file" />
Some Awesome Help!
@@ -1,3 +1,4 @@
import os
import glob

from .test_utils import CliTestCase
@@ -17,3 +18,15 @@ def test_fail_tools(self):
for fail_tool in fail_tools:
lint_cmd = ["lint", fail_tool]
self._check_exit_code(lint_cmd, exit_code=1)

def test_skips(self):
fail_citation = os.path.join(TEST_TOOLS_DIR, "fail_citation.xml")
lint_cmd = ["lint", fail_citation]
self._check_exit_code(lint_cmd, exit_code=1)

lint_cmd = ["lint", "--skip", "citations", fail_citation]
self._check_exit_code(lint_cmd, exit_code=0)

# Check string splitting and stuff.
lint_cmd = ["lint", "--skip", "xml_order, citations", fail_citation]
self._check_exit_code(lint_cmd, exit_code=0)

0 comments on commit 26e3cdb

Please sign in to comment.