diff --git a/Makefile b/Makefile index 981c92f2a..77c5f41e0 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2024 Franco Fichtner +# Copyright (c) 2015-2025 Franco Fichtner # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions diff --git a/Mk/plugins.mk b/Mk/plugins.mk index b9f2b0b76..b1d3482eb 100644 --- a/Mk/plugins.mk +++ b/Mk/plugins.mk @@ -350,89 +350,15 @@ clean: check fi @rm -rf ${.CURDIR}/work +COREREFDIR= ${.CURDIR}/../../../core + +.-include "${COREREFDIR}/Mk/lint.mk" + lint-desc: check @if [ ! -f ${.CURDIR}/${PLUGIN_DESC} ]; then \ echo ">>> Missing ${PLUGIN_DESC}"; exit 1; \ fi -lint-shell: - @for FILE in $$(find ${.CURDIR}/src -name "*.sh" -type f); do \ - if [ "$$(head $${FILE} | grep -c '^#!\/')" == "0" ]; then \ - echo "Missing shebang in $${FILE}"; exit 1; \ - fi; \ - sh -n "$${FILE}" || exit 1; \ - done - -lint-xml: - @find ${.CURDIR}/src \ - -name "*.xml" -type f -print0 | xargs -0 -n1 xmllint --noout - -lint-model: - @if [ -d ${.CURDIR}/src/opnsense/mvc/app/models ]; then for MODEL in $$(find ${.CURDIR}/src/opnsense/mvc/app/models -depth 3 \ - -name "*.xml"); do \ - (xmllint $${MODEL} --xpath '//*[@type and not(@type="ArrayField") and (not(Required) or Required="N") and Default]' 2> /dev/null | grep '^<' || true) | while read LINE; do \ - echo "$${MODEL}: $${LINE} has a spurious default value set"; \ - done; \ - (xmllint $${MODEL} --xpath '//*[@type and not(@type="ArrayField") and Default=""]' 2> /dev/null | grep '^<' || true) | while read LINE; do \ - echo "$${MODEL}: $${LINE} has an empty default value set"; \ - done; \ - (xmllint $${MODEL} --xpath '//*[@type and not(@type="ArrayField") and BlankDesc="None"]' 2> /dev/null | grep '^<' || true) | while read LINE; do \ - echo "$${MODEL}: $${LINE} blank description is the default"; \ - done; \ - (xmllint $${MODEL} --xpath '//*[@type and not(@type="ArrayField") and BlankDesc and Required="Y"]' 2> /dev/null | grep '^<' || true) | while read LINE; do \ - echo "$${MODEL}: $${LINE} blank description not applicable on required field"; \ - done; \ - (xmllint $${MODEL} --xpath '//*[@type and not(@type="ArrayField") and BlankDesc and Multiple="Y"]' 2> /dev/null | grep '^<' || true) | while read LINE; do \ - echo "$${MODEL}: $${LINE} blank description not applicable on multiple field"; \ - done; \ - (xmllint $${MODEL} --xpath '//*[@type and not(@type="ArrayField") and Multiple="N"]' 2> /dev/null | grep '^<' || true) | while read LINE; do \ - echo "$${MODEL}: $${LINE} Multiple=N is the default"; \ - done; \ - (xmllint $${MODEL} --xpath '//*[@type and not(@type="ArrayField") and OptionValues[default[not(@value)] or multiple[not(@value)] or required[not(@value)]]]' 2> /dev/null | grep '^<' || true) | while read LINE; do \ - echo "$${MODEL}: $${LINE} option element default/multiple/required without value attribute"; \ - done; \ - (xmllint $${MODEL} --xpath '//*[@type="CSVListField" and Mask and (not(MaskPerItem) or MaskPerItem=N)]' 2> /dev/null | grep '^<' || true) | while read LINE; do \ - echo "$${MODEL}: $${LINE} uses Mask regex with MaskPerItem=N"; \ - done; \ - for TYPE in .\\AliasesField .\\DomainIPField HostnameField IPPortField NetworkField MacAddressField .\\RangeAddressField; do \ - (xmllint $${MODEL} --xpath '//*[@type="'$${TYPE}'" and FieldSeparator=","]' 2> /dev/null | grep '^<' || true) | while read LINE; do \ - echo "$${MODEL}: $${LINE} FieldSeparator=, is the default"; \ - done; \ - (xmllint $${MODEL} --xpath '//*[@type="'$${TYPE}'" and AsList="N"]' 2> /dev/null | grep '^<' || true) | while read LINE; do \ - echo "$${MODEL}: $${LINE} AsList=N is the default"; \ - done; \ - done; \ - done; fi - -ACLBIN?= ${.CURDIR}/../../../core/Scripts/dashboard-acl.sh - -lint-acl: check -.if exists(${ACLBIN}) - @${ACLBIN} ${.CURDIR}/../../../core -.else - @echo "Did not find ACLBIN, please provide a core repository"; exit 1 -.endif - -lint-exec: check -.for DIR in ${.CURDIR}/src/opnsense/scripts ${.CURDIR}/src/etc/rc.d ${.CURDIR}/src/etc/rc.syshook.d -.if exists(${DIR}) - @find ${DIR} -type f ! -name "*.xml" -print0 | \ - xargs -0 -t -n1 test -x || \ - (echo "Missing executable permission in ${DIR}"; exit 1) -.endif -.endfor - -LINTBIN?= ${.CURDIR}/../../../core/contrib/parallel-lint/parallel-lint - -lint-php: check -.if exists(${LINTBIN}) - @if [ -d ${.CURDIR}/src ]; then ${LINTBIN} src; fi -.else - @echo "Did not find LINTBIN, please provide a core repository"; exit 1 -.endif - -lint: lint-desc lint-shell lint-xml lint-model lint-acl lint-exec lint-php - plist-fix: sweep: check