forked from freifunk-berlin/falter-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools: add makefile for local formatting and linting
Signed-off-by: Packet Please <[email protected]>
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 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,40 @@ | ||
|
||
LUAPATH = $(HOME)/.luarocks/bin | ||
PIPPATH = $(HOME)/.local/bin | ||
|
||
help: | ||
@echo | ||
@echo 'Available commands:' | ||
@echo ' make deps - Install the prerequisite code analysis tools.' | ||
@echo ' make fmt - Apply automatic code formatting. (shell)' | ||
@echo ' make lint - Check for frequent issues in code. (shell, lua)' | ||
@echo | ||
.PHONY: help | ||
|
||
deps: | ||
luarocks --local install luacheck | ||
pip install black isort pylint flake8 | ||
@echo | ||
@echo 'Done. Please also install manually with apt or dnf: shellcheck shfmt gitleaks' | ||
@echo | ||
.PHONY: deps | ||
|
||
fmt: shfmt # TODO: black isort | ||
.PHONY: fmt | ||
|
||
lint: shellcheck luacheck # TODO: gitleaks flake8 pylint | ||
.PHONY: lint | ||
|
||
shfmt: | ||
shfmt -w -l -ln=mksh -i 4 -ci -bn ./luci/ ./packages/ | ||
.PHONY: shfmt | ||
|
||
shellcheck: | ||
# The excluded cases are supported by Busybox but not POSIX. | ||
# TODO update to shellcheck 0.10 for busybox sh support | ||
grep -rIzl '^#![[:blank:]]*/bin/sh' ./packages ./luci | xargs shellcheck -S warning -e SC3003,SC3014,SC3018,SC3020,SC3039,SC3043,SC3060 | ||
.PHONY: shellcheck | ||
|
||
luacheck: | ||
$(LUAPATH)/luacheck ./packages ./luci -q -o 'nowarningsplease' | ||
.PHONY: luacheck |