Commit Graph

6 Commits

Author SHA1 Message Date
Christian Göttsche f304db813e scripts: ignore Flake8 tag E275
./gui/polgengui.py:484:18: E275 missing whitespace after keyword
    ./gui/polgengui.py:530:18: E275 missing whitespace after keyword
    ./python/sepolgen/src/sepolgen/policygen.py:327:19: E275 missing whitespace after keyword
    ./python/sepolgen/src/sepolgen/policygen.py:329:11: E275 missing whitespace after keyword
    ./python/sepolicy/build/lib/sepolicy/__init__.py:453:15: E275 missing whitespace after keyword
    ./python/sepolicy/build/lib/sepolicy/generate.py:1349:28: E275 missing whitespace after keyword
    ./python/sepolicy/build/lib/sepolicy/generate.py:1351:28: E275 missing whitespace after keyword
    ./python/sepolicy/build/lib/sepolicy/gui.py:638:24: E275 missing whitespace after keyword
    ./python/sepolicy/build/lib/sepolicy/gui.py:863:23: E275 missing whitespace after keyword
    ./python/sepolicy/build/lib/sepolicy/gui.py:2177:16: E275 missing whitespace after keyword
    ./python/sepolicy/sepolicy/__init__.py:453:15: E275 missing whitespace after keyword
    ./python/sepolicy/sepolicy/generate.py:1349:28: E275 missing whitespace after keyword
    ./python/sepolicy/sepolicy/generate.py:1351:28: E275 missing whitespace after keyword
    ./python/sepolicy/sepolicy/gui.py:638:24: E275 missing whitespace after keyword
    ./python/sepolicy/sepolicy/gui.py:863:23: E275 missing whitespace after keyword
    ./python/sepolicy/sepolicy/gui.py:2177:16: E275 missing whitespace after keyword
    ./sandbox/sandbox:114:7: E275 missing whitespace after keyword
    ./sandbox/sandbox:134:11: E275 missing whitespace after keyword
    ./sandbox/sandbox:136:7: E275 missing whitespace after keyword

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-08-15 08:50:18 -04:00
Petr Lautrbach d7b0207c5a run-flake8: Filter out ./.git/ directory
When a branch has '.py' suffix git creates a file with the same suffix and this
file is found by the `find . -name '*.py'` command. Such files from './git' need
to be filtered out.

Fixes:

    $ PATH="$VIRTUAL_ENV/bin:$PATH" ./scripts/run-flake8
    Analyzing 189 Python scripts
    ./.git/logs/refs/heads/semanage-test.py:1:42: E999 SyntaxError: invalid syntax
    ./.git/refs/heads/semanage-test.py:1:4: E999 SyntaxError: invalid syntax
    The command "PATH="$VIRTUAL_ENV/bin:$PATH" ./scripts/run-flake8" exited with 1.

Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
Acked-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2020-05-13 11:11:27 +02:00
Nicolas Iooss bb518a01e9 scripts/run-flake8: run on Python scripts not ending with .py
When running flake8 on a directory, it does not analyze files without an
extension, like semanage_migrate_store, mlscolor-test, etc. Use grep to
find files with a Python shebang and build a list which is then given to
flake8.

This commit is possible now that some clean-up patches have been
applied, such as commit 69c56bd2f6 ("python/chcat: improve the code
readability") and b7227aaec1 ("mcstrans: fix Python linter warnings on
test scripts") and 3cb974d2d2 ("semanage_migrate_store: fix many
Python linter warnings").

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-01-08 13:21:09 +01:00
Nicolas Iooss 691231e612 python/sepolgen: upgrade ply to release 3.11
PLY (Python Lex-Yacc) 3.11 has been released in February 2018:
- http://www.dabeaz.com/ply/index.html
- https://github.com/dabeaz/ply/releases/tag/3.11

Copy lex.py and yacc.py from this new release.

This fixes the following warning from "make test":

    python run-tests.py
    ../src/./sepolgen/lex.py:634: DeprecationWarning: Using or importing
    the ABCs from 'collections' instead of from 'collections.abc' is
    deprecated, and in 3.8 it will stop working
     if isinstance(t, collections.Callable):

(Python 3.3 moved collections.Callable to collections.abc.Callable)

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-01-04 13:52:09 +01:00
Nicolas Iooss 6f01778406
python: remove semicolon from end of lines
Python does not need to end a statement with a semicolon. Doing this
gets reported by linters such as flake8 ("E703 statement ends with a
semicolon").

Remove such semicolons in the code and enable this warning in
scripts/run-flake8.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2018-08-19 17:55:19 +02:00
Nicolas Iooss 41764b73a7
Travis-CI: run flake8 on Python code
flake8 is a Python linter which is able to detect issues in Python code
(syntax errors, undefined variables, etc.). It has been used to find
bugs in the project. In order to prevent the introduction of new bugs
which can be detected by it, add a script which runs it and use it in
Travis-CI.

flake8 can be used to detect code which is not written according to PEP8
style guide (which forbids whitespaces in some places, enforces the use
of space-indenting, specifies how many blank lines are used between
functions, etc.). As SELinux code does not follow this style guide,
scripts/run-flake8 disables many warnings related to this when running
the linter.

In order to silence flake8 warnings, the Python code can also be
modified. However fixing every "do not use bare 'except'" in the project
needs to be done carefully and takes much time.
This is why the warnings which are disabled have been ordered in three
lists:
* The warnings which can be activated in a not-so-distant future after
  the code has been modified.
* The warnings related to PEP8 which cannot be activated without a major
  cleaning work of the codebase (for example to modify white spaces)
* The warnings which are introduced by code generated by SWIG 3.0.12,
  which would require patches in SWIG in order to be activated (there
  is right now only one such warning).

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2018-08-18 12:00:24 +02:00