Skip to content

Commit

Permalink
Allow risky fixers with allow_risky setting
Browse files Browse the repository at this point in the history
By default PHP-CS-Fixer won’t run if you have "risky" rules in your config.

I added a setting named `allow_risky` to opt-in by adding the `--allow-risky=yes` param to the command.
  • Loading branch information
sylbru authored Oct 19, 2022
1 parent 894ec1b commit 4fca259
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions SublimePhpCsFixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ def run(self, tmp_file):
def create_cmd(self, tmp_file):
config = self.config_param()
rules = self.rules_param()
allow_risky = self.allow_risky_param()

if rules and config:
self.logger.console("rules and config are both present, rules prevails")
Expand All @@ -185,6 +186,7 @@ def create_cmd(self, tmp_file):
"fix",
rules,
config,
allow_risky,
"--using-cache=no",
tmp_file,
]))
Expand Down Expand Up @@ -227,6 +229,12 @@ def rules_param(self):

return None

def allow_risky_param(self):
if self.settings.get("allow_risky"):
return "--allow-risky=yes"

return None

def get_configured_php_cs_fixer_path(self):
path = self.settings.get_expanded('path')

Expand Down

0 comments on commit 4fca259

Please sign in to comment.