Support groovy lint exclusions
makefiles/utils/include.mk
--------------------------
o Added helper method path-by-makefile.
o Derive a path relative to an active makefile.
makefiles/lint/groovy/include.mk
makefiles/lint/groovy/.groovylintrc.json
makefiles/lint/groovy/urls
----------------------------------------
o make lint-groovy: pass argument --config to npm-groovy-lint.
o Bulk filter subjective and personal-preference items to help
shrink logfile size until the warning volume is under control.
o https://github.com/nvuillam/npm-groovy-lint/blob/main/lib/.groovylintrc-recommended.json
[HOWTO: test]
% git clone onf-make
% cd onf-make
% make lint-groovy HIDE=
Display command line being launched (HIDE=@ cleared):
[...] npm-groovy-lint --config "...../onf-make/makefiles/lint/groovy/.groovylintrc.json"
Change-Id: I0f3bf3f7f949d7911c89e809f1702a1615418ea6
diff --git a/makefiles/lint/groovy/.groovylintrc.json b/makefiles/lint/groovy/.groovylintrc.json
new file mode 100644
index 0000000..3392108
--- /dev/null
+++ b/makefiles/lint/groovy/.groovylintrc.json
@@ -0,0 +1,46 @@
+{
+ "extends": "all",
+ "rules": {
+ "basic.DeadCode": "error",
+ "convention.CompileStatic": {
+ "severity": "info"
+ },
+ "convention.FieldTypeRequired": "info",
+ "convention.IfStatementCouldBeTernary": "info",
+ "convention.NoDef": "info",
+ "convention.TrailingComma": "off",
+ "convention.VariableTypeRequired": "info",
+ "dry.DuplicateListLiteral": "info",
+ "dry.DuplicateMapLiteral": "warning",
+ "dry.DuplicateNumberLiteral": {
+ "ignoreNumbers": [0, 1, 2, 3, -1],
+ "severity": "info"
+ },
+ "dry.DuplicateStringLiteral": "info",
+ "exceptions.ThrowException": "info",
+ "exceptions.ThrowNullPointerException": "info",
+ "exceptions.ThrowRuntimeException": "info",
+ "exceptions.ThrowThrowable": "info",
+ "formatting.BracesForClass": "info",
+ "formatting.BracesForForLoop": "info",
+ "formatting.BracesForIfElse": "off",
+ "formatting.BracesForMethod": "off",
+ "formatting.BracesForTryCatchFinally": "off",
+ "formatting.Indentation": {
+ "spacesPerIndentLevel": 4,
+ "severity": "info"
+ },
+ "formatting.SpaceAroundMapEntryColon": "off",
+ "groovyism.ExplicitCallToEqualsMethod": "info",
+ "logging.Println": "off",
+ "unused.UnusedArray": "error",
+ "unused.UnusedObject": "error",
+ "unused.UnusedPrivateField": "error",
+ "unused.UnusedPrivateMethod": "error",
+ "unused.UnusedPrivateMethodParameter": "error",
+ "unused.UnusedVariable": "error",
+ "unnecessary.UnnecessaryReturnKeyword": "off"
+ },
+ "see-also" : {
+ ".groovylintrc-recommended.json" : "https://github.com/nvuillam/npm-groovy-lint/blob/main/lib/.groovylintrc-recommended.json" }
+}
diff --git a/makefiles/lint/groovy/include.mk b/makefiles/lint/groovy/include.mk
index a2406d4..9cc80c3 100644
--- a/makefiles/lint/groovy/include.mk
+++ b/makefiles/lint/groovy/include.mk
@@ -1,6 +1,6 @@
# -*- makefile -*-
# -----------------------------------------------------------------------
-# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# Copyright 2022-2024 Open Networking Foundation (ONF) and the ONF Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -14,9 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# -----------------------------------------------------------------------
-# https://gerrit.opencord.org/plugins/gitiles/onf-make
-# ONF.makefiles.lint.groovy.version = 1.1.1 (+local edits)
-# -----------------------------------------------------------------------
##-------------------##
##---] GLOBALS [---##
@@ -24,7 +21,11 @@
groovy-check := npm-groovy-lint
+groovy-check-conf := $(call path-by-makefile,.groovylintrc.json)
+
groovy-check-args := $(null)
+groovy-check-args += --config "$(groovy-check-conf)"
+
# groovy-check-args += --loglevel info
# groovy-check-args += --ignorepattern
# groovy-check-args += --verbose
diff --git a/makefiles/lint/groovy/urls b/makefiles/lint/groovy/urls
index 4d9ba27..5c04c73 100644
--- a/makefiles/lint/groovy/urls
+++ b/makefiles/lint/groovy/urls
@@ -8,4 +8,6 @@
# Homepage
installhttps://nvuillam.github.io/npm-groovy-lint/
+https://github.com/nvuillam/npm-groovy-lint/blob/main/lib/.groovylintrc-recommended.json
+
# [EOF]
diff --git a/makefiles/utils/include.mk b/makefiles/utils/include.mk
index 5a7678f..6090a17 100644
--- a/makefiles/utils/include.mk
+++ b/makefiles/utils/include.mk
@@ -1,6 +1,6 @@
# -*- makefile -*-
# -----------------------------------------------------------------------
-# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# Copyright 2022-2024 Open Networking Foundation (ONF) and the ONF Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -24,6 +24,30 @@
if-not = $(info 1=$(1), 2=$(2), 3=$(3))\
$(if $(1),$(null),$(2))
+## -----------------------------------------------------------------------
+## Intent: Derive a filesystem path relative to the active makefile.
+## Primary use is loading adjacent tool config files.
+## Immediate evaluation (:=) needed to preserve path context.
+## Note: We could pass in var=MAKEFILE_LIST
+## -----------------------------------------------------------------------
+## Given:
+## scalar Filename to construct a path for
+## Return:
+## scalar Constructed path for the given filename
+## -----------------------------------------------------------------------
+## Usage:
+## groovy-check-conf := $(call path-by-makefile,.groovylintrc.json)
+## groovy-cmd = npm-groovy-lint --config "$(groovy-check-conf)"
+## -----------------------------------------------------------------------
+path-by-makefile = $(strip \
+ $(foreach filename,$(1),\
+ $(foreach makefile,$(lastword $(MAKEFILE_LIST)),\
+ $(foreach makedir,$(subst /include.mk,$(null),$(makefile)),\
+ $(makedir)/$(filename)\
+ )\
+ ))\
+)
+
$(if $(DEBUG),$(warning LEAVE))
# [EOF]