diff --git a/Mk/plugins.mk b/Mk/plugins.mk index ee97ccbdf..0c617d1aa 100644 --- a/Mk/plugins.mk +++ b/Mk/plugins.mk @@ -314,13 +314,12 @@ lint-xml: -name "*.xml" -type f -print0 | xargs -0 -n1 xmllint --noout lint-model: - # XXX "default" must be changed to upper case "Default" @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 \ + (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 \ + (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 \ @@ -332,6 +331,9 @@ lint-model: (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 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; \ done; fi lint-exec: check @@ -407,6 +409,14 @@ style-python: check pycodestyle --ignore=E501 ${.CURDIR}/src || true; \ fi +style-model: + @for MODEL in $$(find ${.CURDIR}/src/opnsense/mvc/app/models -depth 3 \ + -name "*.xml"); do \ + perl -i -pe 's/(.*?)<\/default>/$$1<\/Default>/g' $${MODEL}; \ + perl -i -pe 's/(.*?)<\/multiple>/$$1<\/Multiple/g' $${MODEL}; \ + perl -i -pe 's/(.*?)<\/required>/$$1<\/Required>/g' $${MODEL}; \ + done + test: check @if [ -d ${.CURDIR}/src/opnsense/mvc/tests ]; then \ cd /usr/local/opnsense/mvc/tests && \