Extending flake8 linting rules.
Project by: Wesley Coomber, Rose Howell, Steven Sprecher, Kristen Escher
A flake8 linter plug-in that checks for bugs and bad practices which flake8 doesn't handle by default. The flake8-Smart plugin focuses on security and optimization for the target Python file.
First, install the base flake8 linter tool:
$ python<version> -m pip install flake8
Then, install the new flake8-plugin called flake8-Smart.
$ cd /compilersProjecto/flake8-Smart/
$ python setup.py install .
After installation, the flake8-Smart
extension is active by default.
Verify this by checking flake8 --version
for the flake8-Smart extension.
To lint a file, run flake8 test.py
where test.py
is the file you would like to lint.
A370
: Insecure hash function usageA371
: Insecure cipher block mode
A421
: Dead code afterif()
constant number valueA422
: Dead code after conditional evaluating constant boolean valueA423
: Dead code after a conditional statement that is indirectly given a constant valueA200
: Redundant or superfluous constant assignment within a loop
Base dir of the project is /compilersProjecto/
Our plug-in is in /compilersProjecto/flake8-Smart/flake8_Smart.py
Our results are in /compilersProjecto/our_stuff.log
A PDF of our report is in /compilersProjecto/linter.pdf
compilersProjecto
- flake8-Smart/
- flake8_Smart.py
- reinstall.sh
- setup.py
- tests/
- A200.py
- A370.py
- A371.py
- A421.py
- A422.py
- A423.py
- helloWorldTest.py
- linter.pdf
- python_repository/
- logs/
- eyeo_sorted.log
- our_plugin_sorted.log
- our_stuff.log
- out_plugin.log
- vanilla_f8.log
- pull_files_we_triggered_on.bash
- python_code/
- [3516 Python files for testing]
- remove_new_rules.py
- README.md
Commands to generate our experiment results:
$ cd python_repository/python_code # make sure you have flake8-eyeo + flake8-Smart plugin
$ flake8 * > ../logs/our_stuff.log
$ cd ../
$ python2.7 remove_new_rules /logs/our_stuff.log /logs/our_plugin_sorted.log /logs/eyeo_sorted.log
$ ./pull_files_we_triggered_on.bash logs/our_plugin_sorted.log python_code FILES_WE_TRIGGERED_ON
$ ./gather_plugin_error_data.bash logs/our_plugin_sorted.log