Skip to content
Snippets Groups Projects
Commit 7a38bab3 authored by Mike McQuaid's avatar Mike McQuaid
Browse files

Fixup all RuboCop warnings.

parent 4356016b
No related branches found
No related tags found
No related merge requests found
Showing
with 32 additions and 41 deletions
......@@ -98,10 +98,10 @@ module Homebrew
reqs = reqs_by_formula.map(&:last)
else
deps = f.deps.reject do |dep|
ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) }
ignores.any? { |ignore| dep.send(ignore) } && includes.none? { |include| dep.send(include) }
end
reqs = f.requirements.reject do |req|
ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) }
ignores.any? { |ignore| req.send(ignore) } && includes.none? { |include| req.send(include) }
end
end
next true if deps.any? do |dep|
......
......@@ -19,5 +19,5 @@ end
def plural(n, s = "s")
odeprecated "#plural", "Formatter.pluralize"
n == 1 ? "" : s
(n == 1) ? "" : s
end
......@@ -16,7 +16,7 @@ class CxxStdlib
if type && ![:libstdcxx, :libcxx].include?(type)
raise ArgumentError, "Invalid C++ stdlib type: #{type}"
end
klass = compiler.to_s =~ GNU_GCC_REGEXP ? GnuStdlib : AppleStdlib
klass = (compiler.to_s =~ GNU_GCC_REGEXP) ? GnuStdlib : AppleStdlib
klass.new(type, compiler)
end
......
......@@ -121,7 +121,7 @@ class Descriptions
blank = Formatter.warning("[no description]")
@descriptions.keys.sort.each do |full_name|
short_name = short_names[full_name]
printed_name = short_name_counts[short_name] == 1 ? short_name : full_name
printed_name = (short_name_counts[short_name] == 1) ? short_name : full_name
description = @descriptions[full_name] || blank
puts "#{Tty.bold}#{printed_name}:#{Tty.reset} #{description}"
end
......
......@@ -591,9 +591,7 @@ class FormulaAuditor
def audit_homepage
homepage = formula.homepage
if homepage.nil? || homepage.empty?
return
end
return if homepage.nil? || homepage.empty?
return unless @online
......@@ -988,9 +986,7 @@ class FormulaAuditor
problem ":apr is deprecated. Usage should be \"apr-util\""
end
if line =~ /depends_on :tex/
problem ":tex is deprecated"
end
problem ":tex is deprecated" if line =~ /depends_on :tex/
if line =~ /depends_on\s+['"](.+)['"]\s+=>\s+:(lua|perl|python|ruby)(\d*)/
problem "#{$2} modules should be vendored rather than use deprecated `depends_on \"#{$1}\" => :#{$2}#{$3}`"
......
......@@ -314,8 +314,8 @@ module Homebrew
old_spec = f.bottle_specification
if ARGV.include?("--keep-old") && !old_spec.checksums.empty?
mismatches = [:root_url, :prefix, :cellar, :rebuild].select do |key|
old_spec.send(key) != bottle.send(key)
mismatches = [:root_url, :prefix, :cellar, :rebuild].reject do |key|
old_spec.send(key) == bottle.send(key)
end
mismatches.delete(:cellar) if old_spec.cellar == :any && bottle.cellar == :any_skip_relocation
unless mismatches.empty?
......@@ -382,9 +382,7 @@ module Homebrew
bottle = BottleSpecification.new
bottle.root_url bottle_hash["bottle"]["root_url"]
cellar = bottle_hash["bottle"]["cellar"]
if cellar == "any" || cellar == "any_skip_relocation"
cellar = cellar.to_sym
end
cellar = cellar.to_sym if ["any", "any_skip_relocation"].include?(cellar)
bottle.cellar cellar
bottle.prefix bottle_hash["bottle"]["prefix"]
bottle.rebuild bottle_hash["bottle"]["rebuild"]
......
......@@ -21,7 +21,7 @@ module Homebrew
# If no brews are listed, open the project root in an editor.
if ARGV.named.empty?
editor = File.basename which_editor
if editor == "mate" || editor == "subl"
if ["mate", "subl"].include?(editor)
# If the user is using TextMate or Sublime Text,
# give a nice project view instead.
exec_editor HOMEBREW_REPOSITORY+"bin/brew",
......
......@@ -60,9 +60,7 @@ module Homebrew
end
Homebrew.install_gem_setup_path! "bundler"
unless quiet_system("bundle", "check")
system "bundle", "install"
end
system "bundle", "install" unless quiet_system("bundle", "check")
parallel = true
......
......@@ -61,9 +61,9 @@ module FormulaCellarChecks
valid_extensions = %w[.a .dylib .framework .jnilib .la .o .so
.jar .prl .pm .sh]
non_libraries = formula.lib.children.select do |g|
non_libraries = formula.lib.children.reject do |g|
next if g.directory?
!valid_extensions.include? g.extname
valid_extensions.include? g.extname
end
return if non_libraries.empty?
......
......@@ -472,7 +472,7 @@ class FormulaInstaller
def effective_build_options_for(dependent, inherited_options = [])
args = dependent.build.used_options
args |= dependent == formula ? options : inherited_options
args |= (dependent == formula) ? options : inherited_options
args |= Tab.for_formula(dependent).used_options
args &= dependent.options
BuildOptions.new(args, dependent.options)
......@@ -680,7 +680,6 @@ class FormulaInstaller
if !formula.prefix.directory? || Keg.new(formula.prefix).empty_installation?
raise "Empty installation"
end
rescue Exception
ignore_interrupts do
# any exceptions must leave us with nothing installed
......
......@@ -367,7 +367,7 @@ class Keg
dep_formula = Formulary.factory(dep["full_name"])
dep_formula == to_formula
rescue FormulaUnavailableError
next "#{tap}/#{name}" == dep["full_name"]
next dep["full_name"] == "#{tap}/#{name}"
end
end
end
......
......@@ -47,7 +47,7 @@ module Language
def cabal_install(*args)
# cabal hardcodes 64 as the maximum number of parallel jobs
# https://github.com/Homebrew/legacy-homebrew/issues/49509
make_jobs = ENV.make_jobs > 64 ? 64 : ENV.make_jobs
make_jobs = (ENV.make_jobs > 64) ? 64 : ENV.make_jobs
# cabal-install's dependency-resolution backtracking strategy can easily
# need more than the default 2,000 maximum number of "backjumps," since
......
......@@ -90,7 +90,7 @@ module OS
@locator ||= SDKLocator.new
begin
sdk = if v.nil?
Xcode.version.to_i >= 7 ? @locator.latest_sdk : @locator.sdk_for(version)
(Xcode.version.to_i >= 7) ? @locator.latest_sdk : @locator.sdk_for(version)
else
@locator.sdk_for v
end
......
......@@ -62,10 +62,10 @@ class LinkageChecker
declared_deps = formula.deps.reject { |dep| filter_out.call(dep) }.map(&:name)
declared_requirement_deps = formula.requirements.reject { |req| filter_out.call(req) }.map(&:default_formula).compact
declared_dep_names = (declared_deps + declared_requirement_deps).map { |dep| dep.split("/").last }
undeclared_deps = @brewed_dylibs.keys.select do |full_name|
undeclared_deps = @brewed_dylibs.keys.reject do |full_name|
name = full_name.split("/").last
next false if name == formula.name
!declared_dep_names.include?(name)
next true if name == formula.name
declared_dep_names.include?(name)
end
undeclared_deps.sort do |a, b|
if a.include?("/") && !b.include?("/")
......
......@@ -96,7 +96,7 @@ module RuboCop
else
indentation = " " * (start_column(node2) - line_start_column(node2))
# No line breaks upto version_scheme, order_idx == 8
line_breaks = order_idx>8 ? "\n\n" : "\n"
line_breaks = (order_idx>8) ? "\n\n" : "\n"
corrector.insert_before(node2.source_range, node1.source+line_breaks+indentation)
end
corrector.remove(range_with_surrounding_space(node1.source_range, :left))
......
......@@ -176,7 +176,7 @@ class Sandbox
def add_rule(rule)
s = "("
s << (rule[:allow] ? "allow": "deny")
s << ((rule[:allow]) ? "allow": "deny")
s << " #{rule[:operation]}"
s << " (#{rule[:filter]})" if rule[:filter]
s << " (with #{rule[:modifier]})" if rule[:modifier]
......
......@@ -235,7 +235,7 @@ class Bottle
end
def suffix
s = rebuild > 0 ? ".#{rebuild}" : ""
s = (rebuild > 0) ? ".#{rebuild}" : ""
".bottle#{s}.tar.gz"
end
end
......
......@@ -2,11 +2,11 @@ source "https://rubygems.org"
gem "parallel_tests"
gem "rspec"
gem "rubocop"
gem "rspec-its", require: false
gem "rspec-wait", require: false
gem "rubocop"
group :coverage do
gem "simplecov", require: false
gem "codecov", require: false
gem "simplecov", require: false
end
describe "download strategies", :cask do
let(:url) { "http://example.com/cask.dmg" }
let(:url_options) { Hash.new }
let(:url_options) { {} }
let(:cask) {
instance_double(Hbc::Cask, token: "some-cask",
url: Hbc::URL.new(url, url_options),
......
......@@ -4,11 +4,11 @@ require "utils/tty"
describe Formatter do
describe "::columns" do
let(:input) {
[
"aa",
"bbb",
"ccc",
"dd",
%w[
aa
bbb
ccc
dd
]
}
subject { described_class.columns(input) }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment