diff --git a/Helper/inspectproject.sh b/Helper/inspectproject.sh index 516672b..7dfa436 100755 --- a/Helper/inspectproject.sh +++ b/Helper/inspectproject.sh @@ -18,5 +18,8 @@ printf "\nPHPCS checks\n\n" printf "\nPHPStan checks\n\n" ./vendor/bin/phpstan analyse -l 9 -c Build/Config/phpstan.neon ./ +printf "\nRector\n\n" +vendor/bin/rector process --config Build/Config/rector.php ./ + printf "\nESlint checks\n\n" npx eslint jsOMS/ -c Build/Config/.eslintrc.json diff --git a/Hooks/delegator.sh b/Hooks/delegator.sh index 768ee16..f90ea75 100755 --- a/Hooks/delegator.sh +++ b/Hooks/delegator.sh @@ -14,6 +14,8 @@ for FILE in $(git diff --cached --name-only); do # Fixes if [[ "$FILE" =~ ^.+(php)$ ]]; then phpcsfix "$FILE" + phpcbf "$FILE" + phprector "$FILE" fi # Filename diff --git a/Hooks/fixes.sh b/Hooks/fixes.sh index 97a1686..3fec72b 100755 --- a/Hooks/fixes.sh +++ b/Hooks/fixes.sh @@ -1,7 +1,21 @@ #!/bin/bash phpcsfix() { - php ${rootpath}/vendor/bin/php-cs-fixer fix "$1" --rules='{"array_syntax": {"syntax": "short"}, "blank_line_after_namespace": true, "global_namespace_import": {"import_classes": false, "import_constants": false, "import_functions": false}, "binary_operator_spaces": {"operators": {"=": "align", ".=": "align", "+=": "align", "-=": "align", "*=": "align", "/=": "align", "|=": "align", "&=": "align", "=>": "align", "??=": "align"}}, "cast_spaces": {"space": "single"}, "class_attributes_separation": { "elements": {"const": "one", "method": "one", "property": "one"} }, "combine_consecutive_issets": true, "compact_nullable_typehint": true, "declare_strict_types": true, "declare_equal_normalize": {"space": "none"}, "elseif": true, "encoding": true, "explicit_indirect_variable": true, "explicit_string_variable": true, "function_to_constant": true, "implode_call": true, "increment_style": {"style": "pre"}, "is_null": true, "yoda_style": {"equal": false, "identical": false, "less_and_greater": false}, "line_ending": true, "logical_operators": true, "lowercase_cast": true, "constant_case": {"case": "lower"}, "lowercase_keywords": true, "modernize_types_casting": true, "native_constant_invocation": true, "native_function_casing": true, "native_function_invocation": {"include": ["@all"]}, "new_with_braces": true, "no_extra_blank_lines": {"tokens": ["break", "case", "continue", "curly_brace_block", "extra", "return", "switch", "throw", "use"]}, "no_spaces_after_function_name": true, "no_alias_functions": true, "no_closing_tag": true, "no_empty_comment": true, "no_empty_phpdoc": true, "no_empty_statement": true, "no_homoglyph_names": true, "no_mixed_echo_print": {"use": "echo"}, "no_php4_constructor": true, "no_singleline_whitespace_before_semicolons": true, "no_spaces_inside_parenthesis": true, "no_trailing_whitespace": true, "no_unneeded_final_method": true, "no_unused_imports": true, "no_useless_return": true, "no_whitespace_before_comma_in_array": true, "no_whitespace_in_blank_line": true, "non_printable_character": true, "normalize_index_brace": true, "ordered_imports": {"sort_algorithm": "alpha"}, "ordered_interfaces": {"order": "alpha"}, "php_unit_construct": true, "php_unit_internal_class": true, "php_unit_set_up_tear_down_visibility": true, "phpdoc_indent": true, "phpdoc_align": {"align": "vertical"}, "phpdoc_annotation_without_dot": true, "phpdoc_scalar": true, "phpdoc_return_self_reference": {"replacements": {"this": "self"}}, "phpdoc_trim": true, "phpdoc_trim_consecutive_blank_line_separation": true, "random_api_migration": true, "self_accessor": true, "return_type_declaration": {"space_before": "one"}, "semicolon_after_instruction": true, "set_type_to_cast": true, "short_scalar_cast": true, "single_blank_line_at_eof": true, "single_line_after_imports": true, "standardize_increment": true, "trailing_comma_in_multiline": true, "trim_array_spaces": true, "visibility_required": true, "void_return": true}' --allow-risky=yes + php ${rootpath}/vendor/bin/php-cs-fixer fix "$1" --rules='{"array_syntax": {"syntax": "short"}, "blank_line_after_namespace": true, "global_namespace_import": {"import_classes": false, "import_constants": false, "import_functions": false}, "binary_operator_spaces": {"operators": {"=": "align", ".=": "align", "+=": "align", "-=": "align", "*=": "align", "/=": "align", "|=": "align", "&=": "align", "=>": "align", "??=": "align", ">>=": "align", "<<=": "align"}}, "cast_spaces": {"space": "single"}, "class_attributes_separation": { "elements": {"const": "one", "method": "one", "property": "one"} }, "combine_consecutive_issets": true, "compact_nullable_typehint": true, "declare_strict_types": true, "declare_equal_normalize": {"space": "none"}, "elseif": true, "encoding": true, "explicit_indirect_variable": true, "explicit_string_variable": true, "function_to_constant": true, "implode_call": true, "increment_style": {"style": "pre"}, "is_null": true, "yoda_style": {"equal": false, "identical": false, "less_and_greater": false}, "line_ending": true, "logical_operators": true, "lowercase_cast": true, "constant_case": {"case": "lower"}, "lowercase_keywords": true, "modernize_types_casting": true, "native_constant_invocation": true, "native_function_casing": true, "native_function_invocation": {"include": ["@all"]}, "new_with_braces": true, "no_extra_blank_lines": {"tokens": ["break", "case", "continue", "curly_brace_block", "extra", "return", "switch", "throw", "use"]}, "no_spaces_after_function_name": true, "no_alias_functions": true, "no_closing_tag": true, "no_empty_comment": true, "no_empty_phpdoc": true, "no_empty_statement": true, "no_homoglyph_names": true, "no_mixed_echo_print": {"use": "echo"}, "no_php4_constructor": true, "no_singleline_whitespace_before_semicolons": true, "no_spaces_inside_parenthesis": true, "no_trailing_whitespace": true, "no_unneeded_final_method": true, "no_unused_imports": true, "no_useless_return": true, "no_whitespace_before_comma_in_array": true, "no_whitespace_in_blank_line": true, "non_printable_character": true, "normalize_index_brace": true, "ordered_imports": {"sort_algorithm": "alpha"}, "ordered_interfaces": {"order": "alpha"}, "php_unit_construct": true, "php_unit_internal_class": true, "php_unit_set_up_tear_down_visibility": true, "phpdoc_indent": true, "phpdoc_align": {"align": "vertical"}, "phpdoc_annotation_without_dot": true, "phpdoc_scalar": true, "phpdoc_return_self_reference": {"replacements": {"this": "self"}}, "phpdoc_trim": true, "phpdoc_trim_consecutive_blank_line_separation": true, "random_api_migration": true, "self_accessor": true, "return_type_declaration": {"space_before": "one"}, "semicolon_after_instruction": true, "set_type_to_cast": true, "short_scalar_cast": true, "single_blank_line_at_eof": true, "single_line_after_imports": true, "standardize_increment": true, "trailing_comma_in_multiline": true, "trim_array_spaces": true, "visibility_required": true, "void_return": true}' --allow-risky=yes + + echo 1 + return 1 +} + +phpcbf() { + php ${rootpath}/vendor/bin/phpcbf --standard=${rootpath}/Build/Config/phpcs.xml "$1" + + echo 1 + return 1 +} + +phprector() { + php ${rootpath}/vendor/bin/rector process --config ${rootpath}/Build/Config/rector.php "$1" echo 1 return 1 diff --git a/Hooks/syntax.sh b/Hooks/syntax.sh index 4a45a1d..ad1fd67 100755 --- a/Hooks/syntax.sh +++ b/Hooks/syntax.sh @@ -21,7 +21,7 @@ hasInvalidPhpSyntax() { hasInvalidJsSyntax() { # eslint - $(npx eslint "$1" -c Build/Config/.eslintrc.json > /dev/null) + $(npx eslint "$1" -c ${rootpath}/Build/Config/.eslintrc.json > /dev/null) if [[ $? != 0 ]]; then echo 1 return 1 diff --git a/Inspection/Php/style.sh b/Inspection/Php/style.sh index bb7404b..c193999 100755 --- a/Inspection/Php/style.sh +++ b/Inspection/Php/style.sh @@ -7,9 +7,11 @@ echo "Start php style inspection" echo "#################################################" php ${ROOT_PATH}/vendor/bin/phpcs ${ROOT_PATH}/phpOMS --standard="${BUILD_PATH}/Config/phpcs.xml" -s --report-full=${INSPECTION_PATH}/Framework/phpcs.log --report-junit=${INSPECTION_PATH}/Framework/phpcs.xml - php ${ROOT_PATH}/vendor/bin/phpcs ${ROOT_PATH}/Web --standard="${BUILD_PATH}/Config/phpcs.xml" -s --report-full=${INSPECTION_PATH}/Modules/phpcs.log --report-junit=${INSPECTION_PATH}/Modules/phpcs.xml - php ${ROOT_PATH}/vendor/bin/phpcs ${ROOT_PATH}/Modules --standard="${BUILD_PATH}/Config/phpcs.xml" -s --report-full=${INSPECTION_PATH}/Modules/phpcs.log --report-junit=${INSPECTION_PATH}/Modules/phpcs.xml +php ${ROOT_PATH}/vendor/bin/phpcs ${ROOT_PATH} --standard="${BUILD_PATH}/Config/phpcs.xml" -s --report-full=${INSPECTION_PATH}/Test/Php/phpcs.log --report-junit=${INSPECTION_PATH}/Test/Php/junit_phpcs.xml -php ${ROOT_PATH}/vendor/bin/phpcs ${ROOT_PATH} --standard="${BUILD_PATH}/Config/phpcs.xml" -s --report-full=${INSPECTION_PATH}/Test/Php/phpcs.log --report-junit=${INSPECTION_PATH}/Test/Php/junit_phpcs.xml \ No newline at end of file +php ${ROOT_PATH}/vendor/bin/rector --dry-run --config ${BUILD_PATH}/Config/rector.php process ${ROOT_PATH}/phpOMS > ${INSPECTION_PATH}/Framework/rector.log +php ${ROOT_PATH}/vendor/bin/rector --dry-run --config ${BUILD_PATH}/Config/rector.php process ${ROOT_PATH}/Web > ${INSPECTION_PATH}/Modules/rector.log +php ${ROOT_PATH}/vendor/bin/rector --dry-run --config ${BUILD_PATH}/Config/rector.php process ${ROOT_PATH}/Modules > ${INSPECTION_PATH}/Modules/rector.log +php ${ROOT_PATH}/vendor/bin/rector --dry-run --config ${BUILD_PATH}/Config/rector.php process ${ROOT_PATH} > ${INSPECTION_PATH}/Test/Php/rector.log \ No newline at end of file diff --git a/Inspection/inspect.sh b/Inspection/inspect.sh index 098262c..74ef2c5 100755 --- a/Inspection/inspect.sh +++ b/Inspection/inspect.sh @@ -17,7 +17,6 @@ mysql -e 'create database oms;' -u ${DB_USER} --password="${DB_PASSWORD}" echo "#################################################" echo "PHP tests" echo "#################################################" - . ${BUILD_PATH}/Inspection/Php/tests.sh # Executing query inspections AFTER the unit test which also runs queries @@ -25,7 +24,6 @@ echo "#################################################" echo "#################################################" echo "MYSQL queries" echo "#################################################" - . ${BUILD_PATH}/Inspection/Sql/performance.sh # Stats & metrics