psprint / zsh-sweep Goto Github PK
View Code? Open in Web Editor NEWLinter for Zshell scripting language
License: MIT License
Linter for Zshell scripting language
License: MIT License
I've tried following various versions of the installation instructions; they don't seem to work.
Recreation (this isn't the standard installation method but to illustrate the problem):
git clone https://github.com/psprint/zsh-sweep <some_temporary_dir>
cd <some_temporary_dir>
source zsh-sweep.plugin.zsh
zsweep <some_zsh_file>
Gives:
zsh: command not found: zsweep
This is with zsh 5.8.1 (x86_64-apple-darwin21.0)
Am I using it right?
I'm wondering if anyone has considered integrating zsh-sweep into Visual Studio Code? I'm in the process of researching it, but figured I'd ask if anyone has done it already.
When I add
zs_set_path=1
source /Users/fharper/zsh-sweep/zsh-sweep.plugin.zsh
to my ~/.zshrc
, I get this error util/zs::setup-aliases:29: scalar parameter REPLY created globally in function util/zs::setup-aliases
and the command doesn't exist, which I assume it's because the aliases weren't created.
Any idea what is causing this?
--
macOS 13.3 build 22E252 on arm64
zsh 5.9 (x86_64-apple-darwin22.0)
The global vars check creates a lot of false positives because of how simple it is. It seems to ignore almost all context. Consider this example:
(
a='a'
)
bar() (
b='b'
)
c='c' true
local arr=(
d='d'
)
e='e'; export e
python - <<'EOF'
f='f'
print(f)
EOF
All of those variable-like patterns should be fine ('d' and 'f' are not even variables), but zsh-sweep complains about all of them. 'f' is the most problematic, because it's not always practical to add a shell-style comment inside of a heredoc in order to suppress it. Another problem is that zsh-sweep complains about implicitly global variables being set outside of functions, even in --script mode, where there is no practical difference between local and global AFAIK.
Notice: running check: CHECK_FUNCTION_SETS_GLOBAL_VARS_PRE…
Notice: running check: CHECK_FUNCTION_SETS_GLOBAL_VARS_POST…
[ZSweep][zsfilt:184]: Error: Error near line #2 ↔ a='a':
[ZSweep][zsfilt:184]: Error: Error near line #6 ↔ b='b':
[ZSweep][zsfilt:184]: Error: Error near line #9 ↔ c='c' true:
[ZSweep][zsfilt:184]: Error: Error near line #12 ↔ d='d':
[ZSweep][zsfilt:184]: Error: Error near line #15 ↔ e='e'; export e:
[ZSweep][zsfilt:184]: Error: Error near line #18 ↔ f='f':
[ZSweep][zscan:125]: Warning: A global variable has been created without declaration, by assignment. Add a line like local VAR or typeset -g VAR so that the variable is defined before use.
Less concerning are the false negatives like this, which zsh-sweep does not see as variables:
{ a='a' }
foo() { b='b' }
I think moving details about which file is being scanned, into the individual warning lines, would help to clean up the noisy log output.
It seems like get-prj-dir is trying to print something, but can't because there is no function named tigmsg:
util/zs::get-prj-dir:30: command not found: tigmsg
This was proposed on Reddit.
https://www.reddit.com/r/zsh/comments/10nb0y0/announcing_zshscan_a_zshlinter_zsh/
I like how shellcheck assigns each type of error or warning with a code, that optimistically corresponds to a page on their wiki to read more about it.
So for example with zsh-sweep, it tells me:
Notice: running check: CHECK_ZERO_ASSIGNMENT…
[ZSweep][zscan:125]: Warning: $0 assignment is missing, it should be:
·0=${${(M)${0::=${(%):-%x}}:#/*}:-$PWD/$0}
Notice: running check: CHECK_ZERO_ASSIGNMENT_STD…
[ZSweep][zscan:125]: Warning: $0 setting isn't the standard one, it's best if it's:
·0=${${(M)${0::=${(%):-%x}}:#/*}:-$PWD/$0}
It would be great if the project had wiki pages or readme sections or something corresponding to CHECK_ZERO_ASSIGNMENT and CHECK_ZERO_ASSIGNMENT_STD, where a user can learn more about the what and why of those warnings and suggested solutions.
Then there are a bunch of lines like:
[ZSweep][zsfilt:184]: Error: near line #2399 ↔ words=(pip-compile $words):
but it doesn't identify the error by a code or name or description, so I can't tell what's wrong.
EDIT:
Then there are some warnings like:
[ZSweep][zscan:125]: Warning: Incorrect array append, it should say: arr+=(elem) not: arr+=elem which doesn't work on various occasions.
and
[ZSweep][zscan:125]: Warning: A global variable has been created without declaration, by assignment. Add a line like local VAR or typeset -g VAR so that the variable is defined before use.
but they don't seem to indicate where in my source these issues are encountered.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.