The current flake8 check only looks at one item (semicolons at end of
line). This means that our code quality will continue to get worse,
violating an increasing number of checks.
Switching to a whitelist means that we freeze the badness at its
current level & can incrementally fix things up.
We are excluding the folllowing...
Indentation:
E114 indentation is not a multiple of four (comment)
E115 expected an indented block (comment)
E116 unexpected indentation (comment)
E121 continuation line under-indented for hanging indent
E125 continuation line with same indent as next logical line
E126 continuation line over-indented for hanging indent
E127 continuation line over-indented for visual indent
E128 continuation line under-indented for visual indent
E129 visually indented line with same indent as next logical line
E131 continuation line unaligned for hanging indent
Whitespace:
E211 whitespace before ‘(‘
E221 multiple spaces before operator
E222 multiple spaces after operator
E225 missing whitespace around operator
E226 missing whitespace around arithmetic operator
E231 missing whitespace after ‘,’, ‘;’, or ‘:’
E261 at least two spaces before inline comment
Blank lines
E301 expected 1 blank line, found 0
E302 expected 2 blank lines, found 0
E303 too many blank lines (3)
E305 expected 2 blank lines after end of function or class
Line length
E501 line too long (82 > 79 characters)
Statements
E722 do not use bare except, specify exception instead
E741 do not use variables named ‘l’, ‘O’, or ‘I’
Errors:
F821 undefined name 'name'
Warnings:
W504 line break after binary operator
W605 invalid escape sequence ‘x’
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
build-aux/syntax-check.mk | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk
index 8345703b3e..1ad0c626e1 100644
--- a/build-aux/syntax-check.mk
+++ b/build-aux/syntax-check.mk
@@ -878,11 +878,28 @@ sc_require_enum_last_marker:
{ echo '$(ME): enum impl needs _LAST marker on second line' 1>&2; \
exit 1; } || :
-# In Python files we don't want to end lines with a semicolon like in C
+# Validate many python style rules
+FLAKE8_INDENTATION = E114,E115,E116,E121,E125,E126,E127,E128,E129,E131
+FLAKE8_WHITESPACE = E211,E221,E222,E225,E226,E231,E261
+FLAKE8_BLANK_LINES = E301,E302,E303,E305
+FLAKE8_LINE_LENGTH = E501
+FLAKE8_STATEMENTS = E722,E741
+FLAKE8_ERRORS = F821
+FLAKE8_WARNINGS = W504,W605
+
+FLAKE8_IGNORE = $(FLAKE8_INDENTATION),$\
+ $(FLAKE8_WHITESPACE),$\
+ $(FLAKE8_BLANK_LINES),$\
+ $(FLAKE8_LINE_LENGTH),$\
+ $(FLAKE8_STATEMENTS),$\
+ $(FLAKE8_ERRORS),$\
+ $(FLAKE8_WARNINGS) \
+ $(NULL)
+
sc_flake8:
@if [ -n "$(FLAKE8)" ]; then \
$(VC_LIST_EXCEPT) | $(GREP) '\.py$$' | xargs \
- $(FLAKE8) --select E703 --show-source; \
+ $(FLAKE8) --ignore $(FLAKE8_IGNORE) --show-source; \
else \
echo '$(ME): skipping test $@: flake8 not installed' 1>&2; \
fi
--
2.21.0