Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "(FACT-3428) Performance/RegexpMatch" #2670

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
Performance/RegexpMatch:
Exclude:
- 'install.rb'

# Offense count: 70
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
# Include: **/*_spec*rb*, **/spec/**/*
Expand Down
10 changes: 5 additions & 5 deletions install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Installer

# Returns true if OS is windows (copied from facter/util/config.rb)
def windows?
(defined?(RbConfig) ? RbConfig : Config)::CONFIG['host_os'].match?(/mswin|win32|dos|mingw|cygwin/i)
(defined?(RbConfig) ? RbConfig : Config)::CONFIG['host_os'] =~ /mswin|win32|dos|mingw|cygwin/i
end

def glob(list)
Expand Down Expand Up @@ -153,7 +153,7 @@ def prepare_installation
# /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin
# which is not generally where people expect executables to be installed
# These settings are appropriate defaults for all OS X versions.
RbConfig::CONFIG['bindir'] = '/usr/bin' if RUBY_PLATFORM.match?(/^universal-darwin[\d.]+$/)
RbConfig::CONFIG['bindir'] = '/usr/bin' if RUBY_PLATFORM =~ /^universal-darwin[\d.]+$/

# if InstallOptions.configdir
# configdir = InstallOptions.configdir
Expand All @@ -173,10 +173,10 @@ def prepare_installation
else
sitelibdir = RbConfig::CONFIG['sitelibdir']
if sitelibdir.nil?
sitelibdir = $LOAD_PATH.find { |x| x.match?(/site_ruby/) }
sitelibdir = $LOAD_PATH.find { |x| x =~ /site_ruby/ }
if sitelibdir.nil?
sitelibdir = File.join(libdir, 'site_ruby')
elsif !sitelibdir.match?(Regexp.quote(version))
elsif sitelibdir !~ Regexp.quote(version)
sitelibdir = File.join(sitelibdir, version)
end
end
Expand Down Expand Up @@ -232,7 +232,7 @@ def install_binfile(from, op_file, target)
File.open(tmp_file.path, 'w') do |op|
op.puts "#!#{ruby}"
contents = ip.readlines
contents.shift if contents[0].match?(/^#!/)
contents.shift if contents[0] =~ /^#!/
op.write contents.join
end
end
Expand Down