From cb9fa2624a4b7a7d50ec9a183add7287c7119d16 Mon Sep 17 00:00:00 2001 From: "Schiefelbein, Andrew" Date: Wed, 22 Jul 2020 13:40:32 -0500 Subject: [PATCH] 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 --- .gitignore | 2 +- LICENSE | 16 ++++++++-------- Makefile | 7 +++++++ tools/install_js_linter | 2 +- tools/whitespace_linter | 11 +++++++++++ 5 files changed, 28 insertions(+), 10 deletions(-) create mode 100755 tools/whitespace_linter diff --git a/.gitignore b/.gitignore index 14eace3..9bc2bb5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # Coverage File -coverage.out +*.out tools/bin tools/*node* diff --git a/LICENSE b/LICENSE index 744ae56..fac7037 100644 --- a/LICENSE +++ b/LICENSE @@ -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. diff --git a/Makefile b/Makefile index fca0140..6cf313a 100755 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/tools/install_js_linter b/tools/install_js_linter index 35575e6..f70ad9d 100755 --- a/tools/install_js_linter +++ b/tools/install_js_linter @@ -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 diff --git a/tools/whitespace_linter b/tools/whitespace_linter new file mode 100755 index 0000000..fe16711 --- /dev/null +++ b/tools/whitespace_linter @@ -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