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

Remove useless Layout/SpaceAfterColon Cop #7157

Closed
AdrienSdy opened this issue Jun 19, 2019 · 2 comments
Closed

Remove useless Layout/SpaceAfterColon Cop #7157

AdrienSdy opened this issue Jun 19, 2019 · 2 comments

Comments

@AdrienSdy
Copy link
Contributor

AdrienSdy commented Jun 19, 2019

Is your feature request related to a problem? Please describe.

The Layout/SpaceAfterColon, checks space needed between colon and value in ruby 1.9 hash syntax. It's already check with Layout/AlignHash.
Each style describe in this latter cop guarantee at least one space between separators and values.

Also since #6649 release in 0.70.0 (2019-05-21), user can choose multiple alignement style, reinforcing the feeling than the Layout/SpaceAfterColon cop is become useless.

Describe the solution you'd like

Remove this cop which has become useless.


What do you think ?

@koic
Copy link
Member

koic commented Jun 20, 2019

I think that roles of Layout/SpaceAfterColon cop and Layout/AlignHash cop are different.

Layout/AlignHash cop is a cop for Hash style. For example, Layout/SpaceAfterColon cop has detected a kwargs. This is not detected by Layout/AlignHash cop.

% cat example.rb
# frozen_string_literal: true

def m(foo:1, bar:2)
end

% rubocop
Inspecting 1 file
C

Offenses:

example.rb:3:1: C: Style/EmptyMethod: Put empty method definitions on a single line.
def m(foo:1, bar:2) ...
^^^^^^^^^^^^^^^^^^^
example.rb:3:10: C: Layout/SpaceAfterColon: Space missing after colon.
def m(foo:1, bar:2)
         ^
example.rb:3:17: C: Layout/SpaceAfterColon: Space missing after colon.
def m(foo:1, bar:2)
                ^

1 file inspected, 3 offenses detected

It can not be detected when Layout/SpaceAfterColon is disabled.

% cat .rubocop.yml
Layout/SpaceAfterColon:
  Enabled: false

% rubocop
Inspecting 1 file
C

Offenses:

example.rb:3:1: C: Style/EmptyMethod: Put empty method definitions on a single line.
def m(foo:1, bar:2) ...
^^^^^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected

So Layout/SpaceAfterColon cop cannot be removed as it works.

@koic koic closed this as completed Jun 20, 2019
@AdrienSdy
Copy link
Contributor Author

@koic

You agree, I forgot to check the inline hash.

@rubocop rubocop deleted a comment from EDISONchen00 Oct 5, 2021
@rubocop rubocop deleted a comment from EDISONchen00 Oct 5, 2021
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

No branches or pull requests

2 participants