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

Style/RedundantConstantBase-20230403233322 #858

Merged
merged 3 commits into from Apr 6, 2023

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Apr 3, 2023

Rubocop challenge!

Style/RedundantConstantBase

Safe autocorrect: Yes
✅ The autocorrect a cop does is safe (equivalent) by design.

Description

Overview

Avoid redundant :: prefix on constant.

How Ruby searches constant is a bit complicated, and it can often be difficult to
understand from the code whether the :: is intended or not. Where Module.nesting
is empty, there is no need to prepend ::, so it would be nice to consistently
avoid such meaningless :: prefix to avoid confusion.

NOTE: This cop is disabled if Lint/ConstantResolution cop is enabled to prevent
conflicting rules. Because it respects user configurations that want to enable
Lint/ConstantResolution cop which is disabled by default.

Examples

# bad
::Const

# good
Const

# bad
class << self
  ::Const
end

# good
class << self
  Const
end

# good
class A
  ::Const
end

# good
module A
  ::Const
end

Auto generated by rubocop_challenger

@mathieujobin mathieujobin reopened this Apr 6, 2023
@mathieujobin mathieujobin merged commit 5fc1bf5 into master Apr 6, 2023
18 checks passed
@mathieujobin mathieujobin deleted the rubocop-challenge/20230403233322 branch April 6, 2023 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant