mirror of
https://github.com/opnsense/plugins.git
synced 2025-12-10 10:30:21 -06:00
make: kill the plugin lint code
For clarity we split core and plugins from the beginning although plugins only really make sense with a core in mind. To that end, when dealing with plugins a core repository should always be available in order to run the lint passes on the code. This makes maintenance a lot easier in the future.
This commit is contained in:
parent
b2668b72c9
commit
047bab5022
2
Makefile
2
Makefile
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2015-2024 Franco Fichtner <franco@opnsense.org>
|
||||
# Copyright (c) 2015-2025 Franco Fichtner <franco@opnsense.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user