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
This commit is contained in:
parent
451e571753
commit
541a4b2270
18
bin/dib-lint
18
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() {
|
||||
|
Loading…
Reference in New Issue
Block a user