mirror of
https://github.com/opnsense/plugins.git
synced 2026-05-28 04:34:15 -04:00
make: add lint-model for sanity checking
This commit is contained in:
parent
2caee070f9
commit
7f99c4095d
1 changed files with 23 additions and 2 deletions
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2015-2022 Franco Fichtner <franco@opnsense.org>
|
||||
# Copyright (c) 2015-2023 Franco Fichtner <franco@opnsense.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
|
|
@ -313,6 +313,27 @@ lint-xml:
|
|||
@find ${.CURDIR}/src \
|
||||
-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 \
|
||||
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; \
|
||||
done; fi
|
||||
|
||||
lint-exec: check
|
||||
.for DIR in ${.CURDIR}/src/opnsense/scripts ${.CURDIR}/src/etc/rc.d ${.CURDIR}/src/etc/rc.syshook.d
|
||||
.if exists(${DIR})
|
||||
|
|
@ -337,7 +358,7 @@ lint-php: check
|
|||
-type f -print0 | xargs -0 -n1 php -l
|
||||
.endif
|
||||
|
||||
lint: lint-desc lint-shell lint-xml lint-exec lint-php
|
||||
lint: lint-desc lint-shell lint-xml lint-model lint-exec lint-php
|
||||
|
||||
sweep: check
|
||||
find ${.CURDIR}/src -type f -name "*.map" -print0 | \
|
||||
|
|
|
|||
Loading…
Reference in a new issue