-
Notifications
You must be signed in to change notification settings - Fork 453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
php-cs-fixer allow risky option #1614
Conversation
added option for risky rules
To confirm, this option is only available on PHP-CS-Fixer v2? |
@Glavin001 This is actually something that I cannot confirm 100%. It seems to be an option for version 2 only and I only know about it because cs-fixer will return an error message and apply no beatification if:
|
@@ -5852,6 +5852,24 @@ | |||
"namespace": "php" | |||
} | |||
}, | |||
"allow_risky": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be automatically generated. I do not see a change to the PHP language adding allow_risky
option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Glavin001 I haven't really worked with modules before, this was my first time and I did not know about the autogeneration part, but i got it now, I also committed the change to the language file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem! Getting closer.
@@ -44,6 +44,12 @@ module.exports = { | |||
type: 'string' | |||
default: "" | |||
description: "Add rule(s). i.e. line_ending,-full_opening_tag,@PSR2 (PHP-CS-Fixer 2 only)" | |||
allow_risky: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Don't forget to regenerate the documentation with npm run docs
.
See https://github.com/Glavin001/atom-beautify/blob/master/docs/add-languages-and-beautifiers.md#options-documentation for details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should have probably seen this documentation from start 👍 . Well everything should be ready now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
src/languages/php.coffee
Outdated
type: 'string' | ||
default: "no" | ||
enum: ["no", "yes"] | ||
description: "allow risky rules to be applied!" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add (PHP-CS-Fixer 2 only)
? I should have noticed this sooner, sorry about that.
@@ -24,6 +24,7 @@ module.exports = class PHPCSFixer extends Beautifier | |||
"fix" | |||
"--rules=#{options.rules}" if options.rules | |||
"--config=#{configFile}" if configFile | |||
"--allow-risky=#{options.allow_risky}" if options.allow_risky |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we will always pass in allow_risky
?
php-cs-fixer --allow-risky=yes
php-cs-fixer --allow-risky=no
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Glavin001 I thought the if there is not passing this option as long as the allow_risky is not changed (not in the configuration file), after changed yes.
I know for sure that if not defined its set to no by default. So the general behaviour would be.
- As long as it is not in the config file it will not be included (I am not sure about this)
- If its set to no it will be included but nothing will change from the default behaviour
- If it is set to yes then rules like symfony and so on (that are considered risky) may be applied
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good! I think this is good as is.
As long as it is not in the config file it will not be included (I am not sure about this)
The default value should be present, so no
. So as long as php-cs-fixer --allow-risky=no
is valid, then we are all good.
Looking good! I would just like to add a note about |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting on Travis CI to pass then will merge!
Thank you for contributing! |
Published to v0.29.24 |
What does this implement/fix? Explain your changes.
Adds an option for allow-risky in php-cs-fixer so you can apply risky rules if you want to.
Does this close any currently open issues?
I am not sure.
Any other comments?
none.
Checklist
Check all those that are applicable and complete.
master
branch