Skip to content

Commit

Permalink
planemo lint: add --skip_file
Browse files Browse the repository at this point in the history
new option allowing to specify one or more files
listing linters to skip
  • Loading branch information
bernt-matthias committed Dec 15, 2023
1 parent 4dddc03 commit 781429f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion planemo/commands/cmd_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@options.report_level_option()
@options.report_xunit()
@options.fail_level_option()
@options.skip_option()
@options.skip_options()
@options.lint_xsd_option()
@options.recursive_option()
@click.option(
Expand Down
2 changes: 1 addition & 1 deletion planemo/commands/cmd_shed_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@options.shed_realization_options()
@options.report_level_option()
@options.fail_level_option()
@options.skip_option()
@options.skip_options()
@options.click.option(
"--tools", is_flag=True, default=False, help=("Lint tools discovered in the process of linting repositories.")
)
Expand Down
11 changes: 10 additions & 1 deletion planemo/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,17 @@ def build_lint_args(ctx, **kwds):
skip = ctx.global_config.get("lint_skip", "")
if isinstance(skip, list):
skip = ",".join(skip)

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

for skip_file in kwds.get("skip_file", []):
with open(skip_file) as f:
for line in f.readlines():
line = line.strip()
if not line or line.startswith("#"):
continue
skip_types.append(line)


lint_args = dict(
level=report_level,
fail_level=fail_level,
Expand Down
15 changes: 15 additions & 0 deletions planemo/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -1384,6 +1384,12 @@ def report_xunit():
)


def skip_options():
return _compose(
skip_option(),
skip_file_option(),
)

def skip_option():
return planemo_option(
"-s",
Expand All @@ -1395,6 +1401,15 @@ def skip_option():
"and best-practice XML ordering."
),
)
def skip_file_option():
return planemo_option(
"--skip_file",
type=click.Path(exists=True, file_okay=True, dir_okay=False, resolve_path=True),
multiple=True,
help=(
"File containing a list of lint tests to skip"
),
)


def fail_level_option():
Expand Down

0 comments on commit 781429f

Please sign in to comment.