Apipie / apipie-rails

Ruby on Rails API documentation tool
Apache License 2.0
2.47k stars 461 forks source link

Style/RedundantConstantBase-20230403233322 #858

Closed github-actions[bot] closed 1 year ago

github-actions[bot] commented 1 year ago

Rubocop challenge!

Style/RedundantConstantBase

Safe autocorrect: Yes :white_check_mark: 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