Skip to content

Commit

Permalink
Merge pull request #1039 from pmatsinopoulos/fix-style-violation-1021…
Browse files Browse the repository at this point in the history
…-performance-string-replacement

Fixes rubocop violation Performance/StringReplacement
  • Loading branch information
Andrea Nodari authored Nov 8, 2016
2 parents b107f4e + 585ad21 commit 15d698c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
11 changes: 5 additions & 6 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,12 @@ Performance/RedundantMatch:
- 'lib/cucumber/deprecate.rb'
- 'spec/cucumber/formatter/junit_spec.rb'

# Offense count: 5
# Offense count: 8
# Cop supports --auto-correct.
Performance/StringReplacement:
Exclude:
- 'features/lib/support/feature_factory.rb'
- 'lib/cucumber/configuration.rb'
- 'lib/cucumber/formatter/json.rb'
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: outdent, indent
Style/AccessModifierIndentation:
Enabled: false

# Offense count: 6
Style/AccessorMethodName:
Expand Down
2 changes: 1 addition & 1 deletion features/lib/support/feature_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def generate_step_definition_filename
end

def filename(name)
"features/#{name.downcase.gsub(' ', '_')}.feature"
"features/#{name.downcase.tr(' ', '_')}.feature"
end

def features
Expand Down
4 changes: 2 additions & 2 deletions lib/cucumber/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def filters

def feature_files
potential_feature_files = with_default_features_path(paths).map do |path|
path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
path = path.tr('\\', '/') # In case we're on windows. Globs don't work with backslashes.
path = path.chomp('/')

# TODO: Move to using feature loading strategies stored in
Expand All @@ -179,7 +179,7 @@ def support_to_load

def all_files_to_load
files = require_dirs.map do |path|
path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
path = path.tr('\\', '/') # In case we're on windows. Globs don't work with backslashes.
path = path.gsub(/\/$/, '') # Strip trailing slash.
File.directory?(path) ? Dir["#{path}/**/*"] : path
end.flatten.uniq
Expand Down
4 changes: 2 additions & 2 deletions lib/cucumber/formatter/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def create_error_message(result)

def encode64(data)
# strip newlines from the encoded data
Base64.encode64(data).gsub(/\n/, '')
Base64.encode64(data).delete("\n")
end

class Builder
Expand Down Expand Up @@ -316,7 +316,7 @@ def examples_table_row(row)
private

def create_id(element)
element.name.downcase.gsub(/ /, '-')
element.name.downcase.tr(' ', '-')
end

def create_tags_array(tags)
Expand Down

0 comments on commit 15d698c

Please sign in to comment.