Skip to content
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

feat: StatementIndentationFixer - introduce stick_comment_to_next_continuous_control_statement config #7624

Merged
merged 9 commits into from Dec 27, 2023

Conversation

keradus
Copy link
Member

@keradus keradus commented Dec 26, 2023

closes #7497

@keradus keradus changed the title feat: StatementIndentationFixer - introduce stick_comment_to_next_con… tinuous_control_statement config feat: StatementIndentationFixer - introduce stick_comment_to_next_continuous_control_statement config Dec 26, 2023
@keradus
Copy link
Member Author

keradus commented Dec 26, 2023

cc @mvorisek @Wirone

@keradus keradus marked this pull request as ready for review December 26, 2023 21:30
@keradus keradus enabled auto-merge (squash) December 26, 2023 21:30
@coveralls
Copy link

coveralls commented Dec 26, 2023

Coverage Status

coverage: 94.799% (+0.004%) from 94.795%
when pulling 77c36a5 on keradus:7497
into 8c784d4 on PHP-CS-Fixer:master.


- `@Symfony <./../../ruleSets/Symfony.rst>`_ with config:

``['stick_comment_to_next_continuous_control_statement' => true]``
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this turned out to be too agressive - #7497 - and should therefore be not by default in any ruleset

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why any ruleset? If Symfony's standard is like this, then it's OK to have it enabled. If you don't like this and you're using Symfony or PhpCsFixer standard as a base for your ruleset, then you need to re-configure this particular rule 🙂.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. The Symfony or PhpCsFixer standards are too aggresive in cases where comments are at the places mentioned in the issue, search https://github.com/roundcube/roundcubemail codebase for "7497", there are dozens places.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So don't use these rulesets 🤷‍♂️? These are opinionated sets, you either accept how they work or prepare your own configuration. And just to remind, I don't like this behaviour at all because I believe it's impossible to determine the intent (where the comment belongs to) and from a logical point of view such comments should be intended just like everything inside the braces. But it was done on purpose to move it one step left, and now it can be configurable - leaving the same behaviour as default. It's the decision of rulesets' owners, not something you can argue with 🙂.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PHP CS Fixer is not reformatter, thus it should reformat to one, current?, indent, but allow the other valid/meaningful one too. I would say that would be better than hard/project wide configuration option.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reformatting is part of Fixer responsibility. Actually, quite a huge part of it - anything related to whitespaces or phpdocs can be understood as reformatting.

With previous complain that the change was too aggressive, we disable it by default for rule itself and allow everyone to opt-in, if they want to use it.

Same time, any community creating their standard has a freedom to decide where the comments should be placed. And it is that implemented rules are following existing standard, not that standard is adjusted to created rules. With that, if someone was already following Sf standards, they shall already have following each rules, even those without existing Fixer rules.

Any standard/rule can be called "too aggressive" by those who do not want to follow given rule. Happily, you can not only disable the rule now, but also configure it to your needs.

@keradus keradus merged commit 25dfd3f into PHP-CS-Fixer:master Dec 27, 2023
26 checks passed
@keradus keradus deleted the 7497 branch December 27, 2023 22:11
danog pushed a commit to zoonru/PHP-CS-Fixer that referenced this pull request Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

statement_indentation is too aggressive since 7384 PR
5 participants