-
Notifications
You must be signed in to change notification settings - Fork 532
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1591 from mandiant/fix/issue-1579
use pre-commit to invoke linters
- Loading branch information
Showing
79 changed files
with
632 additions
and
723 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[flake8] | ||
max-line-length = 120 | ||
|
||
extend-ignore = | ||
# E203: whitespace before ':' (black does this) | ||
E203, | ||
# F401: `foo` imported but unused (prefer ruff) | ||
F401, | ||
# F811 Redefinition of unused `foo` (prefer ruff) | ||
F811, | ||
# E501 line too long (prefer black) | ||
E501, | ||
# B010 Do not call setattr with a constant attribute value | ||
B010, | ||
# G200 Logging statement uses exception in arguments | ||
G200 | ||
|
||
|
||
per-file-ignores = | ||
# T201 print found. | ||
# | ||
# scripts are meant to print output | ||
scripts/*: T201 | ||
# capa.exe is meant to print output | ||
capa/main.py: T201 | ||
# IDA tests emit results to output window so need to print | ||
tests/test_ida_features.py: T201 | ||
# utility used to find the Binary Ninja API via invoking python.exe | ||
capa/features/extractors/binja/find_binja_api.py: T201 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,61 @@ | ||
# Enable pycodestyle (`E`) codes | ||
select = ["E"] | ||
# Enable the pycodestyle (`E`) and Pyflakes (`F`) rules by default. | ||
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or | ||
# McCabe complexity (`C901`) by default. | ||
select = ["E", "F"] | ||
|
||
# Allow autofix for all enabled rules (when `--fix`) is provided. | ||
fixable = ["ALL"] | ||
unfixable = [] | ||
|
||
# E402 module level import not at top of file | ||
# E722 do not use bare 'except' | ||
ignore = ["E402", "E722"] | ||
exclude = ["*_pb2.py", "*_pb2.pyi"] | ||
# E501 line too long | ||
ignore = ["E402", "E722", "E501"] | ||
|
||
line-length = 120 | ||
|
||
exclude = [ | ||
# Exclude a variety of commonly ignored directories. | ||
".bzr", | ||
".direnv", | ||
".eggs", | ||
".git", | ||
".git-rewrite", | ||
".hg", | ||
".mypy_cache", | ||
".nox", | ||
".pants.d", | ||
".pytype", | ||
".ruff_cache", | ||
".svn", | ||
".tox", | ||
".venv", | ||
"__pypackages__", | ||
"_build", | ||
"buck-out", | ||
"build", | ||
"dist", | ||
"node_modules", | ||
"venv", | ||
# protobuf generated files | ||
"*_pb2.py", | ||
"*_pb2.pyi" | ||
] | ||
|
||
# Same as pycodestyle. | ||
line-length = 180 | ||
[per-file-ignores] | ||
# until we address #1592 and move test fixtures into conftest.py | ||
# then we need to ignore imports done to enable pytest fixtures. | ||
# | ||
# F401: `foo` imported but unused | ||
# F811 Redefinition of unused `foo` | ||
"tests/test_main.py" = ["F401", "F811"] | ||
"tests/test_proto.py" = ["F401", "F811"] | ||
"tests/test_freeze.py" = ["F401", "F811"] | ||
"tests/test_function_id.py" = ["F401", "F811"] | ||
"tests/test_viv_features.py" = ["F401", "F811"] | ||
"tests/test_binja_features.py" = ["F401", "F811"] | ||
"tests/test_pefile_features.py" = ["F401", "F811"] | ||
"tests/test_dnfile_features.py" = ["F401", "F811"] | ||
"tests/test_dotnet_features.py" = ["F401", "F811"] | ||
"tests/test_result_document.py" = ["F401", "F811"] | ||
"tests/test_dotnetfile_features.py" = ["F401", "F811"] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# install the pre-commit hooks: | ||
# | ||
# ❯ pre-commit install --hook-type pre-commit | ||
# pre-commit installed at .git/hooks/pre-commit | ||
# | ||
# ❯ pre-commit install --hook-type pre-push | ||
# pre-commit installed at .git/hooks/pre-push | ||
# | ||
# run all linters liks: | ||
# | ||
# ❯ pre-commit run --all-files | ||
# isort....................................................................Passed | ||
# black....................................................................Passed | ||
# ruff.....................................................................Passed | ||
# flake8...................................................................Passed | ||
# mypy.....................................................................Passed | ||
# | ||
# run a single linter like: | ||
# | ||
# ❯ pre-commit run --all-files isort | ||
# isort....................................................................Passed | ||
|
||
repos: | ||
- repo: local | ||
hooks: | ||
- id: isort | ||
name: isort | ||
stages: [commit, push] | ||
language: system | ||
entry: isort | ||
args: | ||
- "--length-sort" | ||
- "--profile" | ||
- "black" | ||
- "--line-length=120" | ||
- "--skip-glob" | ||
- "*_pb2.py" | ||
- "capa/" | ||
- "scripts/" | ||
- "tests/" | ||
always_run: true | ||
pass_filenames: false | ||
|
||
- repo: local | ||
hooks: | ||
- id: black | ||
name: black | ||
stages: [commit, push] | ||
language: system | ||
entry: black | ||
args: | ||
- "--line-length=120" | ||
- "--extend-exclude" | ||
- ".*_pb2.py" | ||
- "capa/" | ||
- "scripts/" | ||
- "tests/" | ||
always_run: true | ||
pass_filenames: false | ||
|
||
- repo: local | ||
hooks: | ||
- id: ruff | ||
name: ruff | ||
stages: [commit, push] | ||
language: system | ||
entry: ruff | ||
args: | ||
- "check" | ||
- "--config" | ||
- ".github/ruff.toml" | ||
- "capa/" | ||
- "scripts/" | ||
- "tests/" | ||
always_run: true | ||
pass_filenames: false | ||
|
||
- repo: local | ||
hooks: | ||
- id: flake8 | ||
name: flake8 | ||
stages: [commit, push] | ||
language: system | ||
entry: flake8 | ||
args: | ||
- "--config" | ||
- ".github/flake8.ini" | ||
- "--extend-exclude" | ||
- "capa/render/proto/capa_pb2.py" | ||
- "capa/" | ||
- "scripts/" | ||
- "tests/" | ||
always_run: true | ||
pass_filenames: false | ||
|
||
- repo: local | ||
hooks: | ||
- id: mypy | ||
name: mypy | ||
stages: [commit, push] | ||
language: system | ||
entry: mypy | ||
args: | ||
- "--check-untyped-defs" | ||
- "--ignore-missing-imports" | ||
- "--config-file=.github/mypy/mypy.ini" | ||
- "capa/" | ||
- "scripts/" | ||
- "tests/" | ||
always_run: true | ||
pass_filenames: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.