diff options
author | Koichi ITO <koic.ito@gmail.com> | 2018-07-03 12:11:28 +0900 |
---|---|---|
committer | Koichi ITO <koic.ito@gmail.com> | 2018-07-26 17:48:07 +0900 |
commit | 211b10aea6313582e2f837edd297af4aeb33c8dc (patch) | |
tree | 9e5b037b2d9ae2b65182d154fd7426bed3b14a20 /ci/custom_cops/test/support | |
parent | 91fd679710118482f718ea710710561f1cfb0b70 (diff) | |
download | rails-211b10aea6313582e2f837edd297af4aeb33c8dc.tar.gz rails-211b10aea6313582e2f837edd297af4aeb33c8dc.tar.bz2 rails-211b10aea6313582e2f837edd297af4aeb33c8dc.zip |
Bump RuboCop to 0.58.2
## Summary
RuboCop 0.58.2 was released.
https://github.com/rubocop-hq/rubocop/releases/tag/v0.58.2
And rubocop-0-58 channel is available in Code Climate.
https://github.com/codeclimate/codeclimate/releases/tag/v0.76.0
https://github.com/codeclimate/codeclimate/commit/38f21f0
In addition, the following changes are made in this PR.
- Replace Custom cops with Rails cops
- Add jaro_winkler gem to Gemfile.lock
### Replace Custom cops with Rails cops
These are compatible replacements.
- Replace `CustomCops/AssertNot` cop with `Rails/AssertNot` cop.
- Replace `CustomCops/RefuteNot` cop with `Rails/RefuteMethods` cop.
With this replacement, it was decided to use cop of RuboCop itself.
It removes the code related to CustomCops accordingly.
### Add jaro_winkler gem to Gemfile.lock
Since RuboCop 0.57.0 depends on jaro_winkler gem,
it has been added to Gemfile.lock.
Diffstat (limited to 'ci/custom_cops/test/support')
-rw-r--r-- | ci/custom_cops/test/support/cop_helper.rb | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/ci/custom_cops/test/support/cop_helper.rb b/ci/custom_cops/test/support/cop_helper.rb deleted file mode 100644 index c2c6b969dd..0000000000 --- a/ci/custom_cops/test/support/cop_helper.rb +++ /dev/null @@ -1,47 +0,0 @@ -# frozen_string_literal: true - -require "rubocop" - -module CopHelper - def inspect_source(cop, source) - processed_source = parse_source(source) - raise "Error parsing example code" unless processed_source.valid_syntax? - investigate(cop, processed_source) - processed_source - end - - def autocorrect_source(cop, source) - cop.instance_variable_get(:@options)[:auto_correct] = true - processed_source = inspect_source(cop, source) - rewrite(cop, processed_source) - end - - def assert_offense(cop, expected_message) - assert_not_empty( - cop.offenses, - "Expected offense with message \"#{expected_message}\", but got no offense" - ) - - offense = cop.offenses.first - carets = "^" * offense.column_length - - assert_equal expected_message, "#{carets} #{offense.message}" - end - - private - TARGET_RUBY_VERSION = 2.4 - - def parse_source(source) - RuboCop::ProcessedSource.new(source, TARGET_RUBY_VERSION) - end - - def rewrite(cop, processed_source) - RuboCop::Cop::Corrector.new(processed_source.buffer, cop.corrections) - .rewrite - end - - def investigate(cop, processed_source) - RuboCop::Cop::Commissioner.new([cop], [], raise_error: true) - .investigate(processed_source) - end -end |