Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
[RuboCop] Enable Style/AndOr
Browse files Browse the repository at this point in the history
  • Loading branch information
segiddins committed Nov 26, 2015
1 parent d5f3f86 commit bf5c235
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 32 deletions.
16 changes: 0 additions & 16 deletions .rubocop_todo.yml
Expand Up @@ -66,22 +66,6 @@ Style/AccessorMethodName:
Exclude:
- 'lib/bundler/source/git.rb'

# Offense count: 16
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/AndOr:
Exclude:
- 'lib/bundler/gem_helper.rb'
- 'lib/bundler/graph.rb'
- 'lib/bundler/lazy_specification.rb'
- 'lib/bundler/match_platform.rb'
- 'lib/bundler/remote_specification.rb'
- 'lib/bundler/resolver.rb'
- 'lib/bundler/rubygems_integration.rb'
- 'lib/bundler/runtime.rb'
- 'lib/bundler/settings.rb'
- 'spec/support/builders.rb'

# Offense count: 24
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/gem_helper.rb
Expand Up @@ -129,7 +129,7 @@ def already_tagged?
end

def guard_clean
clean? && committed? or raise("There are files that need to be committed first.")
clean? && committed? || raise("There are files that need to be committed first.")
end

def clean?
Expand Down
4 changes: 2 additions & 2 deletions lib/bundler/graph.rb
Expand Up @@ -97,8 +97,8 @@ def _patching_gem_dependency_class
Gem::Dependency.class_eval do
def matching_specs(platform_only = false)
matches = Bundler.load.specs.select { |spec|
name == spec.name and
requirement.satisfied_by? spec.version
name == spec.name &&
requirement.satisfied_by?(spec.version)
}

if platform_only
Expand Down
4 changes: 2 additions & 2 deletions lib/bundler/lazy_specification.rb
Expand Up @@ -19,7 +19,7 @@ def initialize(name, version, platform, source = nil)
end

def full_name
if platform == Gem::Platform::RUBY or platform.nil?
if platform == Gem::Platform::RUBY || platform.nil?
"#{@name}-#{@version}"
else
"#{@name}-#{@version}-#{platform}"
Expand All @@ -35,7 +35,7 @@ def satisfies?(dependency)
end

def to_lock
if platform == Gem::Platform::RUBY or platform.nil?
if platform == Gem::Platform::RUBY || platform.nil?
out = " #{name} (#{version})\n"
else
out = " #{name} (#{version}-#{platform})\n"
Expand Down
4 changes: 2 additions & 2 deletions lib/bundler/match_platform.rb
Expand Up @@ -5,8 +5,8 @@ module MatchPlatform
include GemHelpers

def match_platform(p)
Gem::Platform::RUBY == platform or
platform.nil? or p == platform or
Gem::Platform::RUBY == platform ||
platform.nil? || p == platform ||
generic(Gem::Platform.new(platform)) === p
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/remote_specification.rb
Expand Up @@ -27,7 +27,7 @@ def fetch_platform
end

def full_name
if platform == Gem::Platform::RUBY or platform.nil?
if platform == Gem::Platform::RUBY || platform.nil?
"#{@name}-#{@version}"
else
"#{@name}-#{@version}-#{platform}"
Expand Down
4 changes: 2 additions & 2 deletions lib/bundler/resolver.rb
Expand Up @@ -312,7 +312,7 @@ def sort_dependencies(dependencies, activated, conflicts)
def amount_constrained(dependency)
@amount_constrained ||= {}
@amount_constrained[dependency.name] ||= begin
if base = @base[dependency.name] and !base.empty?
if (base = @base[dependency.name]) && !base.empty?
dependency.requirement.satisfied_by?(base.first.version) ? 0 : 1
else
base_dep = Dependency.new dependency.name, ">= 0.a"
Expand All @@ -332,7 +332,7 @@ def verify_gemfile_dependencies_are_found!(requirements)
requirements.each do |requirement|
next if requirement.name == "bundler"
if search_for(requirement).empty?
if base = @base[requirement.name] and !base.empty?
if (base = @base[requirement.name]) && !base.empty?
version = base.first.version
message = "You have requested:\n" \
" #{requirement.name} #{requirement.requirement}\n\n" \
Expand Down
4 changes: 2 additions & 2 deletions lib/bundler/rubygems_integration.rb
Expand Up @@ -354,15 +354,15 @@ def replace_bin_path(specs)

if exec_name
spec = specs.find {|s| s.executables.include?(exec_name) }
spec or raise Gem::Exception, "can't find executable #{exec_name}"
raise(Gem::Exception, "can't find executable #{exec_name}") unless spec
unless spec.name == name
warn "Bundler is using a binstub that was created for a different gem.\n" \
"This is deprecated, in future versions you may need to `bundle binstub #{name}` " \
"to work around a system/bundle conflict."
end
else
spec = specs.find {|s| s.name == name }
exec_name = spec.default_executable or raise Gem::Exception, "no default executable for #{spec.full_name}"
raise Gem::Exception, "no default executable for #{spec.full_name}" unless exec_name = spec.default_executable
end

gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/runtime.rb
Expand Up @@ -21,7 +21,7 @@ def setup(*groups)
raise GemNotFound, "#{spec.full_name} is missing. Run `bundle` to get it."
end

if activated_spec = Bundler.rubygems.loaded_specs(spec.name) and activated_spec.version != spec.version
if (activated_spec = Bundler.rubygems.loaded_specs(spec.name)) && activated_spec.version != spec.version
e = Gem::LoadError.new "You have already activated #{activated_spec.name} #{activated_spec.version}, " \
"but your Gemfile requires #{spec.name} #{spec.version}. Prepending " \
"`bundle exec` to your command may solve this."
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/settings.rb
Expand Up @@ -29,7 +29,7 @@ def [](name)
end

def []=(key, value)
local_config_file or raise GemfileNotFound, "Could not locate Gemfile"
local_config_file || raise(GemfileNotFound, "Could not locate Gemfile")
set_key(key, value, @local_config, local_config_file)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/support/builders.rb
Expand Up @@ -408,7 +408,7 @@ def build_with(builder, name, args, &blk)

Array(versions).each do |version|
spec = builder.new(self, name, version)
if !spec.authors or spec.authors.empty?
if !spec.authors || spec.authors.empty?
spec.authors = ["no one"]
end
yield spec if block_given?
Expand Down Expand Up @@ -666,7 +666,7 @@ def _build(opts)
destination = opts[:path] || _default_path
FileUtils.mkdir_p(destination)

if !@spec.authors or @spec.authors.empty?
if !@spec.authors || @spec.authors.empty?
@spec.authors = ["that guy"]
end

Expand Down

0 comments on commit bf5c235

Please sign in to comment.