fboender / multi-git-status

Show uncommitted, untracked and unpushed changes for multiple Git repos
MIT License
470 stars 73 forks source link

manage shellcheck warnings #59

Closed infrastation closed 2 months ago

infrastation commented 2 months ago

Thank you for developing this script. You may want to use shellcheck to maintain code quality and to detect some bugs automatically.

The first step would be fixing the existing warnings:

mgitstatus:186:30: note: Use find instead of ls to better handle non-alphanumeric filenames. [SC2012]
mgitstatus:188:24: note: Don't use variables in the printf format string. Use printf '..%s..' "$foo". [SC2059]
mgitstatus:202:24: note: Don't use variables in the printf format string. Use printf '..%s..' "$foo". [SC2059]
mgitstatus:211:20: note: Don't use variables in the printf format string. Use printf '..%s..' "$foo". [SC2059]
mgitstatus:280:38: note: Don't use variables in the printf format string. Use printf '..%s..' "$foo". [SC2059]
mgitstatus:281:38: note: Don't use variables in the printf format string. Use printf '..%s..' "$foo". [SC2059]
mgitstatus:282:42: note: Don't use variables in the printf format string. Use printf '..%s..' "$foo". [SC2059]
mgitstatus:304:44: note: Don't use variables in the printf format string. Use printf '..%s..' "$foo". [SC2059]
mgitstatus:309:44: note: Don't use variables in the printf format string. Use printf '..%s..' "$foo". [SC2059]
mgitstatus:314:44: note: Don't use variables in the printf format string. Use printf '..%s..' "$foo". [SC2059]
mgitstatus:319:44: note: Don't use variables in the printf format string. Use printf '..%s..' "$foo". [SC2059]
mgitstatus:324:44: note: Don't use variables in the printf format string. Use printf '..%s..' "$foo". [SC2059]
mgitstatus:329:44: note: Don't use variables in the printf format string. Use printf '..%s..' "$foo". [SC2059]
mgitstatus:335:71: note: Don't use variables in the printf format string. Use printf '..%s..' "$foo". [SC2059]
mgitstatus:341:24: note: Don't use variables in the printf format string. Use printf '..%s..' "$foo". [SC2059]

The second step would be running shellcheck from a CI system for every commit and pull request. One possible way to do it would be using Cirrus CI, you can model the configuration after this example. Unfortunately, Cirrus CI does not support e-mail notifications, but the service is still free (up to a monthly limit) for open source software projects.

fboender commented 2 months ago

Hey Denis!

Thank you for pointing this out. Multi-git-status already uses Shellcheck. There's a test rule in the Makefile that executes it.

The problems found by Shellcheck that you listed are known, but have reasons for why they're still being used. See above link for excludes and their reasoning.

make test is called in a git pre-commit hook locally in my repo, so that it runs automatically before I commit.

infrastation commented 2 months ago

I did not notice the existing invocation, excuse me. Arguably, there are potential ways to resolve/reduce these warnings, let me know if you would be interested to see a pull request.