Skip to content

Commit

Permalink
Move Style/ConstantResolution to Lint/
Browse files Browse the repository at this point in the history
This is a separate commit so we can easily not do it if you'd rather not
  • Loading branch information
robotdana committed Jun 20, 2020
1 parent 79d6a8e commit 96da2c4
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 93 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -8,7 +8,7 @@
* [#8113](https://github.com/rubocop-hq/rubocop/pull/8113): Let `expect_offense` templates add variable-length whitespace with `_{foo}`. ([@eugeneius][])
* [#8148](https://github.com/rubocop-hq/rubocop/pull/8148): Support autocorrection for `Style/MultilineTernaryOperator`. ([@koic][])
* [#8151](https://github.com/rubocop-hq/rubocop/pull/8151): Support autocorrection for `Style/NestedTernaryOperator`. ([@koic][])
* [#8142](https://github.com/rubocop-hq/rubocop/pull/8142): Add `Style/ConstantResolution` cop. ([@robotdana][])
* [#8142](https://github.com/rubocop-hq/rubocop/pull/8142): Add `Lint/ConstantResolution` cop. ([@robotdana][])

### Bug fixes

Expand Down
18 changes: 9 additions & 9 deletions config/default.yml
Expand Up @@ -1361,6 +1361,15 @@ Lint/CircularArgumentReference:
Enabled: true
VersionAdded: '0.33'

Lint/ConstantResolution:
Description: 'Check that constants are fully qualified with `::`.'
Enabled: false
VersionAdded: '0.86'
# Restrict this cop to only looking at certain names
Only: []
# Restrict this cop from only looking at certain names
Ignore: []

Lint/Debugger:
Description: 'Check for debugger calls.'
Enabled: true
Expand Down Expand Up @@ -2628,15 +2637,6 @@ Style/ConditionalAssignment:
SingleLineConditionsOnly: true
IncludeTernaryExpressions: true

Style/ConstantResolution:
Description: 'Check that constants are fully qualified with `::`.'
Enabled: false
VersionAdded: '0.86'
# Restrict this cop to only looking at certain names
Only: []
# Restrict this cop to from looking at certain names
Ignore: []

Style/ConstantVisibility:
Description: >-
Check that class- and module constants have
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/cops.adoc
Expand Up @@ -187,6 +187,7 @@ In the following section you find all available cops:
* xref:cops_lint.adoc#lintbigdecimalnew[Lint/BigDecimalNew]
* xref:cops_lint.adoc#lintbooleansymbol[Lint/BooleanSymbol]
* xref:cops_lint.adoc#lintcircularargumentreference[Lint/CircularArgumentReference]
* xref:cops_lint.adoc#lintconstantresolution[Lint/ConstantResolution]
* xref:cops_lint.adoc#lintdebugger[Lint/Debugger]
* xref:cops_lint.adoc#lintdeprecatedclassmethods[Lint/DeprecatedClassMethods]
* xref:cops_lint.adoc#lintdeprecatedopensslconstant[Lint/DeprecatedOpenSSLConstant]
Expand Down Expand Up @@ -335,7 +336,6 @@ In the following section you find all available cops:
* xref:cops_style.adoc#stylecommentannotation[Style/CommentAnnotation]
* xref:cops_style.adoc#stylecommentedkeyword[Style/CommentedKeyword]
* xref:cops_style.adoc#styleconditionalassignment[Style/ConditionalAssignment]
* xref:cops_style.adoc#styleconstantresolution[Style/ConstantResolution]
* xref:cops_style.adoc#styleconstantvisibility[Style/ConstantVisibility]
* xref:cops_style.adoc#stylecopyright[Style/Copyright]
* xref:cops_style.adoc#styledatetime[Style/DateTime]
Expand Down
79 changes: 79 additions & 0 deletions docs/modules/ROOT/pages/cops_lint.adoc
Expand Up @@ -310,6 +310,85 @@ def cook(dry_ingredients = self.dry_ingredients)
end
----

== Lint/ConstantResolution

|===
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged

| Disabled
| Yes
| No
| 0.86
| -
|===

Check that constants are fully qualified.

=== Examples

[source,ruby]
----
# By default checks every constant
# bad
User
# bad
User::Login
# good
::User
# good
::User::Login
----

==== Only: ['Login']

[source,ruby]
----
# Restrict this cop to only being concerned about certain constants
# bad
Login
# good
::Login
# good
User::Login
----

==== Ignore: ['Login']

[source,ruby]
----
# Restrict this cop not being concerned about certain constants
# bad
User
# good
::User::Login
# good
Login
----

=== Configurable attributes

|===
| Name | Default value | Configurable values

| Only
| `[]`
| Array

| Ignore
| `[]`
| Array
|===

== Lint/Debugger

|===
Expand Down
79 changes: 0 additions & 79 deletions docs/modules/ROOT/pages/cops_style.adoc
Expand Up @@ -1465,85 +1465,6 @@ end
| Boolean
|===

== Style/ConstantResolution

|===
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged

| Disabled
| Yes
| No
| 0.86
| -
|===

Check that constants are fully qualified.

=== Examples

[source,ruby]
----
# By default checks every constant
# bad
User
# bad
User::Login
# good
::User
# good
::User::Login
----

==== Only: ['Login']

[source,ruby]
----
# Restrict this cop to only being concerned about certain constants
# bad
Login
# good
::Login
# good
User::Login
----

==== Ignore: ['Login']

[source,ruby]
----
# Restrict this cop not being concerned about certain constants
# bad
User
# good
::User::Login
# good
Login
----

=== Configurable attributes

|===
| Name | Default value | Configurable values

| Only
| `[]`
| Array

| Ignore
| `[]`
| Array
|===

== Style/ConstantVisibility

|===
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop.rb
Expand Up @@ -242,6 +242,7 @@
require_relative 'rubocop/cop/lint/big_decimal_new'
require_relative 'rubocop/cop/lint/boolean_symbol'
require_relative 'rubocop/cop/lint/circular_argument_reference'
require_relative 'rubocop/cop/lint/constant_resolution'
require_relative 'rubocop/cop/lint/debugger'
require_relative 'rubocop/cop/lint/deprecated_class_methods'
require_relative 'rubocop/cop/lint/deprecated_open_ssl_constant'
Expand Down Expand Up @@ -375,7 +376,6 @@
require_relative 'rubocop/cop/style/comment_annotation'
require_relative 'rubocop/cop/style/commented_keyword'
require_relative 'rubocop/cop/style/conditional_assignment'
require_relative 'rubocop/cop/style/constant_resolution'
require_relative 'rubocop/cop/style/constant_visibility'
require_relative 'rubocop/cop/style/copyright'
require_relative 'rubocop/cop/style/date_time'
Expand Down
Expand Up @@ -2,7 +2,7 @@

module RuboCop
module Cop
module Style
module Lint
# Check that constants are fully qualified.
#
# @example
Expand Down
@@ -1,6 +1,6 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::Style::ConstantResolution, :config do
RSpec.describe RuboCop::Cop::Lint::ConstantResolution, :config do
it 'registers no offense when qualifying a const' do
expect_no_offenses(<<~RUBY)
::MyConst
Expand Down

0 comments on commit 96da2c4

Please sign in to comment.