[VOL-2870]v2
- Enable YAML/JSON linting
- Fix formatting in files
- Fix minor shellcheck issue on voltha tool
Change-Id: I6d29830a7b60c32e09aca49b22125c350c4d1693
diff --git a/Makefile b/Makefile
index 4c61b4e..e22fe44 100644
--- a/Makefile
+++ b/Makefile
@@ -6,9 +6,9 @@
SHELL = bash -eu -o pipefail
.DEFAULT_GOAL := help
-.PHONY: test shellcheck yamllint jsonlint help
+.PHONY: test shellcheck yamllint lint-json help
-test: shellcheck ## run all tests
+test: shellcheck lint-json yamllint ## run all tests
SHELL_FILES := voltha
shellcheck: ## check shell scripts with shellcheck
@@ -23,11 +23,14 @@
-s $(YAML_FILES)
JSON_FILES ?= $(shell find . -type f -name '*.json' -print )
-jsonlint: ## lint check JSON files with yamllint
- echo "Not supported yet, would check these files: $(JSON_FILES)"
+lint-json: ## lint check JSON files by loading them with python
+ for jsonfile in $(JSON_FILES); do \
+ echo "Validating json file: $$jsonfile" ;\
+ python -m json.tool $$jsonfile > /dev/null ;\
+ done
-help: ## Print help for each target
+help: ## Print help for each Makefile target
@echo kind-voltha Makefile targets
@echo
- @grep '^[[:alpha:]_-]*:.* ##' $(MAKEFILE_LIST) \
+ @grep '^[[:alnum:]_-]*:.* ##' $(MAKEFILE_LIST) \
| sort | awk 'BEGIN {FS=":.* ## "}; {printf "%-25s %s\n", $$1, $$2};'