From 541a4b22706e5a82ec6bc27ef6283db833dc96a3 Mon Sep 17 00:00:00 2001 From: Ben Nemec Date: Wed, 2 Jul 2014 11:15:18 -0500 Subject: [PATCH] Add global exclusions to dib-lint This will be useful for adopting dib-lint in other projects, in particular tripleo-image-elements. It allows some dib-lint rules to be used even if the project can't pass all of the checks. The failing checks can then be fixed one at a time and removed from the exclusions list. For consistency, this change reads the new exclusions from tox.ini in the same way as flake8. To use the exclusion mechanism, the the following section can be added to tox.ini: [dib-lint] ignore = sete setu setpipefail Change-Id: I6d8024e7613890e935ceb5e50d0d507bd554d8dd --- bin/dib-lint | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/bin/dib-lint b/bin/dib-lint index b287e937..35c26fb0 100755 --- a/bin/dib-lint +++ b/bin/dib-lint @@ -22,11 +22,25 @@ set -eu set -o pipefail parse_exclusions() { - # Exclusions are currently only read on a per-file basis + # Per-file exclusions + # Example: # dib-lint: disable=sete setpipefail local filename=$1 local disable_pattern="# dib-lint: disable=" local exclusions=$(grep "^$disable_pattern.*$" $filename | sed "s/$disable_pattern//g") - echo $exclusions + + # Global exclusions read from tox.ini + # Example section in tox.ini: + # [dib-lint] + # ignore = sete setu + section="dib-lint" + option="ignore" + global_exclusions=$(python -c \ + "import ConfigParser; \ + conf=ConfigParser.ConfigParser(); \ + conf.read('tox.ini'); \ + print conf.get('$section', '$option') if conf.has_option('$section', '$option') else ''" + ) + echo $exclusions $global_exclusions } excluded() {