Skip to content

Commit

Permalink
Merge pull request #141 from koic/enforce_style_slashes_by_default
Browse files Browse the repository at this point in the history
Change default of `EnforcedStyle` to `slashes` for `Rails/FilePath`
  • Loading branch information
koic committed Nov 21, 2019
2 parents 72c0fdd + dd92d31 commit 46d2c47
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
### Changes

* [#156](https://github.com/rubocop-hq/rubocop-rails/pull/156): Make `Rails/UnknownEnv` cop aware of `Rails.env == 'unknown_env'`. ([@pocke][])
* [#141](https://github.com/rubocop-hq/rubocop-rails/pull/141): Change default of `EnforcedStyle` from `arguments` to `slashes` for `Rails/FilePath`. ([@koic][])

## 2.3.2 (2019-09-01)

Expand Down
4 changes: 2 additions & 2 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ Rails/FilePath:
Description: 'Use `Rails.root.join` for file path joining.'
Enabled: true
VersionAdded: '0.47'
VersionChanged: '0.57'
EnforcedStyle: arguments
VersionChanged: '2.4'
EnforcedStyle: slashes
SupportedStyles:
- slashes
- arguments
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rails/file_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Rails
# to use `Rails.root.join` clause. It is used to add uniformity when
# joining paths.
#
# @example EnforcedStyle: arguments (default)
# @example EnforcedStyle: arguments
# # bad
# Rails.root.join('app/models/goober')
# File.join(Rails.root, 'app/models/goober')
Expand All @@ -16,7 +16,7 @@ module Rails
# # good
# Rails.root.join('app', 'models', 'goober')
#
# @example EnforcedStyle: slashes
# @example EnforcedStyle: slashes (default)
# # bad
# Rails.root.join('app', 'models', 'goober')
# File.join(Rails.root, 'app/models/goober')
Expand Down
8 changes: 4 additions & 4 deletions manual/cops_rails.md
Original file line number Diff line number Diff line change
Expand Up @@ -812,15 +812,15 @@ Exclude | `lib/**/*.rake` | Array

Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
--- | --- | --- | --- | ---
Enabled | Yes | No | 0.47 | 0.57
Enabled | Yes | No | 0.47 | 2.4

This cop is used to identify usages of file path joining process
to use `Rails.root.join` clause. It is used to add uniformity when
joining paths.

### Examples

#### EnforcedStyle: arguments (default)
#### EnforcedStyle: arguments

```ruby
# bad
Expand All @@ -831,7 +831,7 @@ File.join(Rails.root, 'app/models/goober')
# good
Rails.root.join('app', 'models', 'goober')
```
#### EnforcedStyle: slashes
#### EnforcedStyle: slashes (default)

```ruby
# bad
Expand All @@ -847,7 +847,7 @@ Rails.root.join('app/models/goober')

Name | Default value | Configurable values
--- | --- | ---
EnforcedStyle | `arguments` | `slashes`, `arguments`
EnforcedStyle | `slashes` | `slashes`, `arguments`

## Rails/FindBy

Expand Down

0 comments on commit 46d2c47

Please sign in to comment.