Skip to content

Commit

Permalink
Enable NewCops for RuboCop development
Browse files Browse the repository at this point in the history
Pending cops will be enabled by default in RuboCop 1.0.

This PR enables `NewCops` for RuboCop development. It will be
a verification that enables pending cops.

And this PR suppresses the following offense.

```console
% cd path/to/rubocop
% bundle exec rake
(snip)

lib/rubocop/config_loader_resolver.rb:184:7: C:
Style/HashTransformValues: Prefer transform_values over Hash[_.map {...}].
      Hash[config.map { |cop, params| [cop, yield(params)] }]
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1144 files inspected, 1 offense detected
```
  • Loading branch information
koic committed Apr 13, 2020
1 parent 4c4bd1a commit 3aac880
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require:
- rubocop-rspec

AllCops:
NewCops: enable
Exclude:
- 'vendor/**/*'
- 'spec/fixtures/**/*'
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def check
end

def_delegators :@hash, :[], :[]=, :delete, :each, :key?, :keys, :each_key,
:map, :merge, :to_h, :to_hash
:map, :merge, :to_h, :to_hash, :transform_values
def_delegators :@validator, :validate, :target_ruby_version

def to_s
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/config_loader_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def handle_disabled_by_default(config, new_default_configuration)
end

def transform(config)
Hash[config.map { |cop, params| [cop, yield(params)] }]
config.transform_values { |params| yield(params) }
end

def gem_config_path(gem_name, relative_config_path)
Expand Down

0 comments on commit 3aac880

Please sign in to comment.