Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linting Updates #70

Draft
wants to merge 187 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
187 commits
Select commit Hold shift + click to select a range
98b7444
Fix double space
mepland May 23, 2024
c7d16c1
Add B909
mepland May 23, 2024
d259175
Format flake8 errors on GitHub Actions for GitHub via flake8-github-a…
mepland May 23, 2024
85bd897
Add flake8-implicit-str-concat
mepland May 23, 2024
ca8c155
Added torchfix
mepland May 23, 2024
d1c9577
Added flake8-markdown
mepland May 23, 2024
b89dabe
Added flake8-executable
mepland May 23, 2024
eaaa381
Added flake8-debugger
mepland May 23, 2024
c9d9018
Added flake8-no-pep420
mepland May 23, 2024
38cb214
Added flake8-datetime-import
mepland May 23, 2024
58b001c
Test GitHub error message for trailing spaces
mepland May 23, 2024
0dd53eb
Revert "Added flake8-datetime-import"
mepland May 23, 2024
1652a54
Test double space
mepland May 23, 2024
5e3467f
Update requests for dependabot
mepland May 23, 2024
70a113d
Test trailing space
mepland May 23, 2024
fdd4e35
Merge branch 'lint' of github.com:mepland/chance_of_showers into lint
mepland May 23, 2024
7055010
remove extra echo
mepland May 23, 2024
a326347
Remove test extra space
mepland May 23, 2024
f6be55a
noqa ISC003 due to special chars or long lines
mepland May 23, 2024
0f773d5
Remove unused type ignores
mepland May 23, 2024
53aaef6
Clear ruff cache
mepland May 27, 2024
dc4221b
Config ruff
mepland May 27, 2024
947a630
Configure ruff
mepland May 27, 2024
784cffe
Ignore ruff PLW3301
mepland May 27, 2024
6dff6c7
ignore ruff
mepland May 27, 2024
ca65b74
immutable, no commented out code
mepland May 27, 2024
86cc301
ruff remove unnecessary pass
mepland May 27, 2024
74d2bc3
Revert "Ignore ruff PLW3301"
mepland May 27, 2024
049bd56
No noqa for ruff, until live
mepland May 27, 2024
17c4210
Add more ruff ignores
mepland May 27, 2024
6bc8508
add ignore
mepland May 27, 2024
b5e8721
immutable
mepland May 27, 2024
eeee057
immutable for all
mepland May 28, 2024
d3b3667
lint
mepland May 28, 2024
06683f7
Fix ruff EM101
mepland May 28, 2024
a030fa3
Fix ruff EM102
mepland May 28, 2024
d950dc2
ruff ignore
mepland May 28, 2024
fa3b931
ruff fix SIM108
mepland May 28, 2024
d548b6f
Ruff fix RUF005
mepland May 28, 2024
4832412
Ruff fix RUF005
mepland May 28, 2024
f0d125b
immutable
mepland May 28, 2024
19a2c67
Fix ruff PLW2901
mepland May 28, 2024
fc3a03a
Fix ruff FBT003
mepland May 28, 2024
5e91c3f
lint
mepland May 28, 2024
945b73e
Fix ruff E721 preview
mepland May 28, 2024
3e12883
Fix ruff E721
mepland May 28, 2024
d3a568c
ruff ignore
mepland May 28, 2024
f362e72
Update make ruff commands
mepland May 28, 2024
5e49e98
Fix __init__.py files
mepland May 28, 2024
9fc80ee
Remove noqa
mepland May 28, 2024
36c6444
fix noqa
mepland May 28, 2024
052a07c
Add dummy doc string
mepland May 28, 2024
dc7291d
Update .vulture_ignore
mepland May 28, 2024
3254dce
Add find_pymend_dummies grep
mepland May 28, 2024
8bad186
order flake8 plugins
mepland Jun 2, 2024
b840547
update typos
mepland Jun 2, 2024
a75bd9a
github to GitHub
mepland Jun 2, 2024
c94aa23
Order linters
mepland Jun 2, 2024
1ed032b
reorder dev depend
mepland Jun 2, 2024
21b562b
Update typos config
mepland Jun 2, 2024
e4cc0e4
update mypy
mepland Jun 2, 2024
8e795e5
Update detect-secrets
mepland Jun 2, 2024
f9b1810
update black
mepland Jun 2, 2024
70af6e0
Update pre-commits
mepland Jun 2, 2024
f4e862b
pre-commit typos needs file ignores in args
mepland Jun 2, 2024
371c82b
Update black
mepland Jun 2, 2024
b3f0d0c
Reorder mypy and pylint
mepland Jun 2, 2024
7f93494
Update and reorder shields
mepland Jun 3, 2024
653989f
Update dev deps
mepland Jun 5, 2024
3398b78
Improve find_noqa_comments
mepland Jun 5, 2024
c9765c6
clean nosec
mepland Jun 5, 2024
bcbda9b
Clean noqa for pylint
mepland Jun 5, 2024
1993954
Clean noqa for pylint
mepland Jun 5, 2024
fbbc264
Clean nosec assert
mepland Jun 5, 2024
d24ad8a
lint
mepland Jun 5, 2024
3083bbd
Clean noqa
mepland Jun 5, 2024
62782a6
use rule name
mepland Jun 5, 2024
cd0c165
sed has no non-greedy
mepland Jun 5, 2024
42b9000
Clean noqa
mepland Jun 5, 2024
3c9d6bd
Clean noqa
mepland Jun 5, 2024
f5935fc
Clean noqa
mepland Jun 5, 2024
70b1c3b
pylint breaks on ipynb
mepland Jun 5, 2024
db700a8
add missing actionlint header
mepland Jun 5, 2024
efc24c6
Comment on success() || failure()
mepland Jun 5, 2024
ea56e79
Add target-version for blacken-docs
mepland Jun 5, 2024
1e71e0f
Run blacken-docs on tex in Makefile
mepland Jun 5, 2024
005cd3c
Update step names
mepland Jun 5, 2024
a888a23
flake8-markdown
mepland Jun 5, 2024
973449a
Do not need it as a plugin
mepland Jun 5, 2024
86b79d1
Update ruff
mepland Jun 5, 2024
6263cd1
Need space for bandit nosec
mepland Jun 5, 2024
334acd9
make flake8-markdown a Makefile only linter
mepland Jun 5, 2024
4ca6d1d
clean up msg
mepland Jun 6, 2024
0fc8284
update safe packages
mepland Jun 6, 2024
062d1b4
update mypy configs
mepland Jun 6, 2024
1d1eb94
mypy lint
mepland Jun 6, 2024
73524c4
allow untyped or Any decorators, since we often do not get to define …
mepland Jun 6, 2024
bfbcc2f
mypy lint
mepland Jun 6, 2024
dcb4cfa
refine disable mypy
mepland Jun 6, 2024
685d06e
mypy lint
mepland Jun 6, 2024
dc2835b
mypy lint
mepland Jun 6, 2024
d92216c
mypy lint
mepland Jun 6, 2024
a2383fa
too many libraries lacking stub / type defs
mepland Jun 6, 2024
c21ea03
mypy lint
mepland Jun 6, 2024
11315ab
use @override
mepland Jun 6, 2024
7f212e7
mypy linting
mepland Jun 7, 2024
8e0dddf
Use TypeAlias
mepland Jun 7, 2024
b21c279
mypy lint
mepland Jun 7, 2024
b421f4a
Use TypeAlias
mepland Jun 7, 2024
500a8c1
mypy lint
mepland Jun 7, 2024
79d84aa
mypy lint
mepland Jun 7, 2024
1c64282
Use # mypy: disable-error-code = "possibly-undefined"
mepland Jun 7, 2024
2f2d4d9
Add note
mepland Jun 7, 2024
ee8b4ee
Add '# type: ignore[no-any-unimported]' for packages that do not have…
mepland Jun 7, 2024
e723c39
black
mepland Jun 7, 2024
c8beae9
switch to local mypy in pre-commit
mepland Jun 7, 2024
53a71e9
mypy lint
mepland Jun 7, 2024
5ed0fc0
Debug why mypy finds errors in actions but not locally
mepland Jun 8, 2024
335fc09
comment
mepland Jun 8, 2024
91cbe01
Update version to match tag
mepland Jun 8, 2024
2cde614
reorg debug so it runs
mepland Jun 8, 2024
82fc5fa
Merge branch 'main' into lint
mepland Jun 8, 2024
97eeeec
Remove mypy debugging
mepland Jun 8, 2024
fc9ee52
mypy lint
mepland Jun 8, 2024
aff0e55
updates for dependabot
mepland Jun 8, 2024
c18c606
use perl instead of sed to get non-greedy
mepland Jun 10, 2024
77c3745
remove disables for pylint
mepland Jun 11, 2024
8b4e17c
Add per file noqa comments
mepland Jun 11, 2024
ca45f46
remove duplicate check with flake8 / ruff
mepland Jun 11, 2024
77c8a09
remove duplicate check
mepland Jun 11, 2024
6858068
remove duplicate check
mepland Jun 11, 2024
b5187a1
remove duplicate check
mepland Jun 11, 2024
67d902e
lints
mepland Jun 11, 2024
b59ca74
clean up flake8 ignores
mepland Jun 11, 2024
bd1e851
lint
mepland Jun 11, 2024
0737105
Specify github format
mepland Jun 11, 2024
da551b7
sort
mepland Jun 11, 2024
82f2527
Try removing import-error
mepland Jun 11, 2024
ac3bd4d
Ignore U101
mepland Jun 12, 2024
041f8ea
prettier
mepland Jun 12, 2024
a36277e
order noqa
mepland Jun 12, 2024
2e35cfd
Update packages
mepland Jun 12, 2024
31c55c3
Update ignore
mepland Jun 12, 2024
94d8d19
keep removes only
mepland Jun 12, 2024
3197266
Try github error annotations
mepland Jun 12, 2024
2b6734b
Test errors
mepland Jun 12, 2024
e1362d5
Revert "Test errors"
mepland Jun 12, 2024
e15e040
Test mktemp
mepland Jun 12, 2024
fee2674
no shell from Makefile
mepland Jun 12, 2024
e857ab3
Test tmp file noqa comments
mepland Jun 24, 2024
bdd95b6
Dependabot updates
mepland Jun 24, 2024
1ae9870
Test
mepland Jun 24, 2024
84e7b74
Test
mepland Jun 24, 2024
855c41b
Test output
mepland Jun 25, 2024
3b4ade2
test
mepland Jun 25, 2024
e7e584d
test
mepland Jun 25, 2024
c90e365
Clean comments
mepland Jun 25, 2024
dedd189
prod test
mepland Jun 25, 2024
9f7d20c
test
mepland Jun 25, 2024
8487b0a
test
mepland Jun 25, 2024
24ebfb6
test
mepland Jun 25, 2024
7c9d130
test
mepland Jun 25, 2024
c4ae780
test bash if
mepland Jun 25, 2024
50da969
test
mepland Jun 25, 2024
062c8ef
Add all if statements
mepland Jun 25, 2024
00b3868
test
mepland Jun 25, 2024
5477c93
prod tests
mepland Jun 25, 2024
6b40c5e
Do not fix B905 as it defaults to strict=False
mepland Jul 1, 2024
0df378c
Remove flake8-implicit-str-concat in favor of flake8-no-implicit-concat
mepland Jul 1, 2024
09d6a09
Add flake8-datetime-import
mepland Jul 1, 2024
fcfcadd
refactor to import datetime as dt, import time as tm
mepland Jul 1, 2024
cf7f797
DTZ005 no longer detected by flake8-datetimez
mepland Jul 1, 2024
3db107f
Revert "Remove flake8-implicit-str-concat in favor of flake8-no-impli…
mepland Jul 1, 2024
409fb09
black
mepland Jul 1, 2024
6681ad4
Run isort with --check-only in tests GH action
mepland Jul 1, 2024
5a21ed7
Set allow-multiline = false for ruff flake8-implicit-str-concat
mepland Jul 1, 2024
6640ca0
ruff ignore UP038
mepland Jul 1, 2024
f0e1ba9
Add any files switch to universal tests
mepland Jul 1, 2024
e0ef073
Add ruff, but do not require passing, to tests
mepland Jul 1, 2024
eb98942
Add --diff for isort to show diff
mepland Jul 2, 2024
86b28ad
Add note about devel packages on Fedora
mepland Jul 14, 2024
61373f4
Split markdownlint into check and -fix
mepland Jul 19, 2024
5c03f92
Update dev package versions
mepland Jul 19, 2024
499a34c
Update rev strs
mepland Jul 19, 2024
e9b5eaf
Update deptry
mepland Jul 19, 2024
3cbf4af
Update poetry version
mepland Jul 19, 2024
0cdb70b
Add more install instructions
mepland Jul 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 14 additions & 20 deletions .dev_config/.vulture_ignore.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
# flake8: noqa
# pylint: skip-file
# mypy: disable-error-code="name-defined"
dfp_val # unused variable (ana/exploratory_ana.py:341)
_.converter # unused attribute (daq/daq.py:145)
dummy_signal # unused variable (daq/daq.py:247)
dummy_frame # unused variable (daq/daq.py:248)
_.when_held # unused attribute (daq/daq.py:309)
_.when_released # unused attribute (daq/daq.py:310)
disconnect # unused function (daq/daq.py:490)
_.show_server_banner # unused attribute (daq/daq.py:511)
args # unused variable (daq/daq.py:511)
pin # unused variable (daq/pulse_test.py:19)
dfp_val # unused variable (ana/exploratory_ana.py:339)
_.converter # unused attribute (daq/daq.py:150)
_.when_held # unused attribute (daq/daq.py:310)
_.when_released # unused attribute (daq/daq.py:311)
disconnect # unused function (daq/daq.py:488)
_.show_server_banner # unused attribute (daq/daq.py:508)
args # unused variable (daq/daq.py:508)
_.when_held # unused attribute (daq/switch_test.py:33)
_.when_released # unused attribute (daq/switch_test.py:34)
pin # unused variable (fan_control/fan_control.py:76)
pytorch_lightning # unused import (TSModelWrappers/TSModelWrapper.py:22)
_.on_exception # unused method (TSModelWrappers/TSModelWrapper.py:170)
trainer # unused variable (TSModelWrappers/TSModelWrapper.py:172)
pl_module # unused variable (TSModelWrappers/TSModelWrapper.py:173)
_.formatwarning # unused attribute (utils/bayesian_opt.py:82)
args # unused variable (utils/bayesian_opt.py:82)
dummy_signal # unused variable (utils/bayesian_opt.py:763)
dummy_frame # unused variable (utils/bayesian_opt.py:764)
_._iterations # unused attribute (utils/bayesian_opt.py:931)
_._previous_max # unused attribute (utils/bayesian_opt.py:932)
_.on_exception # unused method (TSModelWrappers/TSModelWrapper.py:165)
trainer # unused variable (TSModelWrappers/TSModelWrapper.py:168)
pl_module # unused variable (TSModelWrappers/TSModelWrapper.py:169)
_.formatwarning # unused attribute (utils/bayesian_opt.py:87)
args # unused variable (utils/bayesian_opt.py:87)
_._iterations # unused attribute (utils/bayesian_opt.py:935)
_._previous_max # unused attribute (utils/bayesian_opt.py:936)
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ignore all ana ipynb and html files in diffs and github languages stats
# ignore all ana/ ipynb and html files in diffs and GitHub languages stats
ana/*.ipynb linguist-generated=true
ana/*.html linguist-generated=true
# ignore html media files in github languages stats
# ignore media/ html files in GitHub languages stats
media/**/*.html linguist-documentation=true
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# Checklist
* [ ] I have performed a self-review of my own code
* [ ] I have run the `pre-commit` checks
* [ ] The [github `tests` action](https://github.com/mepland/chance_of_showers/actions/workflows/tests.yml) is passing
* [ ] The [GitHub `tests` action](https://github.com/mepland/chance_of_showers/actions/workflows/tests.yml) is passing
* [ ] I have commented my code, particularly in hard-to-understand areas
* [ ] I have updated the documentation as required

Expand Down
154 changes: 114 additions & 40 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.11"]
poetry-version: ["1.8.2"]
poetry-version: ["1.8.3"]
node_version: ["lts/*"]

steps:
Expand All @@ -42,11 +42,11 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: 'poetry'

- name: Install Python Dependencies
- name: Install Python dependencies
run: poetry install --with daq,web,ana,dev

# File filters
- name: Paths Changes Filter
- name: Paths changes filter
uses: dorny/paths-filter@v3
id: filter
with:
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
any:
- added|modified: '**'

- name: Free Disk Space
- name: Free disk space
uses: jlumbroso/free-disk-space@main
with:
# This might remove tools that are actually needed, if set to "true" but frees about 6 GB
Expand All @@ -98,7 +98,7 @@ jobs:
# do not use unless necessary, i.e. when running poetry checks.
large-packages: ${{steps.filter.outputs.poetry}}

# Needed by any dockerized github action
# Needed by any dockerized GitHub action
docker-images: false

# Gets the poetry cache back
Expand All @@ -117,28 +117,22 @@ jobs:
node-version: ${{ matrix.node_version }}
check-latest: true

- name: Install Node Dependencies
- name: Install Node dependencies
if: steps.filter.outputs.javascript == 'true' || steps.filter.outputs.prettier == 'true'
run: sudo npm install --global standard prettier
run: sudo npm install --global standard@latest prettier@latest

# All files
- name: detect-secrets
if: success() || failure()
run: poetry run detect-secrets-hook --exclude-lines 'integrity='
# Use "success() || failure()" to run a step even if a previous step fails
# https://stackoverflow.com/a/58859404

- name: blocklint
if: success() || failure()
run: poetry run blocklint --skip-files=poetry.lock --max-issue-threshold=1
# Python

# poetry
- name: poetry
if: (success() || failure()) && steps.filter.outputs.poetry == 'true'
run: poetry check && poetry lock --no-update

# python
- name: isort
if: (success() || failure()) && steps.filter.outputs.python == 'true'
run: poetry run isort ${{ steps.filter.outputs.python_files }}
run: poetry run isort --check-only --diff ${{ steps.filter.outputs.python_files }}

- name: pyupgrade
if: (success() || failure()) && steps.filter.outputs.python == 'true'
Expand All @@ -148,21 +142,42 @@ jobs:
if: (success() || failure()) && steps.filter.outputs.python == 'true'
run: poetry run black --check --diff ${{ steps.filter.outputs.python_files }}

# yamllint disable rule:line-length
- name: blacken-docs
if: (success() || failure()) && (steps.filter.outputs.python == 'true' || steps.filter.outputs.markdown == 'true' || steps.filter.outputs.rst == 'true' || steps.filter.outputs.tex == 'true')
run: poetry run blacken-docs --line-length=100 --target-version=py311 ${{ steps.filter.outputs.python_files }} ${{ steps.filter.outputs.markdown_files }} ${{ steps.filter.outputs.rst_files }} ${{ steps.filter.outputs.tex_files }}
# yamllint enable rule:line-length

- name: flake8
if: (success() || failure()) && steps.filter.outputs.python == 'true'
run: |
echo "::group::version and plugins"
poetry run flake8 --version
echo "::endgroup::"
poetry run flake8 ${{ steps.filter.outputs.python_files }}
poetry run flake8 --format github ${{ steps.filter.outputs.python_files }}

- name: mypy
# Disable: flake8-markdown does not use the pyproject.toml config correctly
# - name: flake8-markdown
# if: (success() || failure()) && steps.filter.outputs.markdown == 'true'
# run: poetry run flake8-markdown ${{ steps.filter.outputs.markdown_files }}

- name: ruff - not required
if: (success() || failure()) && steps.filter.outputs.python == 'true'
run: poetry run mypy ${{ steps.filter.outputs.python_files }}
run: |
poetry run ruff check --exit-zero ${{ steps.filter.outputs.python_files }}

# https://pylint.pycqa.org/en/latest/user_guide/usage/output.html
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message
# yamllint disable rule:line-length
- name: pylint
if: (success() || failure()) && steps.filter.outputs.python_alone == 'true'
run: poetry run pylint ${{ steps.filter.outputs.python_alone_files }}
run: |
poetry run pylint --msg-template='::error file={path},line={line},endLine={end_line},col={column},endColumn={end_column},title={symbol} ({msg_id})::{obj}: {msg}' ${{ steps.filter.outputs.python_alone_files }}
# yamllint enable rule:line-length

- name: mypy
if: (success() || failure()) && steps.filter.outputs.python == 'true'
run: poetry run mypy ${{ steps.filter.outputs.python_files }}

- name: bandit
if: (success() || failure()) && steps.filter.outputs.python == 'true'
Expand All @@ -176,36 +191,42 @@ jobs:
if: (success() || failure()) && steps.filter.outputs.python == 'true'
run: poetry run deptry . # Runs on whole package

# javascript
# Javascript

- name: standard
if: (success() || failure()) && steps.filter.outputs.javascript == 'true'
run: standard ${{ steps.filter.outputs.javascript_files }}

# html
# HTML

- name: html5validator
if: (success() || failure()) && steps.filter.outputs.html == 'true'
uses: Cyb3r-Jak3/html5validator-action@master # blocklint: pragma
with:
config: .dev_config/.html5validator.yaml
# only configurable to run on paths, so just run on whole package

# prettier: html css scss json
# Prettier: HTML CSS SCSS JSON (TOML plugin broken in GitHub actions)

- name: prettier
if: (success() || failure()) && steps.filter.outputs.prettier == 'true'
id: prettier
run: prettier --ignore-path .dev_config/.prettierignore --ignore-path .gitignore --config .dev_config/.prettierrc.yaml --check ${{ steps.filter.outputs.prettier_files }} # yamllint disable-line rule:line-length

# yaml
# YAML

- name: yamllint
if: (success() || failure()) && steps.filter.outputs.yaml == 'true'
run: poetry run yamllint -c .dev_config/.yamllint.yaml --strict ${{ steps.filter.outputs.yaml_files }} # yamllint disable-line rule:line-length
run: poetry run yamllint --format github -c .dev_config/.yamllint.yaml --strict ${{ steps.filter.outputs.yaml_files }} # yamllint disable-line rule:line-length

# Makefile

# makefile
- name: checkmake
if: (success() || failure()) && steps.filter.outputs.makefile == 'true'
uses: Uno-Takashi/checkmake-action@main # Can not pass multiple files

# shell files - no extension to filter on, always run
# Shell scripts - no extension to filter on, always run

- name: shellcheck shfmt checkbashisms
if: success() || failure()
uses: luizm/action-sh-checker@master # blocklint: pragma
Expand All @@ -214,14 +235,8 @@ jobs:
with:
sh_checker_checkbashisms_enable: true

# typos - always run
- name: typos
if: success() || failure()
uses: crate-ci/[email protected]
with:
config: pyproject.toml
# Markdown

# docs
- name: markdownlint
if: (success() || failure()) && steps.filter.outputs.markdown == 'true'
uses: nosborn/[email protected]
Expand All @@ -231,19 +246,78 @@ jobs:
config_file: .dev_config/.markdownlint.yaml
ignore_files: LICENSE.md

- name: blacken-docs
if: (success() || failure()) && (steps.filter.outputs.python == 'true' || steps.filter.outputs.markdown == 'true' || steps.filter.outputs.rst == 'true' || steps.filter.outputs.tex == 'true') # yamllint disable-line rule:line-length
run: poetry run blacken-docs --line-length=100 ${{ steps.filter.outputs.python_files }} ${{ steps.filter.outputs.markdown_files }} ${{ steps.filter.outputs.rst_files }} ${{ steps.filter.outputs.tex_files }} # yamllint disable-line rule:line-length
# All files

- name: detect-secrets
if: (success() || failure()) && steps.filter.outputs.any == 'true'
run: poetry run detect-secrets-hook --exclude-lines 'integrity=' ${{ steps.filter.outputs.any_files }} # yamllint disable-line rule:line-length

- name: blocklint
if: (success() || failure()) && steps.filter.outputs.any == 'true'
run: poetry run blocklint --skip-files=poetry.lock --max-issue-threshold=1 ${{ steps.filter.outputs.any_files }} # yamllint disable-line rule:line-length

- name: typos
if: (success() || failure()) && steps.filter.outputs.any == 'true'
uses: crate-ci/[email protected]
with:
config: pyproject.toml
files: ${{ steps.filter.outputs.any_files }}

- name: trailing-spaces
- name: Trailing spaces
if: (success() || failure()) && steps.filter.outputs.any == 'true'
run: |
TRAILING_SPACES=$(grep -rInH ' $' ${{ steps.filter.outputs.any_files }} || true)
if [[ $TRAILING_SPACES ]]; then
echo "Trailing spaces found, please remove them:"
echo "::error::Trailing spaces found, please remove them"
echo "$TRAILING_SPACES"
false
else
echo "No trailing spaces found."
true
fi

# yamllint disable rule:line-length
- name: noqa flags
if: (success() || failure()) && steps.filter.outputs.any == 'true'
run: |
TMP_FIND_NOQA_COMMENTS=$(mktemp /tmp/find_noqa_comments.XXXXXX)
# isort, flake8, ruff, pylint, mypy, bandit
if [[ ${{ steps.filter.outputs.python }} == 'true' ]]; then
grep -rInH 'isort:\|noqa\|pylint\| type:\|nosec' ${{ steps.filter.outputs.python_files }} >> $TMP_FIND_NOQA_COMMENTS || true
fi
# standard
if [[ ${{ steps.filter.outputs.javascript }} == 'true' ]]; then
grep -rInH 'eslint' ${{ steps.filter.outputs.javascript_files }} >> $TMP_FIND_NOQA_COMMENTS || true
fi
# prettier
if [[ ${{ steps.filter.outputs.prettier }} == 'true' ]]; then
grep -rInH 'prettier-ignore' ${{ steps.filter.outputs.prettier_files }} >> $TMP_FIND_NOQA_COMMENTS || true
fi
# yamllint
if [[ ${{ steps.filter.outputs.yaml }} == 'true' ]]; then
grep -rInH 'yamllint [de]' ${{ steps.filter.outputs.yaml_files }} >> $TMP_FIND_NOQA_COMMENTS || true
fi
# markdownlint
if [[ ${{ steps.filter.outputs.markdown }} == 'true' ]]; then
grep -rInH 'markdownlint-[de]' ${{ steps.filter.outputs.markdown_files }} >> $TMP_FIND_NOQA_COMMENTS || true
fi
# detect-secrets, blocklint
grep -rInH 'pragma: allowlist\|blocklint:.*pragma' ${{ steps.filter.outputs.any_files }} >> $TMP_FIND_NOQA_COMMENTS || true
# Remove false positive lines from Makefile and .pre-commit-config.yaml
sed -i -r '/^Makefile:[0-9]+:(# detect-secrets ~|# blocklint ~|.*grep)/d' $TMP_FIND_NOQA_COMMENTS
# Remove code, keep comments
perl -pi -E 's/(^.*?:[0-9]+:).*?(#|<\!-- )/\1\2/g' $TMP_FIND_NOQA_COMMENTS
# Sort and remove duplicates
sort -u -o $TMP_FIND_NOQA_COMMENTS $TMP_FIND_NOQA_COMMENTS
# Print results
if [[ -s $TMP_FIND_NOQA_COMMENTS ]]; then
echo "::warning::The following lines contain noqa comments"
cat $TMP_FIND_NOQA_COMMENTS
else
echo "No noqa flags found."
fi
# Remove temporary file
rm -f $TMP_FIND_NOQA_COMMENTS
# Always pass, just warn
true
# yamllint enable rule:line-length
Loading
Loading