-
Notifications
You must be signed in to change notification settings - Fork 791
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
fix: lint errors from scripts/checkstyle.py
#1385
Conversation
0c1be65
to
d215961
Compare
My personal opinions of Python aside, this looks fine to me as a starting point. I prefer to use existing tooling if it exists with options to configure regex checks and fixes, but I couldn't find anything with a quick look. So, something custom now that is usable is great. We can always come back to it. Would be good to add Python to this repository's And adding the GitHub Action step now would be fine, no need to wait for another PR, just another step in the |
checkstyle.py
script scripts/checkstyle.py
for improved style linting
Sounds good! - In that case I'll run the script on every file so there aren't a million different lint commits |
dd2dbf5
to
4350aff
Compare
This script checks things that shellcheck fails to.
The following command was executed twice: $ ./scripts/checkstyle.py ./lib/functions/plugins.bash --fix
4350aff
to
39aee9a
Compare
39aee9a
to
ef55bc5
Compare
I made those changed 👍 The regex was also updated to match within any case of double-quotes (not just after |
Building on your comment - #1349 (comment)
Is there a reason we can't capture this like we do While the automated fix is nice, we only need the automated fix once, then we can just ban with regex checks right? |
I am going to merge, we can always back out these scripts which are part of CI. |
scripts/checkstyle.py
for improved style lintingscripts/checkstyle.py
for improved style linting
scripts/checkstyle.py
for improved style lintingscripts/checkstyle.py
Cheers @hyperupcall |
Co-authored-by: James Hegedus <[email protected]>
This reverts commit 3492043 due to breaking changes in some contexts. To reproduce the error, install `asdf` versions of `node` and `python` then use `npm` to install `markov-pwgen`, whose installer runs a python script. Here is the output: ```shell npm i -g markov-pwgen ``` > npm ERR! code 126 > npm ERR! path /home/alm/.asdf/installs/nodejs/18.12.1/lib/node_modules/markov-pwgen > npm ERR! command failed > npm ERR! command sh -c test -f dictionary.js || ./scripts/filter-wordlist.py > npm ERR! No preset version installed for command python3 > npm ERR! Please install a version by running one of the following: > npm ERR! > npm ERR! asdf install python 3.10.9 > npm ERR! > npm ERR! or add one of the following versions in your config file at /home/alm/.asdf/.tool-versions > npm ERR! python 3.11.1 > > npm ERR! A complete log of this run can be found in: > npm ERR! /home/alm/.npm/_logs/2022-12-28T16_47_59_838Z-debug-0.log
This reverts commit 3492043 due to breaking changes in some contexts. To reproduce the error, install `asdf` versions of `node` and `python` then use `npm` to install `markov-pwgen`, whose installer runs a python script. Here is the output: ```shell npm i -g markov-pwgen ``` > npm ERR! code 126 > npm ERR! path /home/alm/.asdf/installs/nodejs/18.12.1/lib/node_modules/markov-pwgen > npm ERR! command failed > npm ERR! command sh -c test -f dictionary.js || ./scripts/filter-wordlist.py > npm ERR! No preset version installed for command python3 > npm ERR! Please install a version by running one of the following: > npm ERR! > npm ERR! asdf install python 3.10.9 > npm ERR! > npm ERR! or add one of the following versions in your config file at /home/alm/.asdf/.tool-versions > npm ERR! python 3.11.1 > > npm ERR! A complete log of this run can be found in: > npm ERR! /home/alm/.npm/_logs/2022-12-28T16_47_59_838Z-debug-0.log
Move python from ~/.asdf/.tool-versions to ~/.asdf/scripts/.tool-versions. Prior to this change, Python scripts under ~/.asdf attempted to open the python version defined in ~/.asdf/.tool-versions, which generally won't be installed.
Summary
Sorry for the onslaught of PR's, this is going to be the last one until all the other ones are either closed or merged. This adds preliminary support for an automated way of enforcing particular styles that shellcheck doesn't catch.
Right now, it's a simple Python file (instead the originally proposed Perl for obvious readability reasons), which just checks a single "rule" - "unecessary printf backslashes".
The second commit uses this rule to format a single file like so:
--fix
is not supplied, then it only prints out the errors*.{bash,sh,bats}
.I have the regular expressions and will write auto-fixers for each of the fixed things from #1349, but I'm only adding them one-at-a-time as stated.
Soon I guess it would be good to add GitHub actions and stuff, but I think should that be in a separate PR? I'm also looking for feedback on the checkstyle script, hopefully it's readable enough?