forked from opnsense/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make: add lint-model for sanity checking
- Loading branch information
Showing
1 changed file
with
23 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright (c) 2015-2022 Franco Fichtner <[email protected]> | ||
# Copyright (c) 2015-2023 Franco Fichtner <[email protected]> | ||
# | ||
# 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 | \ | ||
|