From fb1510a841bc1ac1a65dc9a70b92411e0c307625 Mon Sep 17 00:00:00 2001 From: Laurent Laville Date: Sun, 8 Sep 2024 17:20:06 +0000 Subject: [PATCH] fix for issue #3963 --- .automation/test/php/.mega-linter.yml.sample | 15 +++++++++++++++ .automation/test/php/.php-cs-fixer.risky.php | 13 +++++++++++++ .automation/test/php/php_fix_1.php | 3 +++ megalinter/Linter.py | 6 +++++- 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 .automation/test/php/.mega-linter.yml.sample create mode 100644 .automation/test/php/.php-cs-fixer.risky.php create mode 100644 .automation/test/php/php_fix_1.php diff --git a/.automation/test/php/.mega-linter.yml.sample b/.automation/test/php/.mega-linter.yml.sample new file mode 100644 index 00000000000..800b3984ca6 --- /dev/null +++ b/.automation/test/php/.mega-linter.yml.sample @@ -0,0 +1,15 @@ +ENABLE: + - PHP +DISABLE_LINTERS: + - PHP_PSALM + - PHP_PHPLINT + - PHP_PHPCS + - PHP_PHPSTAN +LOG_LEVEL: debug +PARALLEL: false +UPDATED_SOURCES_REPORTER: true +APPLY_FIXES: PHP_PHPCSFIXER +PHP_PHPCSFIXER_CONFIG_FILE: .php-cs-fixer.risky.php +PHP_PHPCSFIXER_ARGUMENTS: + - "--allow-risky=yes" + - "--diff" diff --git a/.automation/test/php/.php-cs-fixer.risky.php b/.automation/test/php/.php-cs-fixer.risky.php new file mode 100644 index 00000000000..4a70593e1d5 --- /dev/null +++ b/.automation/test/php/.php-cs-fixer.risky.php @@ -0,0 +1,13 @@ +in('.') +; + +return (new PhpCsFixer\Config()) + ->setRules([ + '@PER-CS' => true, + '@PhpCsFixer:risky' => true, + ]) + ->setFinder($finder) +; diff --git a/.automation/test/php/php_fix_1.php b/.automation/test/php/php_fix_1.php new file mode 100644 index 00000000000..88fa9af9ff4 --- /dev/null +++ b/.automation/test/php/php_fix_1.php @@ -0,0 +1,3 @@ + list: # Add fix argument if defined if self.apply_fixes is True and ( self.cli_lint_fix_arg_name is not None + or len(self.cli_lint_fix_remove_args) > 0 or str(self.cli_executable_fix) != str(self.cli_executable) ): args_pos = len(self.cli_executable) cmd = cmd[args_pos:] # Remove executable elements cmd = self.cli_executable_fix + cmd - cmd += [self.cli_lint_fix_arg_name] + if self.cli_lint_fix_arg_name is not None: + cmd += [self.cli_lint_fix_arg_name] self.try_fix = True # Add user-defined extra arguments if defined