mirror of
https://github.com/opnsense/plugins.git
synced 2026-02-03 20:40:37 -05:00
make: style and sweep to from core
This commit is contained in:
parent
9686f6ca16
commit
2b645c896a
5 changed files with 86 additions and 57 deletions
2
Makefile
2
Makefile
|
|
@ -44,7 +44,7 @@ list:
|
|||
.endfor
|
||||
|
||||
# shared targets that are sane to run from the root directory
|
||||
TARGETS= clean glint lint plist-fix revision style sweep test
|
||||
TARGETS= clean glint lint revision style sweep test
|
||||
|
||||
.for TARGET in ${TARGETS}
|
||||
${TARGET}:
|
||||
|
|
|
|||
26
Mk/common.mk
Normal file
26
Mk/common.mk
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# Copyright (c) 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
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
|
||||
.-include "${PLUGINSDIR}/../core/Mk/common.mk"
|
||||
|
|
@ -52,7 +52,10 @@ PLUGIN_REVISION?= 0
|
|||
PLUGIN_REQUIRES= PLUGIN_NAME PLUGIN_VERSION PLUGIN_COMMENT \
|
||||
PLUGIN_MAINTAINER
|
||||
|
||||
.include "common.mk"
|
||||
.include "lint.mk"
|
||||
.include "style.mk"
|
||||
.include "sweep.mk"
|
||||
|
||||
check:
|
||||
.for PLUGIN_REQUIRE in ${PLUGIN_REQUIRES}
|
||||
|
|
@ -353,65 +356,11 @@ clean: check
|
|||
fi
|
||||
@rm -rf ${.CURDIR}/work
|
||||
|
||||
plist-fix:
|
||||
|
||||
sweep: check
|
||||
find ${.CURDIR}/src -type f -name "*.map" -print0 | \
|
||||
xargs -0 -n1 rm
|
||||
find ${.CURDIR}/src ! -name "*.min.*" ! -name "*.svg" \
|
||||
! -name "*.ser" -type f -print0 | \
|
||||
xargs -0 -n1 ${SCRIPTSDIR}/cleanfile
|
||||
find ${.CURDIR} -type f -depth 1 -print0 | \
|
||||
xargs -0 -n1 ${SCRIPTSDIR}/cleanfile
|
||||
|
||||
glint: sweep style-fix plist-fix lint
|
||||
glint: sweep lint
|
||||
|
||||
revision:
|
||||
@MAKE=${MAKE} ${SCRIPTSDIR}/revbump.sh ${.CURDIR}
|
||||
|
||||
STYLEDIRS?= src/etc/inc src/opnsense
|
||||
|
||||
style: check
|
||||
@: > ${.CURDIR}/.style.out
|
||||
.for STYLEDIR in ${STYLEDIRS}
|
||||
@if [ -d ${.CURDIR}/${STYLEDIR} ]; then \
|
||||
(phpcs --standard=${PLUGINSDIR}/ruleset.xml \
|
||||
${.CURDIR}/${STYLEDIR} || true) > \
|
||||
${.CURDIR}/.style.out; \
|
||||
fi
|
||||
.endfor
|
||||
@echo -n "Total number of style warnings: "
|
||||
@grep '| WARNING' ${.CURDIR}/.style.out | wc -l
|
||||
@echo -n "Total number of style errors: "
|
||||
@grep '| ERROR' ${.CURDIR}/.style.out | wc -l
|
||||
@cat ${.CURDIR}/.style.out
|
||||
@rm ${.CURDIR}/.style.out
|
||||
|
||||
style-fix: check
|
||||
.for STYLEDIR in ${STYLEDIRS}
|
||||
@if [ -d ${.CURDIR}/${STYLEDIR} ]; then \
|
||||
phpcbf --standard=${PLUGINSDIR}/ruleset.xml \
|
||||
${.CURDIR}/${STYLEDIR} || true; \
|
||||
fi
|
||||
.endfor
|
||||
|
||||
style-python: check
|
||||
@if [ -d ${.CURDIR}/src ]; then \
|
||||
pycodestyle --ignore=E501 ${.CURDIR}/src || true; \
|
||||
fi
|
||||
|
||||
style-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 \
|
||||
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}; \
|
||||
perl -i -pe 's/<mask>(.*?)<\/mask>/<Mask>$$1<\/Mask>/g' $${MODEL}; \
|
||||
perl -i -pe 's/<asList>(.*?)<\/asList>/<AsList>$$1<\/AsList>/g' $${MODEL}; \
|
||||
done; \
|
||||
fi
|
||||
|
||||
test: check
|
||||
@if [ -d ${.CURDIR}/src/opnsense/mvc/tests ]; then \
|
||||
cd ${LOCALBASE}/opnsense/mvc/tests && \
|
||||
|
|
@ -423,4 +372,4 @@ commit: ensure-workdirs
|
|||
@/bin/echo -n "${.CURDIR:C/\// /g:[-2]}/${.CURDIR:C/\// /g:[-1]}: " > \
|
||||
${WRKDIR}/.commitmsg && git commit -eF ${WRKDIR}/.commitmsg .
|
||||
|
||||
.PHONY: check plist-fix
|
||||
.PHONY: check
|
||||
|
|
|
|||
28
Mk/style.mk
Normal file
28
Mk/style.mk
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# Copyright (c) 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
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
|
||||
CORE_PYTHON_DOT= ${PLUGIN_PYTHON:C/./&./1}
|
||||
|
||||
.-include "${PLUGINSDIR}/../core/Mk/style.mk"
|
||||
26
Mk/sweep.mk
Normal file
26
Mk/sweep.mk
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# Copyright (c) 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
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
|
||||
.-include "${PLUGINSDIR}/../core/Mk/sweep.mk"
|
||||
Loading…
Reference in a new issue