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

[Fix #841] Fix an error for Rails/ActionOrder #859

Merged
merged 1 commit into from
Nov 11, 2022

Conversation

koic
Copy link
Member

@koic koic commented Nov 8, 2022

Fixes #841.

This PR fixes an error for Rails/ActionOrder when using unconventional order of multiple actions.

With this change, autocorrection blank line positions are not as expected, so they are left to autocorrection of Layout/EmptyLineBetweenDefs and Layout/EmptyLinesAroundClassBody cops.

This PR aims to fix the error, that it may be a better autocorrection later.


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.
  • If this is a new cop, consider making a corresponding update to the Rails Style Guide.

@koic koic force-pushed the fix_an_error_for_rails_action_order branch 2 times, most recently from ab0e985 to 37e9c44 Compare November 8, 2022 16:35
@r7kamura
Copy link
Contributor

r7kamura commented Nov 9, 2022

Just to confirm, you are correct that the rule should be changed to "Actions specified in ExpectedOrder should be defined before actions not specified", right?

I think this is not only a bug fix for the cloberring error, but actually changes the rules for the actions order. I wanted to ask this question because if the ordering rule is changed at the same time as the bug fix, I am not sure what order is ideal for this Cop.
(btw, I personally am in favor of the modified ordering rule)

Fixes rubocop#841.

This PR fixes an error for `Rails/ActionOrder`
when using unconventional order of multiple actions.

With this change, autocorrection blank line positions are not as expected,
so they are left to autocorrection of `Layout/EmptyLineBetweenDefs` and
`Layout/EmptyLinesAroundClassBody` cops.

This PR aims to fix the error, that it may be a better autocorrection later.
@koic koic force-pushed the fix_an_error_for_rails_action_order branch from 37e9c44 to 3ad87ce Compare November 10, 2022 03:26
@koic
Copy link
Member Author

koic commented Nov 10, 2022

Good point. This is a fix to work the fully autocorrection that crashed on Parser::Source::TreeRewriter detected clobbering and didn't work. But it may seem like an unclear rule change to some users.
The doc says All other methods are ignored., anyway I added your suggested note to the doc to make the rule clearer.

@koic koic merged commit 2cf5aea into rubocop:master Nov 11, 2022
@koic koic deleted the fix_an_error_for_rails_action_order branch November 11, 2022 02:12
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.

An error occurred while Rails/ActionOrder cop was inspecting files
2 participants