Skip to content

Commit 630c0ea

Browse files
authored
Note about risky rules and how to fix rule violations with PHP-CS-Fixer (#4249)
* a note about risky rules and how to fix rule violations with PHP-CS-Fixer * [MegaLinter] Apply linters fixes --------- Co-authored-by: llaville <[email protected]>
1 parent a01f80f commit 630c0ea

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

megalinter/descriptors/php.megalinter-descriptor.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ linters:
178178
# PHP-CS-Fixer
179179
- linter_name: php-cs-fixer
180180
name: PHP_PHPCSFIXER
181+
linter_text: |
182+
PHP-CS-Fixer is able to fix rule violations detected, and even those marked as (risky)
183+
184+
- Enable **autofixes** by adding `PHP_PHPCSFIXER` in [APPLY_FIXES variable](https://megalinter.io/beta/configuration/#apply-fixes)
185+
- Add "--allow-risky=yes" option in PHP_PHPCSFIXER_ARGUMENTS variable
181186
linter_url: https://cs.symfony.com/
182187
linter_repo: https://github.com/PHP-CS-Fixer/PHP-CS-Fixer
183188
linter_image_url: https://cs.symfony.com/_static/images/logo.png

megalinter/reporters/UpdatedSourcesReporter.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import logging
77
import os
88
import shutil
9+
910
import chalk as c
1011
import git
11-
1212
from megalinter import Reporter, config, utils
1313

1414

@@ -87,16 +87,23 @@ def produce_report(self):
8787
)
8888
else:
8989
try:
90-
repo = git.Repo(os.path.realpath(self.master.github_workspace))
91-
repo.config_writer().set_value("user", "name", "MegaLinter").release()
92-
repo.config_writer().set_value("user", "email", "[email protected]").release()
90+
repo = git.Repo(
91+
os.path.realpath(self.master.github_workspace)
92+
)
93+
repo.config_writer().set_value(
94+
"user", "name", "MegaLinter"
95+
).release()
96+
repo.config_writer().set_value(
97+
"user", "email", "[email protected]"
98+
).release()
9399
repo.git.add(update=True)
94-
repo.git.commit('-m', '[MegaLinter] Apply linters fixes')
95-
repo.git.push('origin', f'HEAD:{remote_branch}')
100+
repo.git.commit("-m", "[MegaLinter] Apply linters fixes")
101+
repo.git.push("origin", f"HEAD:{remote_branch}")
96102
except git.GitCommandError as git_err:
97103
logging.error(
98104
c.red(
99-
"❌ [Updated Sources Reporter] Failed to git push auto fixes: " + str(git_err.stderr)
105+
"❌ [Updated Sources Reporter] Failed to git push auto fixes: "
106+
+ str(git_err.stderr)
100107
)
101108
)
102109
logging.warning(
@@ -107,7 +114,7 @@ def produce_report(self):
107114
)
108115
else:
109116
logging.info(
110-
"[Updated Sources Reporter] Fixed source files have automatically "
117+
"[Updated Sources Reporter] Fixed source files have automatically "
111118
"been pushed to the source branch"
112119
)
113120
else:

0 commit comments

Comments
 (0)