From 585ad210f9561fd135643e9f2d7f98c5b4bb8d72 Mon Sep 17 00:00:00 2001 From: Panayotis Matsinopoulos Date: Thu, 29 Sep 2016 08:23:35 +0300 Subject: [PATCH] Fixes rubocop violation Performance/StringReplacement --- .rubocop_todo.yml | 11 +++++------ features/lib/support/feature_factory.rb | 2 +- lib/cucumber/configuration.rb | 4 ++-- lib/cucumber/formatter/json.rb | 4 ++-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index eef90a7ee0..c1217f5869 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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: diff --git a/features/lib/support/feature_factory.rb b/features/lib/support/feature_factory.rb index 5ee31be631..1da703b402 100644 --- a/features/lib/support/feature_factory.rb +++ b/features/lib/support/feature_factory.rb @@ -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 diff --git a/lib/cucumber/configuration.rb b/lib/cucumber/configuration.rb index a1fc0dc06f..3684bec48d 100644 --- a/lib/cucumber/configuration.rb +++ b/lib/cucumber/configuration.rb @@ -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 @@ -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 diff --git a/lib/cucumber/formatter/json.rb b/lib/cucumber/formatter/json.rb index 01859bd64d..0f9f190ad2 100644 --- a/lib/cucumber/formatter/json.rb +++ b/lib/cucumber/formatter/json.rb @@ -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 @@ -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)