-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Rename enforced style rails for indentation consistency #7113
Rename enforced style rails for indentation consistency #7113
Conversation
I wonder if |
Thanks for proposing a better option name. I'd like to update it to |
@koic That's fine by me. |
Follow up rubocop#7059 (comment). This PR renames `EnforcedStyle: rails` to `EnabledStyle: outdented_access_modifiers` for `Layout/IndentationConsistency`. This makes it a generic name that doesn't depend on Rails.
This PR shows alternative for obsolete EnforcesStyle parameter name. For example, `EnforcedStyle: rails` in config/default.yml will be replaced by `EnforcedStyle: outdented_access_modifiers`. ```diff # .rubocop.yml Layout/IndentationConsistency: - EnforcedStyle: rails + EnforcedStyle: outdented_access_modifiers ``` ### Before After `EnforcedStyle: rails` has been obsoleted, Users do not know what the parameter name to replace. ```consle % rubocop Error: invalid EnforcedStyle 'rails' for Layout/IndentationConsistency found in .rubocop.yml Valid choices are: normal, outdented_access_modifiers ``` ### After Users will find that they should use `EnforcedStyle: outdented_access_modifiers` instead. ```console % rubocop Error: obsolete `EnforcedStyle: rails` (for Layout/IndentationConsistency) found in .rubocop.yml `EnforcedStyle: rails` has been renamed to `EnforcedStyle: outdented_access_modifiers` ```
4f0480c
to
e37d1e5
Compare
Alternative enforced style name updated from |
Probably # not better
class Foo
def bar
end
private
def baz
end
end
# good
class Foo
def bar
end
private
def baz
end
end The naming |
Yeah, that was the case.
I'm puzzled. Did the style in Rails change at some point? If so I guess the name of the style and its description should be changed. |
That is the DHH flavored style, we have not changed any style. See an example for the style (DHH's PR): rails/rails#35489 |
Hmmm, I wonder why I was under the impression that Rails favours:
That's actually why I suggested the outdented naming to @koic. I'll have to check this more closely. |
My bad then. Well, I'm out of a good idea for the name then. :D How does @dhh refer to that style? |
It seems that my commentary on the PR description was not enough. I named it
https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions This assumes the following code indicated by @kamipo. # good
class Foo
def bar
end
private
def baz
end
end AFAIK, the following code is generated at Rails 4.0 using % bundle exec rails -v
Rails 4.0.0
% bundle exec rails g scaffold article author:string % cat app/controllers/articles_controller.rb
class ArticlesController < ApplicationController
before_action :set_article, only: [:show, :edit, :update, :destroy]
# GET /articles
# GET /articles.json
def index
@articles = Article.all
end
(snip)
# DELETE /articles/1
# DELETE /articles/1.json
def destroy
@article.destroy
respond_to do |format|
format.html { redirect_to articles_url }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_article
@article = Article.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def article_params
params.require(:article).permit(:author)
end
end |
@koic I wonder if we shouldn't revert the PR as frankly I can't come up with a better name than Rails. The problem with We can't cut a new release before fixing this. |
Follow up rubocop#7113 (comment). This PR renames enforced style for `Layout/IndentationConsistency` from `EnabledStyle: outdented_access_modifiers` to `EnabledStyle: indented_internal_methods`. Here is an example style that the name `indented_internal_methods` represents: ```ruby # good class Foo def bar end private def baz end end ```
Yeah, I opened a PR #7163 and we may be good to wait for a while to get a better name feedback. |
👍 Thank you guys for thinking of about the naming! |
Follow up #7113 (comment). This PR renames enforced style for `Layout/IndentationConsistency` from `EnabledStyle: outdented_access_modifiers` to `EnabledStyle: indented_internal_methods`. Here is an example style that the name `indented_internal_methods` represents: ```ruby # good class Foo def bar end private def baz end end ```
Remove wrong #7113 entry from changelog
### Summary RuboCop 0.74.0 has been released. https://github.com/rubocop-hq/rubocop/releases/tag/v0.74.0 And rubocop-0-74 channel is available in Code Climate. https://github.com/codeclimate/codeclimate/releases/tag/v0.85.5 This PR specifies the same RuboCop Performance (1.3.0) and RuboCop Rails (2.0.0) versions as Code Climate's Gemfile.lock. https://github.com/codeclimate/codeclimate-rubocop/blob/channel/rubocop-0-74/Gemfile.lock#L51-L55 Also, the `EnforcedStyle` of `Layout/IndentationConsistency` has been renamed from `EnforcedStyle: rails` to `EnforcedStyle: indented_internal_methods` - rubocop/rubocop#7113 - rubocop/rubocop#7163 And this commit disables `Layout/SpaceAroundOperators` that was changed from RuboCop 0.74 by rubocop/rubocop#7211. cf. rails#36943 (comment)
Rubocop changed the `rails` style for `Layout/IndentationConsistency` to `indented_internal_methods` in version 0.72 rubocop/rubocop#7113 Since rubocop-airbnb requires rubocop 0.76 selecting this style is broken. Using `rails` results in the error message: ``` Error: obsolete `EnforcedStyle: rails` (for Layout/IndentationConsistency) found in .rubocop.yml `EnforcedStyle: rails` has been renamed to `EnforcedStyle: indented_internal_methods` ``` And using `indented_internal_methods` results in: ``` Error: invalid EnforcedStyle 'indented_internal_methods' for Layout/IndentationConsistency found in .rubocop.yml Valid choices are: normal, rails ```
Rename
EnforcedStyle: rails
forLayout/IndentationConsistency
Follow up #7059 (comment).
This PR renames
EnforcedStyle: rails
toEnabledStyle: indented
forLayout/IndentationConsistency
. This makes it a generic name that doesn't depend on Rails.And this PR shows alternative for obsolete EnforcesStyle parameter name.
For example,
EnforcedStyle: rails
in config/default.yml will be replaced byEnforcedStyle: indented
.Before
After
EnforcedStyle: rails
has been obsoleted, Users do not know what the parameter name to replace.After
Users will find that they should use
EnforcedStyle: indented
instead.Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).and description in grammatically correct, complete sentences.
bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.