Skip to content

Commit 2e619f3

Browse files
committed
[Docs] Add TargetRailsVersion to config documentation
1 parent 083e24c commit 2e619f3

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,26 @@ RuboCop::RakeTask.new do |task|
6363
end
6464
```
6565

66+
## RuboCop Rails configuration
67+
68+
The following settings specific to RuboCop Rails can be configured in `.rubocop.yml`.
69+
70+
### `AllCops: TargetRailsVersion`
71+
72+
What version of Rails is the inspected code using? If a value is specified
73+
for `TargetRailsVersion` then it is used. Acceptable values are specified
74+
as a float (e.g., 7.2); the patch version of Rails should not be included.
75+
76+
```yaml
77+
AllCops:
78+
TargetRailsVersion: 7.2
79+
```
80+
81+
If `TargetRailsVersion` is not set, RuboCop will parse the Gemfile.lock or
82+
gems.locked file to find the version of Rails that has been bound to the
83+
application. If neither of those files exist, RuboCop will use Rails 5.0
84+
as the default.
85+
6686
## Rails configuration tip
6787

6888
In Rails 6.1+, add the following `config.generators.after_generate` setting to

config/default.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ AllCops:
1717
# Enable checking Active Support extensions.
1818
# See: https://docs.rubocop.org/rubocop/configuration.html#enable-checking-active-support-extensions
1919
ActiveSupportExtensionsEnabled: true
20-
# What version of Rails is the inspected code using? If a value is specified
21-
# for TargetRailsVersion then it is used. Acceptable values are specified
22-
# as a float (i.e. 5.1); the patch version of Rails should not be included.
23-
# If TargetRailsVersion is not set, RuboCop will parse the Gemfile.lock or
20+
# What version of Rails is the inspected code using? If a value is specified
21+
# for `TargetRailsVersion` then it is used. Acceptable values are specified
22+
# as a float (e.g., 7.2); the patch version of Rails should not be included.
23+
# If `TargetRailsVersion` is not set, RuboCop will parse the Gemfile.lock or
2424
# gems.locked file to find the version of Rails that has been bound to the
25-
# application. If neither of those files exist, RuboCop will use Rails 5.0
25+
# application. If neither of those files exist, RuboCop will use Rails 5.0
2626
# as the default.
2727
TargetRailsVersion: ~
2828

docs/modules/ROOT/pages/usage.adoc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,27 @@ RuboCop::RakeTask.new do |task|
3131
end
3232
----
3333

34+
== RuboCop Rails configuration
35+
36+
The following settings specific to RuboCop Rails can be configured in `.rubocop.yml`.
37+
38+
=== `AllCops: TargetRailsVersion`
39+
40+
What version of Rails is the inspected code using? If a value is specified
41+
for `TargetRailsVersion` then it is used. Acceptable values are specified
42+
as a float (e.g., 7.2); the patch version of Rails should not be included.
43+
44+
[source,yaml]
45+
----
46+
AllCops:
47+
TargetRailsVersion: 7.2
48+
----
49+
50+
If `TargetRailsVersion` is not set, RuboCop will parse the Gemfile.lock or
51+
gems.locked file to find the version of Rails that has been bound to the
52+
application. If neither of those files exist, RuboCop will use Rails 5.0
53+
as the default.
54+
3455
== Rails configuration tip
3556

3657
In Rails 6.1+, add the following `config.generators.after_generate` setting to

0 commit comments

Comments
 (0)