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*

16
LICENSE
View File

@ -1,8 +1,8 @@
Apache License
Version 2.0, January 2004
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
@ -10,7 +10,7 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the
copyright owner that is granting the License.
copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other
entities that control, are controlled by, or are under common control
@ -21,7 +21,7 @@ of fifty percent (50%) or more of the outstanding shares, or (iii)
beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising
permissions granted by this License.
permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation source,
@ -30,12 +30,12 @@ and configuration files.
"Object" form shall mean any form resulting from mechanical transformation
or translation of a Source form, including but not limited to compiled
object code, generated documentation, and conversions to other media
types.
types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a copyright
notice that is included in or attached to the work (an example is provided
in the Appendix below).
in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form,
that is based on (or derived from) the Work and for which the editorial
@ -170,7 +170,7 @@ hold each Contributor harmless for any liability incurred by, or claims
asserted against, such Contributor by reason of your accepting any such
warranty or additional liability.
END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.

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:

View File

@ -15,7 +15,7 @@ if [[ ! -d $tools_bin_dir/node-$node_version ]]; then
mv $tools_bin_dir/node-$node_version-linux-x64 $tools_bin_dir/node-$node_version
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
# Mac OSX
if ! curl -sfL "https://nodejs.org/dist/$node_version/node-$node_version-darwin-x64.tar.gz" | tar zxf - --directory "$tools_bin_dir"; then
printf "Something went wrong while installing Mac OSX nodejs\n" 1>&2
exit 1

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