intel / ccc-linux-guest-hardening

Linux Security Hardening for Confidential Compute
https://intel.github.io/ccc-linux-guest-hardening-docs
MIT License
64 stars 13 forks source link

apply autopep8 for bulk of flake8/pycodestyle issues #58

Closed il-steffen closed 1 year ago

il-steffen commented 1 year ago

Apply similar to flake8, but ignoring long lines for now:

find bkc -name '.py' -not -path 'venv' -not -path 'qemu-4.2.0/*' -exec autopep8 --max-line-length 500 -i {} \;

il-steffen commented 1 year ago

makes the following disappear from flake8 report:

E101 indentation contains mixed spaces and tabs
E117 over-indented
E124 closing bracket does not match visual indentation
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
E201 whitespace after '['
E202 whitespace before ']'
E202 whitespace before '}'
E221 multiple spaces before operator
E225 missing whitespace around operator
E231 missing whitespace after ','
E261 at least two spaces before inline comment
E262 inline comment should start with '# '
E266 too many leading '#' for block comment
E275 missing whitespace after keyword
E302 expected 2 blank lines, found 1
E303 too many blank lines (2)
E305 expected 2 blank lines after class or function definition, found 1
E306 expected 1 blank line before a nested definition, found 0
E401 multiple imports on one line
E502 the backslash is redundant between brackets
E701 multiple statements on one line (colon)
E703 statement ends with a semicolon
E731 do not assign a lambda expression, use a def
il-steffen commented 1 year ago

Note, there is at least one change by autopep8 which is more on syntax side: | bkc/coverage/smatcher/smatcher/init.py:219:5: E731 do not assign a lambda expression, use a def

Wenzel commented 1 year ago

Why --max-line-length 500 ?

il-steffen commented 1 year ago

Why --max-line-length 500 ?

Avoid mixing in some of the more silly fixups for long print():

        print(                                                                                                                                               
                f"Error: Input file {input_file} does not exists", file=sys.stderr)

=> The line is still to long, but less readable than before.

We need to fix those manually...however, I can apply the line length fixes now on top and filter out the broken ones like this...1s...

Wenzel commented 1 year ago

If you we use an automated tool, we should apply it everywhere without condition Otherwise it becomes add uncessary complexity for contributors to understand how their patchs should follow certain constraints on some files, but not on others.

il-steffen commented 1 year ago

If you we use an automated tool, we should apply it everywhere without condition Otherwise it becomes add uncessary complexity for contributors to understand how their patchs should follow certain constraints on some files, but not on others.

I don't propose to use autopep8 everywhere or for everyone here. Just to fix some of the flake8 issues.

il-steffen commented 1 year ago

rebased + fix a couple issues that appear outside the whitespace/longlines

il-steffen commented 1 year ago

removed DOINITCALLS config change 6e12988 - need to test separately