diff --git a/Helper/inspectproject.sh b/Helper/inspectproject.sh
new file mode 100755
index 0000000..74f6d9f
--- /dev/null
+++ b/Helper/inspectproject.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+# html checks
+find ./Web ./Install ./Modules -name "*tpl.php" | xargs grep -E '=\"[\#\$\%\^\&\*\(\)\\/\ ]*\"'
+find ./Web ./Install ./Modules -name "*tpl.php" | xargs grep -P '(\
)'
+find ./Web ./Install ./Modules -name "*tpl.php" | xargs grep -P '()'
+find ./Web ./Install ./Modules -name "*tpl.php" | xargs grep -P '()'
+find ./Web ./Install ./Modules -name "*tpl.php" | xargs grep -P '(style=)'
+find ./Web ./Install ./Modules -name "*tpl.php" | xargs grep -P '(value|title|alt|aria\-label)(=\")((?!\<\?).)*(>)'
+find ./Web ./Install ./Modules -name "*tpl.php" | xargs grep -P '(\
|\ | |\|\)[0-9a-zA-Z\.\?]+)'
+
+# php/js strict checks
+grep -r -L "declare(strict_types=1);" --include=*.php --exclude={*.tpl.php,*Hooks.php,*Routes.php,*SearchCommands.php} ./phpOMS ./Web ./Modules ./Model
+grep -r -L "\"use strict\";" --include=*.js ./jsOMS ./Modules ./Model
+
+# php/js has logs
+find ./Web ./phpOMS ./Model ./Modules -name "*.js" | xargs grep 'console.log('
+find ./Web ./jsOMS ./Model ./Modules -name "*.php" | xargs grep 'var_dump('
+
+# js uses on actions
+grep -rlni "onafterprint=\|onbeforeprint=\|onbeforeunload=\|onerror=\|onhaschange=\|onload=\|onmessage=\|onoffline=\|ononline=\|onpagehide=\|onpageshow=\|onpopstate=\|onredo=\|onresize=\|onstorage=\|onund=o\|onunload=\|onblur=\|onchage=\|oncontextmenu=\|onfocus=\|onformchange=\|onforminput=\|oninput=\|oninvalid=\|onreset=\|onselect=\|onsubmit=\|onkeydown=\|onkeypress=\|onkeyup=\|onclick=\|ondblclic=k\|ondrag=\|ondragend=\|ondragenter=\|ondragleave=\|ondragover=\|ondragstart=\|ondrop=\|onmousedown=\|onmousemove=\|onmouseout=\|onmouseover=\|onmouseup=\|onmousewheel=\|onscroll=\|onabor=t\|oncanplay=\|oncanplaythrough=\|ondurationchange=\|onemptied=\|onended=\|onerror=\|onloadeddata=\|onloadedmetadata=\|onloadstart=\|onpause=\|onplay=\|onplaying=\|onprogress=\|onratechange=\|onreadystatechange=\|onseeked=\|onseeking=\|onstalled=\|onsuspend=\|ontimeupdate=\|onvolumechange=" --include=*.js ./jsOMS ./Model ./Modules ./Web
+
+# white spaces at end of line
+find ./Web ./phpOMS ./jsOMS ./cOMS ./Model ./Build ./Modules \( -name "*.php" -o -name "*.js" -o -name "*.sh" -o -name "*.cpp" -o -name "*.h" -o -name "*.json" \) | xargs grep -P ' $'
+
+# php cs + phpstan + eslint
+./vendor/bin/phpcs ./ --standard="Build/Config/phpcs.xml"
+./vendor/bin/phpstan analyse --autoload-file=phpOMS/Autoloader.php -l 9 -c Build/Config/phpstan.neon ./
+npx eslint jsOMS/ -c Build/Config/.eslintrc.json
\ No newline at end of file
diff --git a/Helper/testreport.sh b/Helper/testreport.sh
index c231a44..69e5109 100755
--- a/Helper/testreport.sh
+++ b/Helper/testreport.sh
@@ -2,10 +2,7 @@
mkdir -p Build/test
-./vendor/bin/phpcs ./ --standard="Build/Config/phpcs.xml"
-./vendor/bin/phpstan analyse --autoload-file=phpOMS/Autoloader.php -l 9 -c Build/Config/phpstan.neon ./
-npx eslint jsOMS/ -c Build/Config/.eslintrc.json
-
+# php cs + phpstan + eslint file generation
./vendor/bin/phpcs ./ --standard="Build/Config/phpcs.xml" -s --report-junit=Build/test/junit_phpcs.xml
./vendor/bin/phpstan analyse --autoload-file=phpOMS/Autoloader.php -l 9 -c Build/Config/phpstan.neon --error-format=prettyJson ./ > Build/test/phpstan.json
npx eslint jsOMS/ -c Build/Config/.eslintrc.json -o Build/test/junit_eslint.xml -f junit
@@ -14,6 +11,7 @@ npx eslint jsOMS/ -c Build/Config/.eslintrc.json -o Build/test/junit_eslint.xml
sed -i '/^$/d' Build/test/phpstan.json
sed -i '/^Warning: /d' Build/test/phpstan.json
+# Create report
php ../TestReportGenerator/src/index.php \
-b /home/spl1nes/Orange-Management \
-l /home/spl1nes/Orange-Management/Build/Config/reportLang.php \
@@ -23,4 +21,4 @@ php ../TestReportGenerator/src/index.php \
-a /home/spl1nes/Orange-Management/Build/test/phpstan.json \
-u /home/spl1nes/Orange-Management/Build/test/junit_php.xml \
-d /home/spl1nes/Orange-Management/Build/test/ReportExternal \
---version 1.0.0
\ No newline at end of file
+--version 1.0.0
diff --git a/Hooks/delegator.sh b/Hooks/delegator.sh
index d5b0444..768ee16 100755
--- a/Hooks/delegator.sh
+++ b/Hooks/delegator.sh
@@ -32,11 +32,6 @@ for FILE in $(git diff --cached --name-only); do
fi
# Tests
- if [[ "$FILE" =~ ^.+(php)$ ]] && [[ $(isPhanTestSuccessful "$FILE") = 0 ]]; then
- echo -e "\e[1;31m\tPhan error in $FILE.\e[0m" >&2
- exit 1
- fi
-
if [[ "$FILE" =~ ^.+(php)$ ]] && [[ $(isPhpStanTestSuccessful "$FILE") = 0 ]]; then
echo -e "\e[1;31m\tPhp stan error in $FILE.\e[0m" >&2
exit 1
@@ -63,6 +58,16 @@ for FILE in $(git diff --cached --name-only); do
fi
fi
+ if [[ "$FILE" =~ ^.+(js)$ ]]; then
+ PHP_SYNTAX=$(hasInvalidJsSyntax "$FILE")
+
+ if [[ $PHP_SYNTAX = 1 ]]; then
+ echo -e "\e[1;31m\tEslint error.\e[0m" >&2
+ npx eslint "$FILE" -c Build/Config/.eslintrc.json
+ exit 1
+ fi
+ fi
+
if [[ "$FILE" =~ ^.+(sh)$ ]] && [[ $(isValidBashScript "$FILE") = 0 ]]; then
echo -e "\e[1;31m\tBash linting error in '$FILE'.\e[0m" >&2
exit 1
diff --git a/Hooks/syntax.sh b/Hooks/syntax.sh
index 62cbdf9..4a45a1d 100755
--- a/Hooks/syntax.sh
+++ b/Hooks/syntax.sh
@@ -15,11 +15,16 @@ hasInvalidPhpSyntax() {
return 2
fi
- # phpmd
- $(php -d memory_limit=4G ${rootpath}/vendor/bin/phpmd "$1" text ${rootpath}/Build/Config/phpmd.xml --exclude *tests* --minimumpriority 1 > /dev/null)
+ echo 0
+ return 0
+}
+
+hasInvalidJsSyntax() {
+ # eslint
+ $(npx eslint "$1" -c Build/Config/.eslintrc.json > /dev/null)
if [[ $? != 0 ]]; then
- echo 3
- return 3
+ echo 1
+ return 1
fi
echo 0
diff --git a/Inspection/Html/attributes.sh b/Inspection/Html/attributes.sh
index 2966498..4bc7711 100755
--- a/Inspection/Html/attributes.sh
+++ b/Inspection/Html/attributes.sh
@@ -3,10 +3,14 @@
. config.sh
echo "#################################################"
-echo "Start html attributes inspection"
+echo "Start html inspection"
echo "#################################################"
-# Find invalid attributes
-find ${ROOT_PATH} -name "*tpl.php" | xargs grep -E '=\"[\#\$\%\^\&\*\(\)\\/\ ]*\"' > ${INSPECTION_PATH}/Modules/html/attributes_invalid.log
-find ${ROOT_PATH} -name "*tpl.php" | xargs grep -E '(id|class)=\"[a-zA-Z]*[\#\$\%\^\&\*\(\)\\/\ ]+[a-zA-Z]*\"' >> ${INSPECTION_PATH}/Modules/html/attributes_invalid.log
-find ${ROOT_PATH} -name "*tpl.php" | xargs grep -P '(\ )' >> ${INSPECTION_PATH}/Modules/html/attributes_invalid.log
+# Find invalid html
+find {ROOT_PATH}/Web {ROOT_PATH}/phpOMS {ROOT_PATH}/Build {ROOT_PATH}/Modules -name "*tpl.php" | xargs grep -E '=\"[\#\$\%\^\&\*\(\)\\/\ ]*\"' > ${INSPECTION_PATH}/Modules/html/invalid_html.log
+find {ROOT_PATH}/Web {ROOT_PATH}/phpOMS {ROOT_PATH}/Build {ROOT_PATH}/Modules -name "*tpl.php" | xargs grep -P '(\ )' >> ${INSPECTION_PATH}/Modules/html/invalid_html.log
+find {ROOT_PATH}/Web {ROOT_PATH}/phpOMS {ROOT_PATH}/Build {ROOT_PATH}/Modules -name "*tpl.php" | xargs grep -P '()' >> ${INSPECTION_PATH}/Modules/html/invalid_html.log
+find {ROOT_PATH}/Web {ROOT_PATH}/phpOMS {ROOT_PATH}/Build {ROOT_PATH}/Modules -name "*tpl.php" | xargs grep -P '()' >> ${INSPECTION_PATH}/Modules/html/invalid_html.log
+find {ROOT_PATH}/Web {ROOT_PATH}/phpOMS {ROOT_PATH}/Build {ROOT_PATH}/Modules -name "*tpl.php" | xargs grep -P '(style=)' >> ${INSPECTION_PATH}/Modules/html/invalid_html.log
+find {ROOT_PATH}/Web {ROOT_PATH}/phpOMS {ROOT_PATH}/Build {ROOT_PATH}/Modules -name "*tpl.php" | xargs grep -P '(value|title|alt|aria\-label)(=\")((?!\<\?).)*(>)' >> ${INSPECTION_PATH}/Modules/html/invalid_html.log
+find {ROOT_PATH}/Web {ROOT_PATH}/phpOMS {ROOT_PATH}/Build {ROOT_PATH}/Modules -name "*tpl.php" | xargs grep -P '(\|\ | |\|\)[0-9a-zA-Z\.\?]+)' >> ${INSPECTION_PATH}/Modules/html/invalid_html.log
\ No newline at end of file
diff --git a/Inspection/Php/security.sh b/Inspection/Php/security.sh
index 1d74ed3..22aa989 100755
--- a/Inspection/Php/security.sh
+++ b/Inspection/Php/security.sh
@@ -55,4 +55,4 @@ done
grep -r -L "declare(strict_types=1);" --include=*.php --exclude={*.tpl.php,*Hooks.php,*Routes.php,*SearchCommands.php} ${ROOT_PATH}/phpOMS > ${INSPECTION_PATH}/Framework/strict_missing_php.log
grep -r -L "declare(strict_types=1);" --include=*.php --exclude={*.tpl.php,*Hooks.php,*Routes.php,*SearchCommands.php} ${ROOT_PATH}/Modules > ${INSPECTION_PATH}/Modules/strict_missing_php.log
grep -r -L "declare(strict_types=1);" --include=*.php --exclude={*.tpl.php,*Hooks.php,*Routes.php,*SearchCommands.php} ${ROOT_PATH}/Model > ${INSPECTION_PATH}/Model/strict_missing_php.log
-grep -r -L "declare(strict_types=1);" --include=*.php --exclude={*.tpl.php,*Hooks.php,*Routes.php,*SearchCommands.php} ${ROOT_PATH}/Web > ${INSPECTION_PATH}/Web/strict_missing_php.log
\ No newline at end of file
+grep -r -L "declare(strict_types=1);" --include=*.php --exclude={*.tpl.php,*Hooks.php,*Routes.php,*SearchCommands.php} ${ROOT_PATH}/Web > ${INSPECTION_PATH}/Web/strict_missing_php.log
diff --git a/Inspection/inspect.sh b/Inspection/inspect.sh
index 5d11f67..2cbd700 100755
--- a/Inspection/inspect.sh
+++ b/Inspection/inspect.sh
@@ -50,6 +50,12 @@ echo "Custom php inspection"
echo "#################################################"
. ${BUILD_PATH}/Inspection/Php/security.sh
+# Custom js inspections
+echo "#################################################"
+echo "Custom js inspection"
+echo "#################################################"
+. ${BUILD_PATH}/Inspection/Js/security.sh
+
# Build external test report
echo "#################################################"
echo "Test report"
| |