make: more model QA glue

This commit is contained in:
Franco Fichtner
2023-08-31 12:59:05 +02:00
parent 7f99c4095d
commit 672bd4c7fa
+13 -3
View File
@@ -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>(.*?)<\/default>/<Default>$$1<\/Default>/g' $${MODEL}; \
perl -i -pe 's/<multiple>(.*?)<\/multiple>/<Multiple>$$1<\/Multiple/g' $${MODEL}; \
perl -i -pe 's/<required>(.*?)<\/required>/<Required>$$1<\/Required>/g' $${MODEL}; \
done
test: check
@if [ -d ${.CURDIR}/src/opnsense/mvc/tests ]; then \
cd /usr/local/opnsense/mvc/tests && \