From 7b9825084e883aa139d220f1f482eb84a3c67a3b Mon Sep 17 00:00:00 2001 From: Jayson Smith Date: Wed, 25 Jul 2018 08:20:38 -0700 Subject: [PATCH] Fix Style/CaseEquality --- .rubocop_todo.yml | 9 --------- lib/cucumber/formatter/console.rb | 2 +- lib/cucumber/formatter/io.rb | 4 ++-- lib/cucumber/multiline_argument/data_table.rb | 6 +++--- lib/cucumber/rake/task.rb | 4 ++-- lib/cucumber/step_match.rb | 2 +- 6 files changed, 9 insertions(+), 18 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 60fdd5d258..e1086f2df3 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -45,15 +45,6 @@ Security/Eval: - 'lib/cucumber/formatter/ansicolor.rb' - 'lib/cucumber/term/ansicolor.rb' -# Offense count: 9 -Style/CaseEquality: - Exclude: - - 'lib/cucumber/formatter/console.rb' - - 'lib/cucumber/formatter/io.rb' - - 'lib/cucumber/multiline_argument/data_table.rb' - - 'lib/cucumber/rake/task.rb' - - 'lib/cucumber/step_match.rb' - # Offense count: 2 Style/CommentedKeyword: Exclude: diff --git a/lib/cucumber/formatter/console.rb b/lib/cucumber/formatter/console.rb index e18acffa15..d0cf947320 100644 --- a/lib/cucumber/formatter/console.rb +++ b/lib/cucumber/formatter/console.rb @@ -46,7 +46,7 @@ def format_step(keyword, step_match, status, source_indent) def format_string(o, status) fmt = format_for(status) o.to_s.split("\n").map do |line| - if Proc === fmt + if Proc == fmt.class fmt.call(line) else fmt % line diff --git a/lib/cucumber/formatter/io.rb b/lib/cucumber/formatter/io.rb index cda705c50d..3f9473088d 100644 --- a/lib/cucumber/formatter/io.rb +++ b/lib/cucumber/formatter/io.rb @@ -19,14 +19,14 @@ def ensure_io(path_or_io) end def ensure_file(path, name) - raise "You *must* specify --out FILE for the #{name} formatter" unless String === path + raise "You *must* specify --out FILE for the #{name} formatter" unless String == path.class raise "I can't write #{name} to a directory - it has to be a file" if File.directory?(path) raise "I can't write #{name} to a file in the non-existing directory #{File.dirname(path)}" unless File.directory?(File.dirname(path)) ensure_io(path) end def ensure_dir(path, name) - raise "You *must* specify --out DIR for the #{name} formatter" unless String === path + raise "You *must* specify --out DIR for the #{name} formatter" unless String == path.class raise "I can't write #{name} reports to a file - it has to be a directory" if File.file?(path) FileUtils.mkdir_p(path) unless File.directory?(path) File.absolute_path path diff --git a/lib/cucumber/multiline_argument/data_table.rb b/lib/cucumber/multiline_argument/data_table.rb index 5b2190e0ec..d44c7e90cc 100644 --- a/lib/cucumber/multiline_argument/data_table.rb +++ b/lib/cucumber/multiline_argument/data_table.rb @@ -507,7 +507,7 @@ def convert_headers! #:nodoc: end @header_mappings.each_pair do |pre, post| - mapped_cells = header_cells.select { |cell| pre === cell.value } + mapped_cells = header_cells.select { |cell| cell.value.match? pre } raise "No headers matched #{pre.inspect}" if mapped_cells.empty? raise "#{mapped_cells.length} headers matched #{pre.inspect}: #{mapped_cells.map(&:value).inspect}" if mapped_cells.length > 1 mapped_cells[0].value = post @@ -520,7 +520,7 @@ def clear_cache! #:nodoc: end def ensure_table(table_or_array) #:nodoc: - return table_or_array if DataTable === table_or_array + return table_or_array if DataTable == table_or_array.class DataTable.from(table_or_array) end @@ -603,7 +603,7 @@ def inspect! end def ==(other) - SurplusCell === other || value == other.value + SurplusCell == other.class || value == other.value end def eql?(other) diff --git a/lib/cucumber/rake/task.rb b/lib/cucumber/rake/task.rb index f4ed1ca471..ad6e0d586f 100644 --- a/lib/cucumber/rake/task.rb +++ b/lib/cucumber/rake/task.rb @@ -38,7 +38,7 @@ class InProcessCucumberRunner #:nodoc: attr_reader :args def initialize(libs, cucumber_opts, feature_files) - raise 'libs must be an Array when running in-process' unless Array === libs + raise 'libs must be an Array when running in-process' unless Array == libs.class libs.reverse_each { |lib| $LOAD_PATH.unshift(lib) } @args = ( cucumber_opts + @@ -113,7 +113,7 @@ def run # It's recommended to pass an Array, but if it's a String it will be #split by ' '. attr_reader :cucumber_opts def cucumber_opts=(opts) #:nodoc: - @cucumber_opts = String === opts ? opts.split(' ') : opts + @cucumber_opts = String == opts.class ? opts.split(' ') : opts end # Whether or not to fork a new ruby interpreter. Defaults to true. You may gain diff --git a/lib/cucumber/step_match.rb b/lib/cucumber/step_match.rb index 0124881fbd..81acb02064 100644 --- a/lib/cucumber/step_match.rb +++ b/lib/cucumber/step_match.rb @@ -77,7 +77,7 @@ def replace_arguments(string, step_arguments, format) replacement = if block_given? yield(group.value) - elsif Proc === format + elsif Proc == format.class format.call(group.value) else format % group.value