Skip to content

Commit

Permalink
[Docs] Add TargetRailsVersion to config documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
koic committed Oct 8, 2024
1 parent 083e24c commit 2e619f3
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,26 @@ RuboCop::RakeTask.new do |task|
end
```

## RuboCop Rails configuration

The following settings specific to RuboCop Rails can be configured in `.rubocop.yml`.

### `AllCops: TargetRailsVersion`

What version of Rails is the inspected code using? If a value is specified
for `TargetRailsVersion` then it is used. Acceptable values are specified
as a float (e.g., 7.2); the patch version of Rails should not be included.

```yaml
AllCops:
TargetRailsVersion: 7.2
```

If `TargetRailsVersion` is not set, RuboCop will parse the Gemfile.lock or
gems.locked file to find the version of Rails that has been bound to the
application. If neither of those files exist, RuboCop will use Rails 5.0
as the default.

## Rails configuration tip

In Rails 6.1+, add the following `config.generators.after_generate` setting to
Expand Down
10 changes: 5 additions & 5 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ AllCops:
# Enable checking Active Support extensions.
# See: https://docs.rubocop.org/rubocop/configuration.html#enable-checking-active-support-extensions
ActiveSupportExtensionsEnabled: true
# What version of Rails is the inspected code using? If a value is specified
# for TargetRailsVersion then it is used. Acceptable values are specified
# as a float (i.e. 5.1); the patch version of Rails should not be included.
# If TargetRailsVersion is not set, RuboCop will parse the Gemfile.lock or
# What version of Rails is the inspected code using? If a value is specified
# for `TargetRailsVersion` then it is used. Acceptable values are specified
# as a float (e.g., 7.2); the patch version of Rails should not be included.
# If `TargetRailsVersion` is not set, RuboCop will parse the Gemfile.lock or
# gems.locked file to find the version of Rails that has been bound to the
# application. If neither of those files exist, RuboCop will use Rails 5.0
# application. If neither of those files exist, RuboCop will use Rails 5.0
# as the default.
TargetRailsVersion: ~

Expand Down
21 changes: 21 additions & 0 deletions docs/modules/ROOT/pages/usage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,27 @@ RuboCop::RakeTask.new do |task|
end
----

== RuboCop Rails configuration

The following settings specific to RuboCop Rails can be configured in `.rubocop.yml`.

=== `AllCops: TargetRailsVersion`

What version of Rails is the inspected code using? If a value is specified
for `TargetRailsVersion` then it is used. Acceptable values are specified
as a float (e.g., 7.2); the patch version of Rails should not be included.

[source,yaml]
----
AllCops:
TargetRailsVersion: 7.2
----

If `TargetRailsVersion` is not set, RuboCop will parse the Gemfile.lock or
gems.locked file to find the version of Rails that has been bound to the
application. If neither of those files exist, RuboCop will use Rails 5.0
as the default.

== Rails configuration tip

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

0 comments on commit 2e619f3

Please sign in to comment.