Skip to content

Commit

Permalink
tools: add makefile for local formatting and linting
Browse files Browse the repository at this point in the history
Signed-off-by: Packet Please <[email protected]>
  • Loading branch information
pktpls committed Apr 3, 2024
1 parent 59187a5 commit 0d15ef6
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Makefile
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

0 comments on commit 0d15ef6

Please sign in to comment.