Incorporate the whitespace linter from the CTL project

This just brings over the whitespace linter and updates any
files that may have been out of compliance.  It's also a small
update to .gitignore to not care about the .out files generated
by a make cover command.

Change-Id: I3e5a4f170f0fd7724949708a290a1e13def834fb
This commit is contained in:
Schiefelbein, Andrew 2020-07-22 13:40:32 -05:00
parent 7b0fe7a7d1
commit cb9fa2624a
5 changed files with 28 additions and 10 deletions

2
.gitignore vendored
View File

@ -1,5 +1,5 @@
# Coverage File
coverage.out
*.out
tools/bin
tools/*node*

View File

@ -154,9 +154,16 @@ docs:
.PHONY: lint
lint: tidy $(LINTER) $(NPX)
@echo "Performing linting steps..."
@echo "Running whitespace linting step..."
@./tools/whitespace_linter
@echo "Running golangci-lint linting step..."
$(LINTER) run --config $(LINTER_CONFIG)
@echo "Running eslint for JavaScript linting step..."
cd $(WEBDIR) && (PATH="$(PATH):$(JSLINTER_BIN)"; $(NPX) --no-install eslint js) && cd ..
@echo "Running eslint for HTML linting step..."
cd $(WEBDIR) && (PATH="$(PATH):$(JSLINTER_BIN)"; $(NPX) --no-install eslint --ext .html .) && cd ..
@echo "Linting completed successfully"
.PHONY: tidy
tidy:

11
tools/whitespace_linter Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
# git 1.9.0+ allows for exclusions in pathspecs via ':!foo' syntax.
# However, until git 2.13.0 there must be at least one "inclusive" pathspec, hence the './*'
trailing_whitespace=$(git grep -E -n -- ' +$' -- './*' ':!*.png' ':!*.jpg')
if [[ -n "$trailing_whitespace" ]]; then
printf "ERROR: Trailing whitespaces:\n"
awk 'BEGIN {FS=":"} {printf " * %s:%s\n", $1, $2}' <<< "$trailing_whitespace"
exit 1
fi