Skip to content

Commit

Permalink
Fix Style/CaseEquality
Browse files Browse the repository at this point in the history
  • Loading branch information
mxygem committed Jul 25, 2018
1 parent 7f75e6e commit 7b98250
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 18 deletions.
9 changes: 0 additions & 9 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/formatter/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/cucumber/formatter/io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/cucumber/multiline_argument/data_table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -603,7 +603,7 @@ def inspect!
end

def ==(other)
SurplusCell === other || value == other.value
SurplusCell == other.class || value == other.value
end

def eql?(other)
Expand Down
4 changes: 2 additions & 2 deletions lib/cucumber/rake/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 +
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/step_match.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7b98250

Please sign in to comment.