aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMarkus Reiter2016-09-23 17:17:49 +0200
committerGitHub2016-09-23 17:17:49 +0200
commit246bb1a3b18cf41c2499cc78b7eac8fab503c5d6 (patch)
tree24c62806b60d59b0f9a689ac693a7afec5bd3291 /Library
parent4cbeb1e981e974474a0d37c120ffa18e13ac3db9 (diff)
parentfe2d51e0b9d4d9c138e512c245b1ed8d0f1dbf53 (diff)
downloadbrew-246bb1a3b18cf41c2499cc78b7eac8fab503c5d6.tar.bz2
Merge pull request #1050 from reitermarkus/rubocop
RuboCop changes.
Diffstat (limited to 'Library')
-rw-r--r--Library/.rubocop.yml2
-rw-r--r--Library/.rubocop_rules.yml41
-rw-r--r--Library/.rubocop_todo.yml177
-rw-r--r--Library/Homebrew/brew.rb6
-rw-r--r--Library/Homebrew/build.rb5
-rw-r--r--Library/Homebrew/cask/.rubocop.yml58
-rw-r--r--Library/Homebrew/cask/Gemfile4
-rw-r--r--Library/Homebrew/cask/Gemfile.lock17
-rw-r--r--Library/Homebrew/cask/Rakefile7
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact/abstract_flight_block.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact/moved.rb6
-rw-r--r--Library/Homebrew/cask/lib/hbc/cache.rb30
-rw-r--r--Library/Homebrew/cask/lib/hbc/cask.rb45
-rw-r--r--Library/Homebrew/cask/lib/hbc/caskroom.rb52
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli.rb4
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/audit.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/cleanup.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/doctor.rb10
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/install.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/internal_audit_modified_casks.rb8
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/list.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/uninstall.rb4
-rw-r--r--Library/Homebrew/cask/lib/hbc/dsl.rb12
-rw-r--r--Library/Homebrew/cask/lib/hbc/dsl/base.rb16
-rw-r--r--Library/Homebrew/cask/lib/hbc/dsl/stanza_proxy.rb20
-rw-r--r--Library/Homebrew/cask/lib/hbc/installer.rb24
-rw-r--r--Library/Homebrew/cask/lib/hbc/source/tapped_qualified.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/system_command.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/url_checker.rb2
-rw-r--r--Library/Homebrew/cask/lib/hbc/utils.rb15
-rw-r--r--Library/Homebrew/cask/spec/cask/cli/cleanup_spec.rb2
-rw-r--r--Library/Homebrew/cask/spec/spec_helper.rb2
-rw-r--r--Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb9
-rw-r--r--Library/Homebrew/cask/test/cask/cli/list_test.rb4
-rw-r--r--Library/Homebrew/cask/test/test_helper.rb2
-rw-r--r--Library/Homebrew/caveats.rb51
-rw-r--r--Library/Homebrew/cleaner.rb6
-rw-r--r--Library/Homebrew/cleanup.rb8
-rw-r--r--Library/Homebrew/cmd/cleanup.rb14
-rw-r--r--Library/Homebrew/cmd/diy.rb8
-rw-r--r--Library/Homebrew/cmd/info.rb7
-rw-r--r--Library/Homebrew/cmd/install.rb10
-rw-r--r--Library/Homebrew/cmd/reinstall.rb9
-rw-r--r--Library/Homebrew/cmd/search.rb9
-rw-r--r--Library/Homebrew/cmd/style.rb32
-rw-r--r--Library/Homebrew/cxxstdlib.rb2
-rw-r--r--Library/Homebrew/debrew.rb26
-rw-r--r--Library/Homebrew/dependencies.rb2
-rw-r--r--Library/Homebrew/dependency_collector.rb14
-rw-r--r--Library/Homebrew/descriptions.rb6
-rw-r--r--Library/Homebrew/dev-cmd/audit.rb105
-rw-r--r--Library/Homebrew/dev-cmd/bottle.rb74
-rw-r--r--Library/Homebrew/dev-cmd/edit.rb6
-rw-r--r--Library/Homebrew/dev-cmd/mirror.rb4
-rw-r--r--Library/Homebrew/dev-cmd/pull.rb12
-rw-r--r--Library/Homebrew/dev-cmd/test-bot.rb29
-rw-r--r--Library/Homebrew/diagnostic.rb16
-rw-r--r--Library/Homebrew/download_strategy.rb25
-rw-r--r--Library/Homebrew/extend/ARGV.rb2
-rw-r--r--Library/Homebrew/extend/ENV/std.rb8
-rw-r--r--Library/Homebrew/extend/ENV/super.rb4
-rw-r--r--Library/Homebrew/extend/os/blacklist.rb5
-rw-r--r--Library/Homebrew/extend/os/bottles.rb5
-rw-r--r--Library/Homebrew/extend/os/cleaner.rb5
-rw-r--r--Library/Homebrew/extend/os/dependency_collector.rb5
-rw-r--r--Library/Homebrew/extend/os/development_tools.rb5
-rw-r--r--Library/Homebrew/extend/os/diagnostic.rb5
-rw-r--r--Library/Homebrew/extend/os/emoji.rb5
-rw-r--r--Library/Homebrew/extend/os/extend/ENV/shared.rb5
-rw-r--r--Library/Homebrew/extend/os/extend/ENV/std.rb5
-rw-r--r--Library/Homebrew/extend/os/extend/ENV/super.rb5
-rw-r--r--Library/Homebrew/extend/os/formula_cellar_checks.rb5
-rw-r--r--Library/Homebrew/extend/os/keg_relocate.rb5
-rw-r--r--Library/Homebrew/extend/os/mac/extend/ENV/shared.rb9
-rw-r--r--Library/Homebrew/extend/os/system_config.rb5
-rw-r--r--Library/Homebrew/extend/pathname.rb4
-rw-r--r--Library/Homebrew/formula.rb18
-rw-r--r--Library/Homebrew/formula_cellar_checks.rb2
-rw-r--r--Library/Homebrew/formula_installer.rb19
-rw-r--r--Library/Homebrew/formula_lock.rb5
-rw-r--r--Library/Homebrew/formula_versions.rb4
-rw-r--r--Library/Homebrew/formulary.rb8
-rw-r--r--Library/Homebrew/keg.rb27
-rw-r--r--Library/Homebrew/language/haskell.rb9
-rw-r--r--Library/Homebrew/migrator.rb4
-rw-r--r--Library/Homebrew/options.rb2
-rw-r--r--Library/Homebrew/os/mac/xcode.rb2
-rw-r--r--Library/Homebrew/patch.rb2
-rw-r--r--Library/Homebrew/pkg_version.rb2
-rw-r--r--Library/Homebrew/requirement.rb6
-rw-r--r--Library/Homebrew/requirements.rb6
-rw-r--r--Library/Homebrew/software_spec.rb11
-rw-r--r--Library/Homebrew/tab.rb6
-rw-r--r--Library/Homebrew/test/test_diagnostic.rb2
-rw-r--r--Library/Homebrew/test/test_download_strategies.rb2
-rw-r--r--Library/Homebrew/test/test_pathname.rb2
-rw-r--r--Library/Homebrew/utils/git.rb4
-rw-r--r--Library/Homebrew/version.rb4
100 files changed, 619 insertions, 697 deletions
diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml
index d6dc0c429..99de0d8a2 100644
--- a/Library/.rubocop.yml
+++ b/Library/.rubocop.yml
@@ -4,6 +4,8 @@ inherit_from:
AllCops:
TargetRubyVersion: 2.0
+ Include:
+ - '**/.simplecov'
Exclude:
- 'Homebrew/cask/**/*'
- 'Homebrew/vendor/**/*'
diff --git a/Library/.rubocop_rules.yml b/Library/.rubocop_rules.yml
index cde310930..95f8ae0a3 100644
--- a/Library/.rubocop_rules.yml
+++ b/Library/.rubocop_rules.yml
@@ -7,6 +7,14 @@ Style/StringLiterals:
Style/StringLiteralsInInterpolation:
EnforcedStyle: double_quotes
+# only for numbers >= 1_000_000
+Style/NumericLiterals:
+ MinDigits: 7
+
+# zero-prefixed octal literals are just too widely used (and mostly understood)
+Style/NumericLiteralPrefix:
+ EnforcedOctalStyle: zero_only
+
# percent-x is allowed for multiline
Style/CommandLiteral:
EnforcedStyle: mixed
@@ -58,14 +66,6 @@ Lint/ParenthesesAsGroupedExpression:
Style/EmptyLineBetweenDefs:
AllowAdjacentOneLineDefs: true
-# port numbers and such tech stuff
-Style/NumericLiterals:
- Enabled: false
-
-# zero-prefixed octal literals are just too widely used (and mostly understood)
-Style/NumericLiteralPrefix:
- EnforcedOctalStyle: zero_only
-
# consistency and readability when faced with string interpolation
Style/PercentLiteralDelimiters:
PreferredDelimiters:
@@ -93,15 +93,31 @@ Style/AlignParameters:
# counterproductive in formulas, notably within the install method
Style/GuardClause:
- Enabled: false
+ Exclude:
+ - 'Taps/**/*'
Style/IfUnlessModifier:
+ Exclude:
+ - 'Taps/**/*'
+
+# TODO: enforce when rubocop has fixed this
+# https://github.com/bbatsov/rubocop/issues/3516
+Style/VariableNumber:
+ Enabled: false
+
+# TODO: enforce when rubocop has shipped this
+# https://github.com/bbatsov/rubocop/pull/3513
+Style/TernaryParentheses:
Enabled: false
# dashes in filenames are typical
-# TODO: enforce when rubocop has fixed this
-# https://github.com/bbatsov/rubocop/issues/1545
Style/FileName:
- Enabled: false
+ # matches:
+ # file_name.rb (default)
+ # file-name.rb, --filename.rb (command names)
+ # FILENAME.rb (ARGV and ENV)
+ # does not match:
+ # dashes-and_underscores.rb
+ Regex: !ruby/regexp /^((([\dA-Z]+|[\da-z]+)(_([\dA-Z]+|[\da-z]+))*|(\-\-)?([\dA-Z]+|[\da-z]+)(-([\dA-Z]+|[\da-z]+))*))(\.rb)?$/
# no percent word array, being friendly to non-ruby users
# TODO: enforce when rubocop has fixed this
@@ -134,6 +150,7 @@ Style/MethodName:
Style/PredicateName:
Exclude:
- 'Homebrew/compat/**/*'
+ NameWhitelist: is_32_bit?, is_64_bit?
# `formula do` uses nested method definitions
Lint/NestedMethodDefinition:
diff --git a/Library/.rubocop_todo.yml b/Library/.rubocop_todo.yml
index a898d2f79..80fa07aab 100644
--- a/Library/.rubocop_todo.yml
+++ b/Library/.rubocop_todo.yml
@@ -1,21 +1,11 @@
# This configuration was generated by
-# `rubocop --auto-gen-config --exclude-limit 30`
-# on 2016-09-18 15:15:22 +0100 using RuboCop version 0.41.2.
+# `rubocop --auto-gen-config --exclude-limit 100`
+# on 2016-09-22 20:07:41 +0200 using RuboCop version 0.43.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
-# Offense count: 4
-# Cop supports --auto-correct.
-# Configuration parameters: AlignWith, SupportedStyles, AutoCorrect.
-# SupportedStyles: keyword, variable, start_of_line
-Lint/EndAlignment:
- Exclude:
- - 'Homebrew/download_strategy.rb'
- - 'Homebrew/keg.rb'
- - 'Homebrew/os/mac/cctools_mach.rb'
-
# Offense count: 18
Lint/HandleExceptions:
Exclude:
@@ -52,11 +42,6 @@ Lint/NestedMethodDefinition:
- 'Homebrew/dev-cmd/bottle.rb'
- 'Homebrew/dev-cmd/test-bot.rb'
-# Offense count: 2
-Lint/NonLocalExitFromIterator:
- Exclude:
- - 'Homebrew/extend/pathname.rb'
-
# Offense count: 28
Lint/RescueException:
Exclude:
@@ -80,12 +65,7 @@ Lint/RescueException:
# Offense count: 1
Lint/ShadowedException:
Exclude:
- - 'Homebrew/brew.rb'
-
-# Offense count: 2
-Lint/UselessAssignment:
- Exclude:
- - 'Homebrew/requirements.rb'
+ - 'Homebrew/utils/fork.rb'
# Offense count: 18
Metrics/BlockNesting:
@@ -94,19 +74,13 @@ Metrics/BlockNesting:
# Offense count: 20
# Configuration parameters: CountComments.
Metrics/ModuleLength:
- Max: 400
+ Max: 370
-# Offense count: 1
+# Offense count: 2
# Configuration parameters: CountKeywordArgs.
Metrics/ParameterLists:
Max: 6
-# Offense count: 2
-Performance/FixedSize:
- Exclude:
- - 'Homebrew/dev-cmd/audit.rb'
- - 'Homebrew/dev-cmd/bottle.rb'
-
# Offense count: 8
Style/AccessorMethodName:
Exclude:
@@ -125,33 +99,10 @@ Style/Alias:
Exclude:
- 'Homebrew/blacklist.rb'
-# Offense count: 26
+# Offense count: 1
Style/CaseEquality:
Exclude:
- - 'Homebrew/cleanup.rb'
- - 'Homebrew/cmd/search.rb'
- 'Homebrew/compilers.rb'
- - 'Homebrew/cxxstdlib.rb'
- - 'Homebrew/debrew.rb'
- - 'Homebrew/dependencies.rb'
- - 'Homebrew/dependency_collector.rb'
- - 'Homebrew/download_strategy.rb'
- - 'Homebrew/formula.rb'
- - 'Homebrew/options.rb'
- - 'Homebrew/patch.rb'
- - 'Homebrew/pkg_version.rb'
- - 'Homebrew/requirement.rb'
- - 'Homebrew/requirements.rb'
- - 'Homebrew/software_spec.rb'
- - 'Homebrew/version.rb'
-
-# Offense count: 1
-# Cop supports --auto-correct.
-# Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep, IndentationWidth.
-# SupportedStyles: case, end
-Style/CaseIndentation:
- Exclude:
- - 'Homebrew/keg.rb'
# Offense count: 11
Style/ClassVars:
@@ -168,17 +119,6 @@ Style/ConstantName:
Exclude:
- 'Homebrew/os/mac.rb'
-# Offense count: 10
-Style/DoubleNegation:
- Exclude:
- - 'Homebrew/extend/ARGV.rb'
- - 'Homebrew/formula_installer.rb'
- - 'Homebrew/os/mac/cctools_keg.rb'
- - 'Homebrew/os/mac/ruby_keg.rb'
- - 'Homebrew/os/mac/xcode.rb'
- - 'Homebrew/requirement.rb'
- - 'Homebrew/software_spec.rb'
-
# Offense count: 1
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: format, sprintf, percent
@@ -193,22 +133,57 @@ Style/GlobalVars:
- 'Homebrew/diagnostic.rb'
- 'Homebrew/utils.rb'
-# Offense count: 2
-Style/IdenticalConditionalBranches:
+# Offense count: 70
+# Configuration parameters: MinBodyLength.
+Style/GuardClause:
Exclude:
+ - 'Taps/**/*'
+ - 'Homebrew/cmd/update-report.rb'
+ - 'Homebrew/dependency_collector.rb'
+ - 'Homebrew/dev-cmd/audit.rb'
+ - 'Homebrew/dev-cmd/pull.rb'
+ - 'Homebrew/dev-cmd/test-bot.rb'
+ - 'Homebrew/download_strategy.rb'
+ - 'Homebrew/extend/ARGV.rb'
+ - 'Homebrew/extend/ENV/shared.rb'
+ - 'Homebrew/extend/ENV/std.rb'
+ - 'Homebrew/extend/ENV/super.rb'
+ - 'Homebrew/extend/fileutils.rb'
+ - 'Homebrew/extend/os/mac/extend/ENV/std.rb'
+ - 'Homebrew/extend/os/mac/formula_cellar_checks.rb'
+ - 'Homebrew/extend/os/mac/utils/bottles.rb'
+ - 'Homebrew/extend/string.rb'
+ - 'Homebrew/formula.rb'
+ - 'Homebrew/formula_installer.rb'
- 'Homebrew/formula_lock.rb'
+ - 'Homebrew/formulary.rb'
+ - 'Homebrew/keg.rb'
+ - 'Homebrew/migrator.rb'
+ - 'Homebrew/os/mac/xcode.rb'
+ - 'Homebrew/patch.rb'
+ - 'Homebrew/requirement.rb'
+ - 'Homebrew/tap.rb'
+ - 'Homebrew/test/test_cmd_testbot.rb'
+ - 'Homebrew/test/test_integration_cmds.rb'
+ - 'Homebrew/test/testing_env.rb'
+ - 'Homebrew/utils.rb'
+ - 'Homebrew/utils/popen.rb'
+ - 'Homebrew/version.rb'
-# Offense count: 5
-# Configuration parameters: EnforcedStyle, SupportedStyles.
-# SupportedStyles: snake_case, camelCase
-Style/MethodName:
+# Offense count: 51
+# Cop supports --auto-correct.
+# Configuration parameters: MaxLineLength.
+Style/IfUnlessModifier:
Exclude:
- - 'Homebrew/compat/**/*'
- - 'Homebrew/cleanup.rb'
- - 'Homebrew/diagnostic.rb'
- - 'Homebrew/formula_cellar_checks.rb'
- - 'Homebrew/formula_installer.rb'
- - 'Homebrew/os/mac/cctools_mach.rb'
+ - 'Taps/**/*'
+ - 'Homebrew/dev-cmd/audit.rb'
+
+# Offense count: 2
+# Cop supports --auto-correct.
+# Configuration parameters: SupportedStyles, IndentationWidth.
+# SupportedStyles: special_inside_parentheses, consistent, align_brackets
+Style/IndentArray:
+ EnforcedStyle: special_inside_parentheses
# Offense count: 7
# Configuration parameters: EnforcedStyle, SupportedStyles.
@@ -241,14 +216,6 @@ Style/MutableConstant:
- 'Homebrew/tab.rb'
- 'Homebrew/tap.rb'
-# Offense count: 1
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
-# SupportedStyles: skip_modifier_ifs, always
-Style/Next:
- Exclude:
- - 'Homebrew/dev-cmd/test-bot.rb'
-
# Offense count: 9
Style/OpMethod:
Exclude:
@@ -257,37 +224,9 @@ Style/OpMethod:
- 'Homebrew/install_renamed.rb'
- 'Homebrew/options.rb'
-# Offense count: 4
-# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
-# NamePrefix: is_, has_, have_
-# NamePrefixBlacklist: is_, has_, have_
-# NameWhitelist: is_a?
-Style/PredicateName:
- Exclude:
- - 'Homebrew/compat/**/*'
- - 'Homebrew/download_strategy.rb'
- - 'Homebrew/hardware.rb'
-
-# Offense count: 7
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
-# SupportedStyles: slashes, percent_r, mixed
-Style/RegexpLiteral:
- Exclude:
- - 'Homebrew/diagnostic.rb'
- - 'Homebrew/keg.rb'
- - 'Homebrew/version.rb'
-
-# Offense count: 1
+# Offense count: 2
# Cop supports --auto-correct.
-# Configuration parameters: AllowAsExpressionSeparator.
-Style/Semicolon:
- Exclude:
- - 'Homebrew/descriptions.rb'
-
-# Offense count: 1
-# Configuration parameters: Methods.
-# Methods: {"reduce"=>["a", "e"]}, {"inject"=>["a", "e"]}
-Style/SingleLineBlockParams:
- Exclude:
- - 'Homebrew/diagnostic.rb'
+# Configuration parameters: SupportedStyles.
+# SupportedStyles: use_perl_names, use_english_names
+Style/SpecialGlobalVars:
+ EnforcedStyle: use_perl_names
diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb
index 0d1bcbdda..1ba3fb8c2 100644
--- a/Library/Homebrew/brew.rb
+++ b/Library/Homebrew/brew.rb
@@ -37,9 +37,9 @@ begin
cmd = nil
ARGV.dup.each_with_index do |arg, i|
- if help_flag && cmd
- break
- elsif help_flag_list.include?(arg)
+ break if help_flag && cmd
+
+ if help_flag_list.include?(arg)
# Option-style help: Both `--help <cmd>` and `<cmd> --help` are fine.
help_flag = true
elsif arg == "help" && !cmd
diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb
index f4dde895a..d3c2833d4 100644
--- a/Library/Homebrew/build.rb
+++ b/Library/Homebrew/build.rb
@@ -31,9 +31,8 @@ class Build
def post_superenv_hacks
# Only allow Homebrew-approved directories into the PATH, unless
# a formula opts-in to allowing the user's path.
- if formula.env.userpaths? || reqs.any? { |rq| rq.env.userpaths? }
- ENV.userpaths!
- end
+ return unless formula.env.userpaths? || reqs.any? { |rq| rq.env.userpaths? }
+ ENV.userpaths!
end
def effective_build_options_for(dependent)
diff --git a/Library/Homebrew/cask/.rubocop.yml b/Library/Homebrew/cask/.rubocop.yml
index 31a2a193d..076b87f61 100644
--- a/Library/Homebrew/cask/.rubocop.yml
+++ b/Library/Homebrew/cask/.rubocop.yml
@@ -1,10 +1,8 @@
-require: 'rubocop-cask'
-
AllCops:
TargetRubyVersion: 2.0
Exclude:
+ - '**/.simplecov'
- '**/Casks/**/*'
- - 'developer/**/*'
- '**/vendor/**/*'
Metrics/AbcSize:
@@ -16,10 +14,10 @@ Metrics/ClassLength:
Metrics/CyclomaticComplexity:
Enabled: false
-Metrics/MethodLength:
+Metrics/LineLength:
Enabled: false
-Metrics/PerceivedComplexity:
+Metrics/MethodLength:
Enabled: false
Metrics/ModuleLength:
@@ -29,6 +27,16 @@ Metrics/ModuleLength:
- 'lib/hbc/macos.rb'
- 'lib/hbc/utils.rb'
+Metrics/PerceivedComplexity:
+ Enabled: false
+
+Style/AlignHash:
+ EnforcedHashRocketStyle: table
+ EnforcedColonStyle: table
+
+Style/BarePercentLiterals:
+ EnforcedStyle: percent_q
+
Style/BlockDelimiters:
EnforcedStyle: semantic
FunctionalMethods:
@@ -59,6 +67,8 @@ Style/BlockDelimiters:
- chdir
- context
- create
+ - define_method
+ - define_singleton_method
- each_with_object
- fork
- measure
@@ -75,15 +85,47 @@ Style/BlockDelimiters:
- lambda
- proc
-
Style/ClassAndModuleChildren:
EnforcedStyle: compact
-Style/PredicateName:
- NameWhitelist: is_32_bit?, is_64_bit?
+Style/Documentation:
+ Enabled: false
+
+Style/FileName:
+ Regex: !ruby/regexp /^((([\dA-Z]+|[\da-z]+)(_([\dA-Z]+|[\da-z]+))*|(\-\-)?([\dA-Z]+|[\da-z]+)(-([\dA-Z]+|[\da-z]+))*))(\.rb)?$/
+
+Style/HashSyntax:
+ EnforcedStyle: ruby19_no_mixed_keys
+
+Style/IndentArray:
+ EnforcedStyle: align_brackets
+
+Style/IndentHash:
+ EnforcedStyle: align_braces
+
+Style/PercentLiteralDelimiters:
+ PreferredDelimiters:
+ '%': '{}'
+ '%i': '{}'
+ '%q': '{}'
+ '%Q': '{}'
+ '%r': '{}'
+ '%s': '()'
+ '%w': '[]'
+ '%W': '[]'
+ '%x': '()'
Style/RaiseArgs:
EnforcedStyle: exploded
+Style/RegexpLiteral:
+ EnforcedStyle: percent_r
+
Style/StringLiterals:
EnforcedStyle: double_quotes
+
+Style/StringLiteralsInInterpolation:
+ EnforcedStyle: double_quotes
+
+Style/TrailingCommaInLiteral:
+ EnforcedStyleForMultiline: comma
diff --git a/Library/Homebrew/cask/Gemfile b/Library/Homebrew/cask/Gemfile
index cba638dc9..df06bd5d4 100644
--- a/Library/Homebrew/cask/Gemfile
+++ b/Library/Homebrew/cask/Gemfile
@@ -7,10 +7,6 @@ group :debug do
gem "pry-byebug", platforms: :mri
end
-group :development do
- gem "rubocop-cask", "~> 0.8.3"
-end
-
group :test do
# This is SimpleCov v0.12.0 with two fixes merged on top, that finally resolve
# all issues with parallel tests, uncovered files, and tracked files. Switch
diff --git a/Library/Homebrew/cask/Gemfile.lock b/Library/Homebrew/cask/Gemfile.lock
index 9d53aebf8..93dd59712 100644
--- a/Library/Homebrew/cask/Gemfile.lock
+++ b/Library/Homebrew/cask/Gemfile.lock
@@ -12,7 +12,6 @@ GEM
remote: https://rubygems.org/
specs:
ansi (1.5.0)
- ast (2.3.0)
builder (3.2.2)
byebug (9.0.5)
codecov (0.1.5)
@@ -36,9 +35,6 @@ GEM
parallel (1.9.0)
parallel_tests (2.9.0)
parallel
- parser (2.3.1.2)
- ast (~> 2.2)
- powerpack (0.1.1)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
@@ -46,8 +42,6 @@ GEM
pry-byebug (3.4.0)
byebug (~> 9.0)
pry (~> 0.10)
- public_suffix (2.0.2)
- rainbow (2.1.0)
rake (10.4.2)
rspec (3.0.0)
rspec-core (~> 3.0.0)
@@ -66,19 +60,9 @@ GEM
rspec-support (3.0.4)
rspec-wait (0.0.9)
rspec (>= 3, < 4)
- rubocop (0.41.2)
- parser (>= 2.3.1.1, < 3.0)
- powerpack (~> 0.1)
- rainbow (>= 1.99.1, < 3.0)
- ruby-progressbar (~> 1.7)
- unicode-display_width (~> 1.0, >= 1.0.1)
- rubocop-cask (0.8.3)
- public_suffix (~> 2.0)
- rubocop (~> 0.41.1)
ruby-progressbar (1.8.1)
simplecov-html (0.10.0)
slop (3.6.0)
- unicode-display_width (1.1.0)
url (0.3.2)
PLATFORMS
@@ -96,7 +80,6 @@ DEPENDENCIES
rspec (~> 3.0.0)
rspec-its
rspec-wait
- rubocop-cask (~> 0.8.3)
simplecov (= 0.12.0)!
BUNDLED WITH
diff --git a/Library/Homebrew/cask/Rakefile b/Library/Homebrew/cask/Rakefile
index fe3e75c98..ec6a4a7f6 100644
--- a/Library/Homebrew/cask/Rakefile
+++ b/Library/Homebrew/cask/Rakefile
@@ -1,6 +1,5 @@
require "rake/testtask"
require "rspec/core/rake_task"
-require "rubocop/rake_task"
homebrew_repo = `brew --repository`.chomp
$LOAD_PATH.unshift(File.expand_path("#{homebrew_repo}/Library/Homebrew"))
@@ -18,12 +17,6 @@ namespace :test do
end
end
-RuboCop::RakeTask.new(:rubocop) do |t|
- t.options = ["--force-exclusion"]
-end
-
-task default: [:rubocop]
-
desc "Open a REPL for debugging and experimentation"
task :console do
require "pry"
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/abstract_flight_block.rb b/Library/Homebrew/cask/lib/hbc/artifact/abstract_flight_block.rb
index fcf98d7ad..c879fc2be 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/abstract_flight_block.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/abstract_flight_block.rb
@@ -10,7 +10,7 @@ class Hbc::Artifact::AbstractFlightBlock < Hbc::Artifact::Base
end
def self.class_for_dsl_key(dsl_key)
- Object.const_get("Hbc::DSL::#{dsl_key.to_s.split('_').collect(&:capitalize).join}")
+ Object.const_get("Hbc::DSL::#{dsl_key.to_s.split("_").collect(&:capitalize).join}")
end
def self.me?(cask)
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/moved.rb b/Library/Homebrew/cask/lib/hbc/artifact/moved.rb
index 8565ab836..8f41e9fd5 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/moved.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/moved.rb
@@ -64,9 +64,9 @@ class Hbc::Artifact::Moved < Hbc::Artifact::Relocated
def delete
ohai "Removing #{self.class.artifact_english_name}: '#{target}'"
- if MacOS.undeletable?(target)
- raise Hbc::CaskError, "Cannot remove undeletable #{self.class.artifact_english_name}"
- elsif force
+ raise Hbc::CaskError, "Cannot remove undeletable #{self.class.artifact_english_name}" if MacOS.undeletable?(target)
+
+ if force
Hbc::Utils.gain_permissions_remove(target, command: @command)
else
target.rmtree
diff --git a/Library/Homebrew/cask/lib/hbc/cache.rb b/Library/Homebrew/cask/lib/hbc/cache.rb
index 9fc5fe0f3..7ae5fcc8c 100644
--- a/Library/Homebrew/cask/lib/hbc/cache.rb
+++ b/Library/Homebrew/cask/lib/hbc/cache.rb
@@ -3,32 +3,32 @@ module Hbc::Cache
def ensure_cache_exists
return if Hbc.cache.exist?
+
odebug "Creating Cache at #{Hbc.cache}"
Hbc.cache.mkpath
end
def migrate_legacy_cache
- if Hbc.legacy_cache.exist?
- ohai "Migrating cached files to #{Hbc.cache}..."
-
- Hbc.legacy_cache.children.select(&:symlink?).each do |symlink|
- file = symlink.readlink
+ return unless Hbc.legacy_cache.exist?
- new_name = file.basename
- .sub(%r{\-((?:(\d|#{Hbc::DSL::Version::DIVIDER_REGEX})*\-\2*)*[^\-]+)$}x,
- '--\1')
+ ohai "Migrating cached files to #{Hbc.cache}..."
+ Hbc.legacy_cache.children.select(&:symlink?).each do |symlink|
+ file = symlink.readlink
- renamed_file = Hbc.cache.join(new_name)
+ new_name = file.basename
+ .sub(%r{\-((?:(\d|#{Hbc::DSL::Version::DIVIDER_REGEX})*\-\2*)*[^\-]+)$}x,
+ '--\1')
- if file.exist?
- puts "#{file} -> #{renamed_file}"
- FileUtils.mv(file, renamed_file)
- end
+ renamed_file = Hbc.cache.join(new_name)
- FileUtils.rm(symlink)
+ if file.exist?
+ puts "#{file} -> #{renamed_file}"
+ FileUtils.mv(file, renamed_file)
end
- FileUtils.remove_entry_secure(Hbc.legacy_cache)
+ FileUtils.rm(symlink)
end
+
+ FileUtils.remove_entry_secure(Hbc.legacy_cache)
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/cask.rb b/Library/Homebrew/cask/lib/hbc/cask.rb
index fd13a6fe7..f19e5b81f 100644
--- a/Library/Homebrew/cask/lib/hbc/cask.rb
+++ b/Library/Homebrew/cask/lib/hbc/cask.rb
@@ -87,28 +87,29 @@ class Hbc::Cask
end
def dumpcask
- if Hbc.respond_to?(:debug) && Hbc.debug
- odebug "Cask instance dumps in YAML:"
- odebug "Cask instance toplevel:", to_yaml
- [
- :name,
- :homepage,
- :url,
- :appcast,
- :version,
- :license,
- :sha256,
- :artifacts,
- :caveats,
- :depends_on,
- :conflicts_with,
- :container,
- :gpg,
- :accessibility_access,
- :auto_updates,
- ].each do |method|
- odebug "Cask instance method '#{method}':", send(method).to_yaml
- end
+ return unless Hbc.respond_to?(:debug)
+ return unless Hbc.debug
+
+ odebug "Cask instance dumps in YAML:"
+ odebug "Cask instance toplevel:", to_yaml
+ [
+ :name,
+ :homepage,
+ :url,
+ :appcast,
+ :version,
+ :license,
+ :sha256,
+ :artifacts,
+ :caveats,
+ :depends_on,
+ :conflicts_with,
+ :container,
+ :gpg,
+ :accessibility_access,
+ :auto_updates,
+ ].each do |method|
+ odebug "Cask instance method '#{method}':", send(method).to_yaml
end
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/caskroom.rb b/Library/Homebrew/cask/lib/hbc/caskroom.rb
index 7dcb35d41..5d26ac222 100644
--- a/Library/Homebrew/cask/lib/hbc/caskroom.rb
+++ b/Library/Homebrew/cask/lib/hbc/caskroom.rb
@@ -3,39 +3,39 @@ module Hbc::Caskroom
def migrate_caskroom_from_repo_to_prefix
repo_caskroom = Hbc.homebrew_repository.join("Caskroom")
- if !Hbc.caskroom.exist? && repo_caskroom.directory?
- ohai "Moving Caskroom from HOMEBREW_REPOSITORY to HOMEBREW_PREFIX"
+ return if Hbc.caskroom.exist?
+ return unless repo_caskroom.directory?
- if Hbc.caskroom.parent.writable?
- FileUtils.mv repo_caskroom, Hbc.caskroom
- else
- opoo "#{Hbc.caskroom.parent} is not writable, sudo is needed to move the Caskroom."
- system "/usr/bin/sudo", "--", "/bin/mv", "--", repo_caskroom.to_s, Hbc.caskroom.parent.to_s
- end
+ ohai "Moving Caskroom from HOMEBREW_REPOSITORY to HOMEBREW_PREFIX"
+
+ if Hbc.caskroom.parent.writable?
+ FileUtils.mv repo_caskroom, Hbc.caskroom
+ else
+ opoo "#{Hbc.caskroom.parent} is not writable, sudo is needed to move the Caskroom."
+ system "/usr/bin/sudo", "--", "/bin/mv", "--", repo_caskroom.to_s, Hbc.caskroom.parent.to_s
end
end
def ensure_caskroom_exists
- unless Hbc.caskroom.exist?
- ohai "Creating Caskroom at #{Hbc.caskroom}"
+ return if Hbc.caskroom.exist?
- if Hbc.caskroom.parent.writable?
- Hbc.caskroom.mkpath
- else
- ohai "We'll set permissions properly so we won't need sudo in the future"
- toplevel_dir = Hbc.caskroom
- toplevel_dir = toplevel_dir.parent until toplevel_dir.parent.root?
- unless toplevel_dir.directory?
- # If a toplevel dir such as '/opt' must be created, enforce standard permissions.
- # sudo in system is rude.
- system "/usr/bin/sudo", "--", "/bin/mkdir", "--", toplevel_dir
- system "/usr/bin/sudo", "--", "/bin/chmod", "--", "0775", toplevel_dir
- end
+ ohai "Creating Caskroom at #{Hbc.caskroom}"
+ if Hbc.caskroom.parent.writable?
+ Hbc.caskroom.mkpath
+ else
+ ohai "We'll set permissions properly so we won't need sudo in the future"
+ toplevel_dir = Hbc.caskroom
+ toplevel_dir = toplevel_dir.parent until toplevel_dir.parent.root?
+ unless toplevel_dir.directory?
+ # If a toplevel dir such as '/opt' must be created, enforce standard permissions.
# sudo in system is rude.
- system "/usr/bin/sudo", "--", "/bin/mkdir", "-p", "--", Hbc.caskroom
- unless Hbc.caskroom.parent == toplevel_dir
- system "/usr/bin/sudo", "--", "/usr/sbin/chown", "-R", "--", "#{Hbc::Utils.current_user}:staff", Hbc.caskroom.parent.to_s
- end
+ system "/usr/bin/sudo", "--", "/bin/mkdir", "--", toplevel_dir
+ system "/usr/bin/sudo", "--", "/bin/chmod", "--", "0775", toplevel_dir
+ end
+ # sudo in system is rude.
+ system "/usr/bin/sudo", "--", "/bin/mkdir", "-p", "--", Hbc.caskroom
+ unless Hbc.caskroom.parent == toplevel_dir
+ system "/usr/bin/sudo", "--", "/usr/sbin/chown", "-R", "--", "#{Hbc::Utils.current_user}:staff", Hbc.caskroom.parent.to_s
end
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/cli.rb b/Library/Homebrew/cask/lib/hbc/cli.rb
index 1378176da..7b3b886b9 100644
--- a/Library/Homebrew/cask/lib/hbc/cli.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli.rb
@@ -117,11 +117,11 @@ class Hbc::CLI
rescue NameError
nil
end
+
if klass.respond_to?(:run)
# invoke "run" on a Ruby library which follows our coding conventions
- klass.run(*rest)
- else
# other Ruby libraries must do everything via "require"
+ klass.run(*rest)
end
elsif Hbc::Utils.which "brewcask-#{command}"
# arbitrary external executable on PATH, Homebrew-style
diff --git a/Library/Homebrew/cask/lib/hbc/cli/audit.rb b/Library/Homebrew/cask/lib/hbc/cli/audit.rb
index 289547b44..14f3d8254 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/audit.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/audit.rb
@@ -6,7 +6,7 @@ class Hbc::CLI::Audit < Hbc::CLI::Base
def self.run(*args)
failed_casks = new(args, Hbc::Auditor).run
return if failed_casks.empty?
- raise Hbc::CaskError, "audit failed for casks: #{failed_casks.join(' ')}"
+ raise Hbc::CaskError, "audit failed for casks: #{failed_casks.join(" ")}"
end
def initialize(args, auditor)
diff --git a/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb b/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb
index 4115d26fc..39a90e702 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/cleanup.rb
@@ -65,7 +65,7 @@ class Hbc::CLI::Cleanup < Hbc::CLI::Base
def remove_cache_files(*tokens)
message = "Removing cached downloads"
- message.concat " for #{tokens.join(', ')}" unless tokens.empty?
+ message.concat " for #{tokens.join(", ")}" unless tokens.empty?
message.concat " older than #{OUTDATED_DAYS} days old" if outdated_only
ohai message
diff --git a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb
index 2632bcaef..7cfccd8b9 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/doctor.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/doctor.rb
@@ -54,7 +54,7 @@ class Hbc::CLI::Doctor < Hbc::CLI::Base
if homebrew_origin !~ %r{\S}
homebrew_origin = "#{none_string} #{error_string}"
elsif homebrew_origin !~ %r{(mxcl|Homebrew)/(home)?brew(\.git)?\Z}
- homebrew_origin.concat " #{error_string 'warning: nonstandard origin'}"
+ homebrew_origin.concat " #{error_string "warning: nonstandard origin"}"
end
rescue StandardError
homebrew_origin = error_string "Not Found - Error running git"
@@ -106,7 +106,7 @@ class Hbc::CLI::Doctor < Hbc::CLI::Base
end
def self.privileged_uid
- Process.euid == 0 ? "Yes #{error_string 'warning: not recommended'}" : "No"
+ Process.euid.zero? ? "Yes #{error_string "warning: not recommended"}" : "No"
rescue StandardError
notfound_string
end
@@ -143,7 +143,7 @@ class Hbc::CLI::Doctor < Hbc::CLI::Base
if dir.nil? || dir.to_s.empty?
none_string
elsif dir.to_s.match(legacy_tap_pattern)
- dir.to_s.concat(" #{error_string 'Warning: legacy tap path'}")
+ dir.to_s.concat(" #{error_string "Warning: legacy tap path"}")
else
dir.to_s
end
@@ -175,9 +175,9 @@ class Hbc::CLI::Doctor < Hbc::CLI::Base
def self.render_staging_location(path)
path = Pathname.new(path)
if !path.exist?
- "#{path} #{error_string 'error: path does not exist'}}"
+ "#{path} #{error_string "error: path does not exist"}}"
elsif !path.writable?
- "#{path} #{error_string 'error: not writable by current user'}"
+ "#{path} #{error_string "error: not writable by current user"}"
else
path
end
diff --git a/Library/Homebrew/cask/lib/hbc/cli/install.rb b/Library/Homebrew/cask/lib/hbc/cli/install.rb
index 43eab9f3d..16e3b8121 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/install.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/install.rb
@@ -36,7 +36,7 @@ class Hbc::CLI::Install < Hbc::CLI::Base
count += 1
end
end
- count == 0 ? nil : count == cask_tokens.length
+ count.zero? ? nil : count == cask_tokens.length
end
def self.warn_unavailable_with_suggestion(cask_token, e)
diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_audit_modified_casks.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_audit_modified_casks.rb
index f05dbe803..2cee09eef 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/internal_audit_modified_casks.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/internal_audit_modified_casks.rb
@@ -62,7 +62,7 @@ class Hbc::CLI::InternalAuditModifiedCasks < Hbc::CLI::InternalUseBase
end
def git_root
- @git_root ||= git(*%w[rev-parse --show-toplevel])
+ @git_root ||= git("rev-parse", "--show-toplevel")
end
def modified_cask_files
@@ -83,8 +83,8 @@ class Hbc::CLI::InternalAuditModifiedCasks < Hbc::CLI::InternalUseBase
@modified_casks = modified_cask_files.map { |f| Hbc.load(f) }
if @modified_casks.any?
num_modified = @modified_casks.size
- ohai "#{num_modified} modified #{pluralize('cask', num_modified)}: " \
- "#{@modified_casks.join(' ')}"
+ ohai "#{num_modified} modified #{pluralize("cask", num_modified)}: " \
+ "#{@modified_casks.join(" ")}"
end
@modified_casks
end
@@ -122,7 +122,7 @@ class Hbc::CLI::InternalAuditModifiedCasks < Hbc::CLI::InternalUseBase
num_failed = failed_casks.size
cask_pluralized = pluralize("cask", num_failed)
odie "audit failed for #{num_failed} #{cask_pluralized}: " \
- "#{failed_casks.join(' ')}"
+ "#{failed_casks.join(" ")}"
end
def pluralize(str, num)
diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb
index d1cfe8d63..1bccf610d 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb
@@ -21,7 +21,7 @@ class Hbc::CLI::InternalDump < Hbc::CLI::InternalUseBase
opoo "#{cask_token} was not found or would not load: #{e}"
end
end
- count == 0 ? nil : count == cask_tokens.length
+ count.zero? ? nil : count == cask_tokens.length
end
def self.help
diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb
index 651a9ae37..0fb99cc72 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb
@@ -118,7 +118,7 @@ class Hbc::CLI::InternalStanza < Hbc::CLI::InternalUseBase
count += 1
end
- count == 0 ? nil : count == cask_tokens.length
+ count.zero? ? nil : count == cask_tokens.length
end
def self.help
diff --git a/Library/Homebrew/cask/lib/hbc/cli/list.rb b/Library/Homebrew/cask/lib/hbc/cli/list.rb
index 88907a797..8b9c67105 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/list.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/list.rb
@@ -48,7 +48,7 @@ class Hbc::CLI::List < Hbc::CLI::Base
end
end
- count == 0 ? nil : count == cask_tokens.length
+ count.zero? ? nil : count == cask_tokens.length
end
def self.list_artifacts(cask)
diff --git a/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb b/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb
index ae15414b7..2ce9b7d4d 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb
@@ -28,8 +28,8 @@ class Hbc::CLI::Uninstall < Hbc::CLI::Base
single = versions.count == 1
puts <<-EOS.undent
- #{cask_token} #{versions.join(', ')} #{single ? 'is' : 'are'} still installed.
- Remove #{single ? 'it' : 'them all'} with `brew cask uninstall --force #{cask_token}`.
+ #{cask_token} #{versions.join(", ")} #{single ? "is" : "are"} still installed.
+ Remove #{single ? "it" : "them all"} with `brew cask uninstall --force #{cask_token}`.
EOS
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/dsl.rb b/Library/Homebrew/cask/lib/hbc/dsl.rb
index f39012542..b947741ea 100644
--- a/Library/Homebrew/cask/lib/hbc/dsl.rb
+++ b/Library/Homebrew/cask/lib/hbc/dsl.rb
@@ -269,8 +269,16 @@ class Hbc::DSL
end
def method_missing(method, *)
- Hbc::Utils.method_missing_message(method, token)
- nil
+ if method
+ Hbc::Utils.method_missing_message(method, token)
+ nil
+ else
+ super
+ end
+ end
+
+ def respond_to_missing?(*)
+ true
end
def appdir
diff --git a/Library/Homebrew/cask/lib/hbc/dsl/base.rb b/Library/Homebrew/cask/lib/hbc/dsl/base.rb
index 4bf62014e..f47f3aab7 100644
--- a/Library/Homebrew/cask/lib/hbc/dsl/base.rb
+++ b/Library/Homebrew/cask/lib/hbc/dsl/base.rb
@@ -13,9 +13,17 @@ class Hbc::DSL::Base
end
def method_missing(method, *)
- underscored_class = self.class.name.gsub(%r{([[:lower:]])([[:upper:]][[:lower:]])}, '\1_\2').downcase
- section = underscored_class.downcase.split("::").last
- Hbc::Utils.method_missing_message(method, @cask.to_s, section)
- nil
+ if method
+ underscored_class = self.class.name.gsub(%r{([[:lower:]])([[:upper:]][[:lower:]])}, '\1_\2').downcase
+ section = underscored_class.downcase.split("::").last
+ Hbc::Utils.method_missing_message(method, @cask.to_s, section)
+ nil
+ else
+ super
+ end
+ end
+
+ def respond_to_missing?(*)
+ true
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/dsl/stanza_proxy.rb b/Library/Homebrew/cask/lib/hbc/dsl/stanza_proxy.rb
index 02c76fb27..218178faa 100644
--- a/Library/Homebrew/cask/lib/hbc/dsl/stanza_proxy.rb
+++ b/Library/Homebrew/cask/lib/hbc/dsl/stanza_proxy.rb
@@ -25,13 +25,21 @@ class Hbc::DSL::StanzaProxy
coder["resolved"] = @resolver.call
end
- def respond_to?(symbol, include_private = false)
- return true if %i{encode_with proxy? to_s type}.include?(symbol)
- return false if symbol == :to_ary
- @resolver.call.respond_to?(symbol, include_private)
+ def method_missing(method, *args)
+ if method != :to_ary
+ @resolver.call.send(method, *args)
+ else
+ super
+ end
end
- def method_missing(symbol, *args)
- @resolver.call.send(symbol, *args)
+ def respond_to?(method, include_private = false)
+ return true if %i{encode_with proxy? to_s type}.include?(method)
+ return false if method == :to_ary
+ @resolver.call.respond_to?(method, include_private)
+ end
+
+ def respond_to_missing?(*)
+ true
end
end
diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb
index 72a9b3077..fad79644e 100644
--- a/Library/Homebrew/cask/lib/hbc/installer.rb
+++ b/Library/Homebrew/cask/lib/hbc/installer.rb
@@ -139,15 +139,15 @@ class Hbc::Installer
# dependencies should also apply for "brew cask stage"
# override dependencies with --force or perhaps --force-deps
def satisfy_dependencies
- if @cask.depends_on
- ohai "Satisfying dependencies"
- macos_dependencies
- arch_dependencies
- x11_dependencies
- formula_dependencies
- cask_dependencies unless skip_cask_deps
- puts "complete"
- end
+ return unless @cask.depends_on
+
+ ohai "Satisfying dependencies"
+ macos_dependencies
+ arch_dependencies
+ x11_dependencies
+ formula_dependencies
+ cask_dependencies unless skip_cask_deps
+ puts "complete"
end
def macos_dependencies
@@ -159,7 +159,7 @@ class Hbc::Installer
end
elsif @cask.depends_on.macos.length > 1
unless @cask.depends_on.macos.include?(Gem::Version.new(MacOS.version.to_s))
- raise Hbc::CaskError, "Cask #{@cask} depends on macOS release being one of [#{@cask.depends_on.macos.map(&:to_s).join(', ')}], but you are running release #{MacOS.version}."
+ raise Hbc::CaskError, "Cask #{@cask} depends on macOS release being one of [#{@cask.depends_on.macos.map(&:to_s).join(", ")}], but you are running release #{MacOS.version}."
end
else
unless MacOS.version == @cask.depends_on.macos.first
@@ -175,7 +175,7 @@ class Hbc::Installer
arch[:type] == @current_arch[:type] &&
Array(arch[:bits]).include?(@current_arch[:bits])
}
- raise Hbc::CaskError, "Cask #{@cask} depends on hardware architecture being one of [#{@cask.depends_on.arch.map(&:to_s).join(', ')}], but you are running #{@current_arch}"
+ raise Hbc::CaskError, "Cask #{@cask} depends on hardware architecture being one of [#{@cask.depends_on.arch.map(&:to_s).join(", ")}], but you are running #{@current_arch}"
end
def x11_dependencies
@@ -203,7 +203,7 @@ class Hbc::Installer
def cask_dependencies
return unless @cask.depends_on.cask && !@cask.depends_on.cask.empty?
- ohai "Installing Cask dependencies: #{@cask.depends_on.cask.join(', ')}"
+ ohai "Installing Cask dependencies: #{@cask.depends_on.cask.join(", ")}"
deps = Hbc::CaskDependencies.new(@cask)
deps.sorted.each do |dep_token|
puts "#{dep_token} ..."
diff --git a/Library/Homebrew/cask/lib/hbc/source/tapped_qualified.rb b/Library/Homebrew/cask/lib/hbc/source/tapped_qualified.rb
index 1da013db2..97a35defe 100644
--- a/Library/Homebrew/cask/lib/hbc/source/tapped_qualified.rb
+++ b/Library/Homebrew/cask/lib/hbc/source/tapped_qualified.rb
@@ -11,7 +11,7 @@ class Hbc::Source::TappedQualified < Hbc::Source::Tapped
qualified_token = Hbc::QualifiedToken.parse(query)
return if qualified_token.nil?
- user, repo, token = qualified_token
+ user, repo = qualified_token[0..1]
Tap.fetch(user, repo)
end
diff --git a/Library/Homebrew/cask/lib/hbc/system_command.rb b/Library/Homebrew/cask/lib/hbc/system_command.rb
index bb8d91504..9ffe9da38 100644
--- a/Library/Homebrew/cask/lib/hbc/system_command.rb
+++ b/Library/Homebrew/cask/lib/hbc/system_command.rb
@@ -123,7 +123,7 @@ class Hbc::SystemCommand::Result
end
def success?
- @exit_status == 0
+ @exit_status.zero?
end
def merged_output
diff --git a/Library/Homebrew/cask/lib/hbc/url_checker.rb b/Library/Homebrew/cask/lib/hbc/url_checker.rb
index 8737903df..327306b2b 100644
--- a/Library/Homebrew/cask/lib/hbc/url_checker.rb
+++ b/Library/Homebrew/cask/lib/hbc/url_checker.rb
@@ -36,7 +36,7 @@ class Hbc::UrlChecker
def _check_response_status
ok = OK_RESPONSES[cask.url.scheme]
return if ok.include?(@response_status)
- add_error "unexpected http response, expecting #{ok.map(&:utf8_inspect).join(' or ')}, got #{@response_status.utf8_inspect}"
+ add_error "unexpected http response, expecting #{ok.map(&:utf8_inspect).join(" or ")}, got #{@response_status.utf8_inspect}"
end
def _get_data_from_request
diff --git a/Library/Homebrew/cask/lib/hbc/utils.rb b/Library/Homebrew/cask/lib/hbc/utils.rb
index 599127523..1b80f6ae2 100644
--- a/Library/Homebrew/cask/lib/hbc/utils.rb
+++ b/Library/Homebrew/cask/lib/hbc/utils.rb
@@ -32,14 +32,15 @@ end
# global methods
def odebug(title, *sput)
- if Hbc.respond_to?(:debug) && Hbc.debug
- width = Tty.width * 4 - 6
- if $stdout.tty? && title.to_s.length > width
- title = title.to_s[0, width - 3] + "..."
- end
- puts "#{Tty.magenta}==>#{Tty.reset} #{Tty.white}#{title}#{Tty.reset}"
- puts sput unless sput.empty?
+ return unless Hbc.respond_to?(:debug)
+ return unless Hbc.debug
+
+ width = Tty.width * 4 - 6
+ if $stdout.tty? && title.to_s.length > width
+ title = title.to_s[0, width - 3] + "..."
end
+ puts "#{Tty.magenta}==>#{Tty.reset} #{Tty.white}#{title}#{Tty.reset}"
+ puts sput unless sput.empty?
end
module Hbc::Utils
diff --git a/Library/Homebrew/cask/spec/cask/cli/cleanup_spec.rb b/Library/Homebrew/cask/spec/cask/cli/cleanup_spec.rb
index ab2cd55cc..fe8bb2d4d 100644
--- a/Library/Homebrew/cask/spec/cask/cli/cleanup_spec.rb
+++ b/Library/Homebrew/cask/spec/cask/cli/cleanup_spec.rb
@@ -12,7 +12,7 @@ describe Hbc::CLI::Cleanup do
describe "cleanup" do
it "removes cached downloads of given casks" do
- cleaned_up_cached_download = 'caffeine'
+ cleaned_up_cached_download = "caffeine"
cached_downloads = [
cache_location.join("#{cleaned_up_cached_download}--latest.zip"),
diff --git a/Library/Homebrew/cask/spec/spec_helper.rb b/Library/Homebrew/cask/spec/spec_helper.rb
index bfd4407e0..5a26884ac 100644
--- a/Library/Homebrew/cask/spec/spec_helper.rb
+++ b/Library/Homebrew/cask/spec/spec_helper.rb
@@ -9,7 +9,7 @@ end
project_root = Pathname.new(File.expand_path("../..", __FILE__))
# add Homebrew to load path
-$LOAD_PATH.unshift(File.expand_path("#{ENV['HOMEBREW_REPOSITORY']}/Library/Homebrew"))
+$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew"))
require "global"
diff --git a/Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb b/Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb
index afa4a61aa..47408ab9f 100644
--- a/Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb
+++ b/Library/Homebrew/cask/test/cask/artifact/two_apps_correct_test.rb
@@ -60,7 +60,6 @@ describe Hbc::Artifact::App do
File.exist?(cask.staged_path.join("Caffeine Deluxe.app")).must_equal true
end
-
describe "avoids clobbering an existing app" do
let(:cask) { local_two_apps_caffeine }
@@ -70,8 +69,8 @@ describe Hbc::Artifact::App do
TestHelper.must_output(self, lambda {
Hbc::Artifact::App.new(cask).install_phase
}, <<-EOS.undent.chomp)
- ==> It seems there is already an App at '#{Hbc.appdir.join('Caffeine Mini.app')}'; not moving.
- ==> Moving App 'Caffeine Pro.app' to '#{Hbc.appdir.join('Caffeine Pro.app')}'
+ ==> It seems there is already an App at '#{Hbc.appdir.join("Caffeine Mini.app")}'; not moving.
+ ==> Moving App 'Caffeine Pro.app' to '#{Hbc.appdir.join("Caffeine Pro.app")}'
EOS
source_path = cask.staged_path.join("Caffeine Mini.app")
@@ -85,8 +84,8 @@ describe Hbc::Artifact::App do
TestHelper.must_output(self, lambda {
Hbc::Artifact::App.new(cask).install_phase
}, <<-EOS.undent.chomp)
- ==> Moving App 'Caffeine Mini.app' to '#{Hbc.appdir.join('Caffeine Mini.app')}'
- ==> It seems there is already an App at '#{Hbc.appdir.join('Caffeine Pro.app')}'; not moving.
+ ==> Moving App 'Caffeine Mini.app' to '#{Hbc.appdir.join("Caffeine Mini.app")}'
+ ==> It seems there is already an App at '#{Hbc.appdir.join("Caffeine Pro.app")}'; not moving.
EOS
source_path = cask.staged_path.join("Caffeine Pro.app")
diff --git a/Library/Homebrew/cask/test/cask/cli/list_test.rb b/Library/Homebrew/cask/test/cask/cli/list_test.rb
index 2189498d4..6831bf0a4 100644
--- a/Library/Homebrew/cask/test/cask/cli/list_test.rb
+++ b/Library/Homebrew/cask/test/cask/cli/list_test.rb
@@ -79,9 +79,9 @@ describe Hbc::CLI::List do
Hbc::CLI::List.run("local-transmission", "local-caffeine")
}.must_output <<-EOS.undent
==> Apps
- #{Hbc.appdir.join('Transmission.app')} (#{Hbc.appdir.join('Transmission.app').abv})
+ #{Hbc.appdir.join("Transmission.app")} (#{Hbc.appdir.join("Transmission.app").abv})
==> Apps
- Missing App: #{Hbc.appdir.join('Caffeine.app')}
+ Missing App: #{Hbc.appdir.join("Caffeine.app")}
EOS
end
end
diff --git a/Library/Homebrew/cask/test/test_helper.rb b/Library/Homebrew/cask/test/test_helper.rb
index 3599b43be..4d795bffe 100644
--- a/Library/Homebrew/cask/test/test_helper.rb
+++ b/Library/Homebrew/cask/test/test_helper.rb
@@ -10,7 +10,7 @@ project_root = Pathname.new(File.expand_path("../..", __FILE__))
tap_root = Pathname.new(ENV["HOMEBREW_LIBRARY"]).join("Taps", "caskroom", "homebrew-cask")
# add Homebrew to load path
-$LOAD_PATH.unshift(File.expand_path("#{ENV['HOMEBREW_REPOSITORY']}/Library/Homebrew"))
+$LOAD_PATH.unshift(File.expand_path("#{ENV["HOMEBREW_REPOSITORY"]}/Library/Homebrew"))
require "global"
diff --git a/Library/Homebrew/caveats.rb b/Library/Homebrew/caveats.rb
index 9c1787f87..a5568cb29 100644
--- a/Library/Homebrew/caveats.rb
+++ b/Library/Homebrew/caveats.rb
@@ -69,27 +69,34 @@ class Caveats
end
def bash_completion_caveats
- if keg && keg.completion_installed?(:bash) then <<-EOS.undent
+ return unless keg
+ return unless keg.completion_installed?(:bash)
+
+ <<-EOS.undent
Bash completion has been installed to:
#{HOMEBREW_PREFIX}/etc/bash_completion.d
- EOS
- end
+ EOS
end
def zsh_completion_caveats
- if keg && keg.completion_installed?(:zsh) then <<-EOS.undent
+ return unless keg
+ return unless keg.completion_installed?(:zsh)
+
+ <<-EOS.undent
zsh completion has been installed to:
#{HOMEBREW_PREFIX}/share/zsh/site-functions
- EOS
- end
+ EOS
end
def fish_completion_caveats
- if keg && keg.completion_installed?(:fish) && which("fish") then <<-EOS.undent
+ return unless keg
+ return unless keg.completion_installed?(:fish)
+ return unless which("fish")
+
+ <<-EOS.undent
fish completion has been installed to:
#{HOMEBREW_PREFIX}/share/fish/vendor_completions.d
- EOS
- end
+ EOS
end
def python_caveats
@@ -140,22 +147,24 @@ class Caveats
end
def app_caveats
- if keg && keg.app_installed?
- <<-EOS.undent
- .app bundles were installed.
- Run `brew linkapps #{keg.name}` to symlink these to /Applications.
- EOS
- end
+ return unless keg
+ return unless keg.app_installed?
+
+ <<-EOS.undent
+ .app bundles were installed.
+ Run `brew linkapps #{keg.name}` to symlink these to /Applications.
+ EOS
end
def elisp_caveats
return if f.keg_only?
- if keg && keg.elisp_installed?
- <<-EOS.undent
- Emacs Lisp files have been installed to:
- #{HOMEBREW_PREFIX}/share/emacs/site-lisp/#{f.name}
- EOS
- end
+ return unless keg
+ return unless keg.elisp_installed?
+
+ <<-EOS.undent
+ Emacs Lisp files have been installed to:
+ #{HOMEBREW_PREFIX}/share/emacs/site-lisp/#{f.name}
+ EOS
end
def plist_caveats
diff --git a/Library/Homebrew/cleaner.rb b/Library/Homebrew/cleaner.rb
index d8a998576..7456e18d6 100644
--- a/Library/Homebrew/cleaner.rb
+++ b/Library/Homebrew/cleaner.rb
@@ -87,9 +87,9 @@ class Cleaner
Find.prune if @f.skip_clean? path
- if path.symlink? || path.directory?
- next
- elsif path.extname == ".la"
+ next if path.symlink? || path.directory?
+
+ if path.extname == ".la"
path.unlink
elsif path.basename.to_s == "perllocal.pod"
# Both this file & the .packlist one below are completely unnecessary
diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb
index 265f06d26..04a976e55 100644
--- a/Library/Homebrew/cleanup.rb
+++ b/Library/Homebrew/cleanup.rb
@@ -12,7 +12,7 @@ module Homebrew
cleanup_logs
unless ARGV.dry_run?
cleanup_lockfiles
- rm_DS_Store
+ rm_ds_store
end
end
@@ -66,7 +66,7 @@ module Homebrew
next unless path.file?
file = path
- if Pathname::BOTTLE_EXTNAME_RX === file.to_s
+ if file.to_s =~ Pathname::BOTTLE_EXTNAME_RX
version = begin
Utils::Bottles.resolve_version(file)
rescue
@@ -86,7 +86,7 @@ module Homebrew
next
end
- file_is_stale = if PkgVersion === version
+ file_is_stale = if version.is_a?(PkgVersion)
f.pkg_version > version
else
f.version > version
@@ -119,7 +119,7 @@ module Homebrew
end
end
- def self.rm_DS_Store
+ def self.rm_ds_store
paths = Queue.new
%w[Cellar Frameworks Library bin etc include lib opt sbin share var]
.map { |p| HOMEBREW_PREFIX/p }.each { |p| paths << p if p.exist? }
diff --git a/Library/Homebrew/cmd/cleanup.rb b/Library/Homebrew/cmd/cleanup.rb
index a9d3fbcde..6e0915c9a 100644
--- a/Library/Homebrew/cmd/cleanup.rb
+++ b/Library/Homebrew/cmd/cleanup.rb
@@ -22,13 +22,13 @@ module Homebrew
ARGV.resolved_formulae.each { |f| Cleanup.cleanup_formula f }
end
- if Cleanup.disk_cleanup_size > 0
- disk_space = disk_usage_readable(Cleanup.disk_cleanup_size)
- if ARGV.dry_run?
- ohai "This operation would free approximately #{disk_space} of disk space."
- else
- ohai "This operation has freed approximately #{disk_space} of disk space."
- end
+ return if Cleanup.disk_cleanup_size.zero?
+
+ disk_space = disk_usage_readable(Cleanup.disk_cleanup_size)
+ if ARGV.dry_run?
+ ohai "This operation would free approximately #{disk_space} of disk space."
+ else
+ ohai "This operation has freed approximately #{disk_space} of disk space."
end
end
end
diff --git a/Library/Homebrew/cmd/diy.rb b/Library/Homebrew/cmd/diy.rb
index 8262352f8..95ec7fe35 100644
--- a/Library/Homebrew/cmd/diy.rb
+++ b/Library/Homebrew/cmd/diy.rb
@@ -31,11 +31,9 @@ module Homebrew
def detect_version(path)
version = path.version.to_s
- if version.empty?
- raise "Couldn't determine version, set it with --version=<version>"
- else
- version
- end
+ raise "Couldn't determine version, set it with --version=<version>" if version.empty?
+
+ version
end
def detect_name(path, version)
diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb
index 2474aad57..09c832203 100644
--- a/Library/Homebrew/cmd/info.rb
+++ b/Library/Homebrew/cmd/info.rb
@@ -54,11 +54,8 @@ module Homebrew
end
rescue FormulaUnavailableError
# No formula with this name, try a blacklist lookup
- if (blacklist = blacklisted?(f))
- puts blacklist
- else
- raise
- end
+ raise unless (blacklist = blacklisted?(f))
+ puts blacklist
end
end
end
diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb
index 50439ccf9..0a6dd5a46 100644
--- a/Library/Homebrew/cmd/install.rb
+++ b/Library/Homebrew/cmd/install.rb
@@ -245,11 +245,11 @@ module Homebrew
end
def check_macports
- unless MacOS.macports_or_fink.empty?
- opoo "It appears you have MacPorts or Fink installed."
- puts "Software installed with other package managers causes known problems for"
- puts "Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again."
- end
+ return if MacOS.macports_or_fink.empty?
+
+ opoo "It appears you have MacPorts or Fink installed."
+ puts "Software installed with other package managers causes known problems for"
+ puts "Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again."
end
def check_cellar
diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb
index e51aace2a..bda6022bf 100644
--- a/Library/Homebrew/cmd/reinstall.rb
+++ b/Library/Homebrew/cmd/reinstall.rb
@@ -58,10 +58,11 @@ module Homebrew
def restore_backup(keg, formula)
path = backup_path(keg)
- if path.directory?
- path.rename keg
- keg.link unless formula.keg_only?
- end
+
+ return unless path.directory?
+
+ path.rename keg
+ keg.link unless formula.keg_only?
end
def backup_path(path)
diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb
index 50d9f5f74..aa80ec589 100644
--- a/Library/Homebrew/cmd/search.rb
+++ b/Library/Homebrew/cmd/search.rb
@@ -150,7 +150,7 @@ module Homebrew
names = remote_tap_formulae["#{user}/#{repo}"]
user = user.downcase if user == "Homebrew" # special handling for the Homebrew organization
- names.select { |name| rx === name }.map { |name| "#{user}/#{repo}/#{name}" }
+ names.select { |name| name =~ rx }.map { |name| "#{user}/#{repo}/#{name}" }
rescue GitHub::HTTPNotFoundError
opoo "Failed to search tap: #{user}/#{repo}. Please run `brew update`"
[]
@@ -171,10 +171,11 @@ module Homebrew
rescue
canonical_name = canonical_full_name = name
end
+
# Ignore aliases from results when the full name was also found
- if aliases.include?(name) && results.include?(canonical_full_name)
- next
- elsif (HOMEBREW_CELLAR/canonical_name).directory?
+ next if aliases.include?(name) && results.include?(canonical_full_name)
+
+ if (HOMEBREW_CELLAR/canonical_name).directory?
pretty_installed(name)
else
name
diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb
index f28d50cc1..db61116be 100644
--- a/Library/Homebrew/cmd/style.rb
+++ b/Library/Homebrew/cmd/style.rb
@@ -45,7 +45,7 @@ module Homebrew
def check_style_impl(files, output_type, options = {})
fix = options[:fix]
- Homebrew.install_gem_setup_path! "rubocop", "0.41.2"
+ Homebrew.install_gem_setup_path! "rubocop", "0.43.0"
args = %W[
--force-exclusion
@@ -54,20 +54,22 @@ module Homebrew
args << "--auto-correct" if fix
args += files
- case output_type
- when :print
- args << "--display-cop-names" if ARGV.include? "--display-cop-names"
- system "rubocop", "--format", "simple", *args
- !$?.success?
- when :json
- json = Utils.popen_read_text("rubocop", "--format", "json", *args)
- # exit status of 1 just means violations were found; other numbers mean execution errors
- # exitstatus can also be nil if RuboCop process crashes, e.g. due to
- # native extension problems
- raise "Error while running RuboCop" if $?.exitstatus.nil? || $?.exitstatus > 1
- RubocopResults.new(Utils::JSON.load(json))
- else
- raise "Invalid output_type for check_style_impl: #{output_type}"
+ HOMEBREW_LIBRARY.cd do
+ case output_type
+ when :print
+ args << "--display-cop-names" if ARGV.include? "--display-cop-names"
+ system "rubocop", "--format", "simple", *args
+ !$?.success?
+ when :json
+ json = Utils.popen_read_text("rubocop", "--format", "json", *args)
+ # exit status of 1 just means violations were found; other numbers mean execution errors
+ # exitstatus can also be nil if RuboCop process crashes, e.g. due to
+ # native extension problems
+ raise "Error while running RuboCop" if $?.exitstatus.nil? || $?.exitstatus > 1
+ RubocopResults.new(Utils::JSON.load(json))
+ else
+ raise "Invalid output_type for check_style_impl: #{output_type}"
+ end
end
end
diff --git a/Library/Homebrew/cxxstdlib.rb b/Library/Homebrew/cxxstdlib.rb
index 1f629a8b2..ad859badd 100644
--- a/Library/Homebrew/cxxstdlib.rb
+++ b/Library/Homebrew/cxxstdlib.rb
@@ -16,7 +16,7 @@ class CxxStdlib
if type && ![:libstdcxx, :libcxx].include?(type)
raise ArgumentError, "Invalid C++ stdlib type: #{type}"
end
- klass = GNU_GCC_REGEXP === compiler.to_s ? GnuStdlib : AppleStdlib
+ klass = compiler.to_s =~ GNU_GCC_REGEXP ? GnuStdlib : AppleStdlib
klass.new(type, compiler)
end
diff --git a/Library/Homebrew/debrew.rb b/Library/Homebrew/debrew.rb
index 48d449f4a..8e371e4e7 100644
--- a/Library/Homebrew/debrew.rb
+++ b/Library/Homebrew/debrew.rb
@@ -118,20 +118,22 @@ module Debrew
menu.prompt = "Choose an action: "
menu.choice(:raise) { original_raise(e) }
- menu.choice(:ignore) { return :ignore } if Ignorable === e
+ menu.choice(:ignore) { return :ignore } if e.is_a?(Ignorable)
menu.choice(:backtrace) { puts e.backtrace }
- menu.choice(:irb) do
- puts "When you exit this IRB session, execution will continue."
- set_trace_func proc { |event, _, _, id, binding, klass|
- if klass == Raise && id == :raise && event == "return"
- set_trace_func(nil)
- synchronize { IRB.start_within(binding) }
- end
- }
-
- return :ignore
- end if Ignorable === e
+ if e.is_a?(Ignorable)
+ menu.choice(:irb) do
+ puts "When you exit this IRB session, execution will continue."
+ set_trace_func proc { |event, _, _, id, binding, klass|
+ if klass == Raise && id == :raise && event == "return"
+ set_trace_func(nil)
+ synchronize { IRB.start_within(binding) }
+ end
+ }
+
+ return :ignore
+ end
+ end
menu.choice(:shell) do
puts "When you exit this shell, you will return to the menu."
diff --git a/Library/Homebrew/dependencies.rb b/Library/Homebrew/dependencies.rb
index b55d35c2e..51e552102 100644
--- a/Library/Homebrew/dependencies.rb
+++ b/Library/Homebrew/dependencies.rb
@@ -69,7 +69,7 @@ class Requirements
end
def <<(other)
- if Comparable === other
+ if other.is_a?(Comparable)
@reqs.grep(other.class) do |req|
return self if req > other
@reqs.delete(req)
diff --git a/Library/Homebrew/dependency_collector.rb b/Library/Homebrew/dependency_collector.rb
index ef3a712e9..0b35e7fb4 100644
--- a/Library/Homebrew/dependency_collector.rb
+++ b/Library/Homebrew/dependency_collector.rb
@@ -49,7 +49,7 @@ class DependencyCollector
end
def cache_key(spec)
- if Resource === spec && spec.download_strategy == CurlDownloadStrategy
+ if spec.is_a?(Resource) && spec.download_strategy == CurlDownloadStrategy
File.extname(spec.url)
else
spec
@@ -57,7 +57,7 @@ class DependencyCollector
end
def build(spec)
- spec, tags = Hash === spec ? spec.first : spec
+ spec, tags = spec.is_a?(Hash) ? spec.first : spec
parse_spec(spec, Array(tags))
end
@@ -81,7 +81,7 @@ class DependencyCollector
end
def parse_string_spec(spec, tags)
- if HOMEBREW_TAP_FORMULA_REGEX === spec
+ if spec =~ HOMEBREW_TAP_FORMULA_REGEX
TapDependency.new(spec, tags)
elsif tags.empty?
Dependency.new(spec, tags)
@@ -165,11 +165,11 @@ class DependencyCollector
def parse_url_spec(url, tags)
case File.extname(url)
- when ".xz" then Dependency.new("xz", tags)
+ when ".xz" then Dependency.new("xz", tags)
when ".lha", ".lzh" then Dependency.new("lha", tags)
- when ".lz" then Dependency.new("lzip", tags)
- when ".rar" then Dependency.new("unrar", tags)
- when ".7z" then Dependency.new("p7zip", tags)
+ when ".lz" then Dependency.new("lzip", tags)
+ when ".rar" then Dependency.new("unrar", tags)
+ when ".7z" then Dependency.new("p7zip", tags)
end
end
end
diff --git a/Library/Homebrew/descriptions.rb b/Library/Homebrew/descriptions.rb
index 5e7a5b06c..0ef4316d3 100644
--- a/Library/Homebrew/descriptions.rb
+++ b/Library/Homebrew/descriptions.rb
@@ -12,9 +12,7 @@ class Descriptions
# If the cache file exists, load it into, and return, a hash; otherwise,
# return nil.
def self.load_cache
- if CACHE_FILE.exist?
- @cache = Utils::JSON.load(CACHE_FILE.read)
- end
+ @cache = Utils::JSON.load(CACHE_FILE.read) if CACHE_FILE.exist?
end
# Write the cache to disk after ensuring the existence of the containing
@@ -138,6 +136,6 @@ class Descriptions
def short_name_counts
@short_name_counts ||=
- short_names.values.each_with_object(Hash.new(0)) { |name, counts| counts[name] += 1; counts }
+ short_names.values.each_with_object(Hash.new(0)) { |name, counts| counts[name] += 1 }
end
end
diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 20e9a8aff..61d136daf 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -83,11 +83,11 @@ module Homebrew
end
end
- unless problem_count.zero?
- problems = "problem" + plural(problem_count)
- formulae = "formula" + plural(formula_count, "e")
- ofail "#{problem_count} #{problems} in #{formula_count} #{formulae}"
- end
+ return if problem_count.zero?
+
+ problems = "problem" + plural(problem_count)
+ formulae = "formula" + plural(formula_count, "e")
+ ofail "#{problem_count} #{problems} in #{formula_count} #{formulae}"
end
end
@@ -279,9 +279,11 @@ class FormulaAuditor
end
end
end
+
if present.include?("head") && present.include?("head block")
problem "Should not have both `head` and `head do`"
end
+
if present.include?("bottle modifier") && present.include?("bottle block")
problem "Should not have `bottle :unneeded/:disable` and `bottle do`"
end
@@ -467,7 +469,7 @@ class FormulaAuditor
# Make sure the formula name plus description is no longer than 80 characters
# Note full_name includes the name of the tap, while name does not
- linelength = formula.name.length + ": ".length + desc.length
+ linelength = "#{formula.name}: #{desc}".length
if linelength > 80
problem <<-EOS.undent
Description is too long. \"name: desc\" should be less than 80 characters.
@@ -668,24 +670,26 @@ class FormulaAuditor
end
revision_map = attributes_map[:revision]
- if formula.revision.nonzero?
- if formula.stable
- if revision_map[formula.stable.version].empty? # check stable spec
- problem "'revision #{formula.revision}' should be removed"
- end
- else # head/devel-only formula
+
+ return if formula.revision.zero?
+
+ if formula.stable
+ if revision_map[formula.stable.version].empty? # check stable spec
problem "'revision #{formula.revision}' should be removed"
end
+ else # head/devel-only formula
+ problem "'revision #{formula.revision}' should be removed"
end
end
def audit_legacy_patches
return unless formula.respond_to?(:patches)
legacy_patches = Patch.normalize_legacy_patches(formula.patches).grep(LegacyPatch)
- unless legacy_patches.empty?
- problem "Use the patch DSL instead of defining a 'patches' method"
- legacy_patches.each { |p| audit_patch(p) }
- end
+
+ return if legacy_patches.empty?
+
+ problem "Use the patch DSL instead of defining a 'patches' method"
+ legacy_patches.each { |p| audit_patch(p) }
end
def audit_patch(patch)
@@ -961,61 +965,56 @@ class FormulaAuditor
problem "Use Language::Node for npm install args"
end
- if @strict
- if line =~ /system ((["'])[^"' ]*(?:\s[^"' ]*)+\2)/
- bad_system = $1
- unless %w[| < > & ; *].any? { |c| bad_system.include? c }
- good_system = bad_system.gsub(" ", "\", \"")
- problem "Use `system #{good_system}` instead of `system #{bad_system}` "
- end
- end
+ return unless @strict
- if line =~ /(require ["']formula["'])/
- problem "`#{$1}` is now unnecessary"
+ if line =~ /system ((["'])[^"' ]*(?:\s[^"' ]*)+\2)/
+ bad_system = $1
+ unless %w[| < > & ; *].any? { |c| bad_system.include? c }
+ good_system = bad_system.gsub(" ", "\", \"")
+ problem "Use `system #{good_system}` instead of `system #{bad_system}` "
end
+ end
- if line =~ %r{#\{share\}/#{Regexp.escape(formula.name)}[/'"]}
- problem "Use \#{pkgshare} instead of \#{share}/#{formula.name}"
- end
+ if line =~ /(require ["']formula["'])/
+ problem "`#{$1}` is now unnecessary"
+ end
- if line =~ %r{share(\s*[/+]\s*)(['"])#{Regexp.escape(formula.name)}(?:\2|/)}
- problem "Use pkgshare instead of (share#{$1}\"#{formula.name}\")"
- end
+ if line =~ %r{#\{share\}/#{Regexp.escape(formula.name)}[/'"]}
+ problem "Use \#{pkgshare} instead of \#{share}/#{formula.name}"
+ end
+
+ if line =~ %r{share(\s*[/+]\s*)(['"])#{Regexp.escape(formula.name)}(?:\2|/)}
+ problem "Use pkgshare instead of (share#{$1}\"#{formula.name}\")"
end
end
def audit_caveats
- caveats = formula.caveats.to_s
-
- if caveats.include?("setuid")
- problem "Don't recommend setuid in the caveats, suggest sudo instead."
- end
+ return unless formula.caveats.to_s.include?("setuid")
+ problem "Don't recommend setuid in the caveats, suggest sudo instead."
end
def audit_reverse_migration
# Only enforce for new formula being re-added to core and official taps
return unless @strict
return unless formula.tap && formula.tap.official?
+ return unless formula.tap.tap_migrations.key?(formula.name)
- if formula.tap.tap_migrations.key?(formula.name)
- problem <<-EOS.undent
- #{formula.name} seems to be listed in tap_migrations.json!
- Please remove #{formula.name} from present tap & tap_migrations.json
- before submitting it to Homebrew/homebrew-#{formula.tap.repo}.
- EOS
- end
+ problem <<-EOS.undent
+ #{formula.name} seems to be listed in tap_migrations.json!
+ Please remove #{formula.name} from present tap & tap_migrations.json
+ before submitting it to Homebrew/homebrew-#{formula.tap.repo}.
+ EOS
end
def audit_prefix_has_contents
return unless formula.prefix.directory?
+ return unless Keg.new(formula.prefix).empty_installation?
- if Keg.new(formula.prefix).empty_installation?
- problem <<-EOS.undent
- The installation seems to be empty. Please ensure the prefix
- is set correctly and expected files are installed.
- The prefix configure/make argument may be case-sensitive.
- EOS
- end
+ problem <<-EOS.undent
+ The installation seems to be empty. Please ensure the prefix
+ is set correctly and expected files are installed.
+ The prefix configure/make argument may be case-sensitive.
+ EOS
end
def audit_conditional_dep(dep, condition, line)
@@ -1184,9 +1183,7 @@ class ResourceAuditor
end
end
- using_strategy = DownloadStrategyDetector.detect("", using)
-
- if url_strategy == using_strategy
+ if url_strategy == DownloadStrategyDetector.detect("", using)
problem "Redundant :using value in URL"
end
end
diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb
index f4d6a463a..b2aa3b2c5 100644
--- a/Library/Homebrew/dev-cmd/bottle.rb
+++ b/Library/Homebrew/dev-cmd/bottle.rb
@@ -51,10 +51,11 @@ module Homebrew
end
@put_filenames ||= []
- unless @put_filenames.include? filename
- puts "#{Tty.red}#{filename}#{Tty.reset}"
- @put_filenames << filename
- end
+
+ return if @put_filenames.include? filename
+
+ puts "#{Tty.red}#{filename}#{Tty.reset}"
+ @put_filenames << filename
end
result = false
@@ -107,9 +108,7 @@ module Homebrew
absolute_symlinks_start_with_string = []
keg.find do |pn|
next unless pn.symlink? && (link = pn.readlink).absolute?
- if link.to_s.start_with?(string)
- absolute_symlinks_start_with_string << pn
- end
+ absolute_symlinks_start_with_string << pn if link.to_s.start_with?(string)
end
if ARGV.verbose?
@@ -137,11 +136,11 @@ module Homebrew
tap = f.tap
unless tap
- if ARGV.include?("--force-core-tap")
- tap = CoreTap.instance
- else
+ unless ARGV.include?("--force-core-tap")
return ofail "Formula not from core or any taps: #{f.full_name}"
end
+
+ tap = CoreTap.instance
end
if f.bottle_disabled?
@@ -154,9 +153,7 @@ module Homebrew
return ofail "Formula not installed with '--build-bottle': #{f.full_name}"
end
- unless f.stable
- return ofail "Formula has no stable version: #{f.full_name}"
- end
+ return ofail "Formula has no stable version: #{f.full_name}" unless f.stable
if ARGV.include?("--no-rebuild") || !f.tap
rebuild = 0
@@ -323,34 +320,33 @@ module Homebrew
puts "./#{filename}"
puts output
- if ARGV.include? "--json"
- json = {
- f.full_name => {
- "formula" => {
- "pkg_version" => f.pkg_version.to_s,
- "path" => f.path.to_s.strip_prefix("#{HOMEBREW_REPOSITORY}/"),
- },
- "bottle" => {
- "root_url" => bottle.root_url,
- "prefix" => bottle.prefix,
- "cellar" => bottle.cellar.to_s,
- "rebuild" => bottle.rebuild,
- "tags" => {
- Utils::Bottles.tag.to_s => {
- "filename" => filename.to_s,
- "sha256" => sha256,
- },
+ return unless ARGV.include? "--json"
+ json = {
+ f.full_name => {
+ "formula" => {
+ "pkg_version" => f.pkg_version.to_s,
+ "path" => f.path.to_s.strip_prefix("#{HOMEBREW_REPOSITORY}/"),
+ },
+ "bottle" => {
+ "root_url" => bottle.root_url,
+ "prefix" => bottle.prefix,
+ "cellar" => bottle.cellar.to_s,
+ "rebuild" => bottle.rebuild,
+ "tags" => {
+ Utils::Bottles.tag.to_s => {
+ "filename" => filename.to_s,
+ "sha256" => sha256,
},
},
- "bintray" => {
- "package" => Utils::Bottles::Bintray.package(f.name),
- "repository" => Utils::Bottles::Bintray.repository(tap),
- },
},
- }
- File.open("#{filename.prefix}.bottle.json", "w") do |file|
- file.write Utils::JSON.dump json
- end
+ "bintray" => {
+ "package" => Utils::Bottles::Bintray.package(f.name),
+ "repository" => Utils::Bottles::Bintray.repository(tap),
+ },
+ },
+ }
+ File.open("#{filename.prefix}.bottle.json", "w") do |file|
+ file.write Utils::JSON.dump json
end
end
@@ -436,7 +432,7 @@ module Homebrew
puts output
update_or_add = "add"
if s.include? "stable do"
- indent = s.slice(/^ +stable do/).length - "stable do".length
+ indent = s.slice(/^( +)stable do/, 1).length
string = s.sub!(/^ {#{indent}}stable do(.|\n)+?^ {#{indent}}end\n/m, '\0' + output + "\n")
else
string = s.sub!(
diff --git a/Library/Homebrew/dev-cmd/edit.rb b/Library/Homebrew/dev-cmd/edit.rb
index f80d05861..2d2a5ec08 100644
--- a/Library/Homebrew/dev-cmd/edit.rb
+++ b/Library/Homebrew/dev-cmd/edit.rb
@@ -33,9 +33,9 @@ module Homebrew
# Don't use ARGV.formulae as that will throw if the file doesn't parse
paths = ARGV.named.map do |name|
path = Formulary.path(name)
- unless path.file? || ARGV.force?
- raise FormulaUnavailableError, name
- end
+
+ raise FormulaUnavailableError, name unless path.file? || ARGV.force?
+
path
end
exec_editor(*paths)
diff --git a/Library/Homebrew/dev-cmd/mirror.rb b/Library/Homebrew/dev-cmd/mirror.rb
index 162008123..9966163f8 100644
--- a/Library/Homebrew/dev-cmd/mirror.rb
+++ b/Library/Homebrew/dev-cmd/mirror.rb
@@ -4,9 +4,7 @@
module Homebrew
def mirror
- if ARGV.named.empty?
- odie "This command requires at least formula argument!"
- end
+ odie "This command requires at least formula argument!" if ARGV.named.empty?
bintray_user = ENV["BINTRAY_USER"]
bintray_key = ENV["BINTRAY_KEY"]
diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb
index 7f027e159..b06719fb1 100644
--- a/Library/Homebrew/dev-cmd/pull.rb
+++ b/Library/Homebrew/dev-cmd/pull.rb
@@ -41,12 +41,12 @@ require "pkg_version"
module Homebrew
def pull
- if ARGV[0] == "--rebase"
- odie "You meant `git pull --rebase`."
- end
+ odie "You meant `git pull --rebase`." if ARGV[0] == "--rebase"
+
if ARGV.named.empty?
odie "This command requires at least one argument containing a URL or pull request number"
end
+
do_bump = ARGV.include?("--bump") && !ARGV.include?("--clean")
# Formulae with affected bottles that were published
@@ -429,9 +429,9 @@ module Homebrew
# Returns nil if formula is absent or if there was an error reading it
def self.lookup(name)
json = Utils.popen_read(HOMEBREW_BREW_FILE, "info", "--json=v1", name)
- unless $?.success?
- return nil
- end
+
+ return nil unless $?.success?
+
Homebrew.force_utf8!(json)
FormulaInfoFromJson.new(Utils::JSON.load(json)[0])
end
diff --git a/Library/Homebrew/dev-cmd/test-bot.rb b/Library/Homebrew/dev-cmd/test-bot.rb
index 7a5853c48..ba78cdb59 100644
--- a/Library/Homebrew/dev-cmd/test-bot.rb
+++ b/Library/Homebrew/dev-cmd/test-bot.rb
@@ -185,8 +185,8 @@ module Homebrew
def puts_result
if ENV["TRAVIS"]
- travis_start_time = @start_time.to_i*1000000000
- travis_end_time = @end_time.to_i*1000000000
+ travis_start_time = @start_time.to_i * 1_000_000_000
+ travis_end_time = @end_time.to_i * 1_000_000_000
travis_duration = travis_end_time - travis_start_time
puts "#{Tty.white}==>#{Tty.green} PASSED#{Tty.reset}" if passed?
puts "travis_time:end:#{@travis_timer_id},start=#{travis_start_time},finish=#{travis_end_time},duration=#{travis_duration}"
@@ -563,11 +563,10 @@ module Homebrew
(installed & dependencies).each do |installed_dependency|
installed_dependency_formula = Formulary.factory(installed_dependency)
- if installed_dependency_formula.installed? &&
- !installed_dependency_formula.keg_only? &&
- !installed_dependency_formula.linked_keg.exist?
- test "brew", "link", installed_dependency
- end
+ next unless installed_dependency_formula.installed?
+ next if installed_dependency_formula.keg_only?
+ next if installed_dependency_formula.linked_keg.exist?
+ test "brew", "link", installed_dependency
end
dependencies -= installed
@@ -725,9 +724,7 @@ module Homebrew
coverage_args = []
if ARGV.include?("--coverage")
if ENV["JENKINS_HOME"]
- if OS.mac? && MacOS.version == :sierra
- coverage_args << "--coverage"
- end
+ coverage_args << "--coverage" if OS.mac? && MacOS.version == :sierra
else
coverage_args << "--coverage"
end
@@ -742,9 +739,7 @@ module Homebrew
test "brew", "cask-tests", *coverage_args
end
elsif @tap
- if @tap.name == "homebrew/core"
- test "brew", "style", @tap.name
- end
+ test "brew", "style", @tap.name if @tap.name == "homebrew/core"
test "brew", "readall", "--aliases", @tap.name
end
end
@@ -1055,9 +1050,7 @@ module Homebrew
ARGV << "--junit" << "--local" << "--test-default-formula"
end
- if ARGV.include? "--ci-master"
- ARGV << "--fast"
- end
+ ARGV << "--fast" if ARGV.include?("--ci-master")
if ARGV.include? "--local"
ENV["HOMEBREW_CACHE"] = "#{ENV["HOME"]}/Library/Caches/Homebrew"
@@ -1081,9 +1074,7 @@ module Homebrew
safe_system "brew", "tap", tap.name, "--full"
end
- if ARGV.include? "--ci-upload"
- return test_ci_upload(tap)
- end
+ return test_ci_upload(tap) if ARGV.include?("--ci-upload")
tests = []
any_errors = false
diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb
index 650ff3eab..743c653d2 100644
--- a/Library/Homebrew/diagnostic.rb
+++ b/Library/Homebrew/diagnostic.rb
@@ -39,15 +39,11 @@ module Homebrew
vols = get_mounts path
# no volume found
- if vols.empty?
- return -1
- end
+ return -1 if vols.empty?
vol_index = @volumes.index(vols[0])
# volume not found in volume list
- if vol_index.nil?
- return -1
- end
+ return -1 if vol_index.nil?
vol_index
end
@@ -82,8 +78,8 @@ module Homebrew
end
end
- def inject_file_list(list, str)
- list.inject(str) { |s, f| s << " #{f}\n" }
+ def inject_file_list(list, string)
+ list.inject(string) { |a, e| a << " #{e}\n" }
end
############# END HELPERS
@@ -599,7 +595,7 @@ module Homebrew
EOS
end
- def check_DYLD_vars
+ def check_dyld_vars
dyld_vars = ENV.keys.grep(/^DYLD_/)
return if dyld_vars.empty?
@@ -758,7 +754,7 @@ module Homebrew
cd #{HOMEBREW_REPOSITORY}
git remote add origin https://github.com/Homebrew/brew.git
EOS
- elsif origin !~ /Homebrew\/brew(\.git)?$/
+ elsif origin !~ %r{Homebrew/brew(\.git)?$}
<<-EOS.undent
Suspicious git origin remote found.
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index cabb22c22..d19d131a7 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -663,19 +663,19 @@ class GitDownloadStrategy < VCSDownloadStrategy
@shallow && support_depth?
end
- def is_shallow_clone?
+ def shallow_dir?
git_dir.join("shallow").exist?
end
def support_depth?
- @ref_type != :revision && SHALLOW_CLONE_WHITELIST.any? { |rx| rx === @url }
+ @ref_type != :revision && SHALLOW_CLONE_WHITELIST.any? { |regex| @url =~ regex }
end
def git_dir
cached_location.join(".git")
end
- def has_ref?
+ def ref?
quiet_system "git", "--git-dir", git_dir, "rev-parse", "-q", "--verify", "#{@ref}^{commit}"
end
@@ -696,7 +696,8 @@ class GitDownloadStrategy < VCSDownloadStrategy
args << "--depth" << "1" if shallow_clone?
case @ref_type
- when :branch, :tag then args << "--branch" << @ref
+ when :branch, :tag
+ args << "--branch" << @ref
end
args << @url << cached_location
@@ -716,8 +717,8 @@ class GitDownloadStrategy < VCSDownloadStrategy
end
def update_repo
- if @ref_type == :branch || !has_ref?
- if !shallow_clone? && is_shallow_clone?
+ if @ref_type == :branch || !ref?
+ if !shallow_clone? && shallow_dir?
quiet_safe_system "git", "fetch", "origin", "--unshallow"
else
quiet_safe_system "git", "fetch", "origin"
@@ -741,9 +742,11 @@ class GitDownloadStrategy < VCSDownloadStrategy
def reset_args
ref = case @ref_type
- when :branch then "origin/#{@ref}"
- when :revision, :tag then @ref
- end
+ when :branch
+ "origin/#{@ref}"
+ when :revision, :tag
+ @ref
+ end
%W[reset --hard #{ref}]
end
@@ -1021,9 +1024,9 @@ class DownloadStrategyDetector
def self.detect(url, strategy = nil)
if strategy.nil?
detect_from_url(url)
- elsif Class === strategy && strategy < AbstractDownloadStrategy
+ elsif strategy.is_a?(Class) && strategy < AbstractDownloadStrategy
strategy
- elsif Symbol === strategy
+ elsif strategy.is_a?(Symbol)
detect_from_symbol(strategy)
else
raise TypeError,
diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb
index d9f599877..92b4cb898 100644
--- a/Library/Homebrew/extend/ARGV.rb
+++ b/Library/Homebrew/extend/ARGV.rb
@@ -216,7 +216,7 @@ module HomebrewArgvExtension
end
def build_all_from_source?
- !!ENV["HOMEBREW_BUILD_FROM_SOURCE"]
+ !ENV["HOMEBREW_BUILD_FROM_SOURCE"].nil?
end
# Whether a given formula should be built from source during the current
diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb
index a9b2358b1..c1111b840 100644
--- a/Library/Homebrew/extend/ENV/std.rb
+++ b/Library/Homebrew/extend/ENV/std.rb
@@ -192,15 +192,11 @@ module Stdenv
end
def libcxx
- if compiler == :clang
- append "CXX", "-stdlib=libc++"
- end
+ append "CXX", "-stdlib=libc++" if compiler == :clang
end
def libstdcxx
- if compiler == :clang
- append "CXX", "-stdlib=libstdc++"
- end
+ append "CXX", "-stdlib=libstdc++" if compiler == :clang
end
# @private
diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb
index 4169905df..39ff4b8f8 100644
--- a/Library/Homebrew/extend/ENV/super.rb
+++ b/Library/Homebrew/extend/ENV/super.rb
@@ -64,9 +64,7 @@ module Superenv
self["HOMEBREW_INCLUDE_PATHS"] = determine_include_paths
self["HOMEBREW_LIBRARY_PATHS"] = determine_library_paths
self["HOMEBREW_DEPENDENCIES"] = determine_dependencies
- unless formula.nil?
- self["HOMEBREW_FORMULA_PREFIX"] = formula.prefix
- end
+ self["HOMEBREW_FORMULA_PREFIX"] = formula.prefix unless formula.nil?
# The HOMEBREW_CCCFG ENV variable is used by the ENV/cc tool to control
# compiler flag stripping. It consists of a string of characters which act
diff --git a/Library/Homebrew/extend/os/blacklist.rb b/Library/Homebrew/extend/os/blacklist.rb
index f72c7c643..932040f82 100644
--- a/Library/Homebrew/extend/os/blacklist.rb
+++ b/Library/Homebrew/extend/os/blacklist.rb
@@ -1,5 +1,2 @@
require "blacklist"
-
-if OS.mac?
- require "extend/os/mac/blacklist"
-end
+require "extend/os/mac/blacklist" if OS.mac?
diff --git a/Library/Homebrew/extend/os/bottles.rb b/Library/Homebrew/extend/os/bottles.rb
index aff9300de..146b807a4 100644
--- a/Library/Homebrew/extend/os/bottles.rb
+++ b/Library/Homebrew/extend/os/bottles.rb
@@ -1,5 +1,2 @@
require "utils/bottles"
-
-if OS.mac?
- require "extend/os/mac/utils/bottles"
-end
+require "extend/os/mac/utils/bottles" if OS.mac?
diff --git a/Library/Homebrew/extend/os/cleaner.rb b/Library/Homebrew/extend/os/cleaner.rb
index 868ff2d33..6b94cdf5a 100644
--- a/Library/Homebrew/extend/os/cleaner.rb
+++ b/Library/Homebrew/extend/os/cleaner.rb
@@ -1,5 +1,2 @@
require "cleaner"
-
-if OS.mac?
- require "extend/os/mac/cleaner"
-end
+require "extend/os/mac/cleaner" if OS.mac?
diff --git a/Library/Homebrew/extend/os/dependency_collector.rb b/Library/Homebrew/extend/os/dependency_collector.rb
index d295263f6..56fcad31d 100644
--- a/Library/Homebrew/extend/os/dependency_collector.rb
+++ b/Library/Homebrew/extend/os/dependency_collector.rb
@@ -1,5 +1,2 @@
require "dependency_collector"
-
-if OS.mac?
- require "extend/os/mac/dependency_collector"
-end
+require "extend/os/mac/dependency_collector" if OS.mac?
diff --git a/Library/Homebrew/extend/os/development_tools.rb b/Library/Homebrew/extend/os/development_tools.rb
index 7b590dc8b..5bd5cb81a 100644
--- a/Library/Homebrew/extend/os/development_tools.rb
+++ b/Library/Homebrew/extend/os/development_tools.rb
@@ -1,5 +1,2 @@
require "development_tools"
-
-if OS.mac?
- require "extend/os/mac/development_tools"
-end
+require "extend/os/mac/development_tools" if OS.mac?
diff --git a/Library/Homebrew/extend/os/diagnostic.rb b/Library/Homebrew/extend/os/diagnostic.rb
index 0c844743b..f8f53b1f4 100644
--- a/Library/Homebrew/extend/os/diagnostic.rb
+++ b/Library/Homebrew/extend/os/diagnostic.rb
@@ -1,5 +1,2 @@
require "diagnostic"
-
-if OS.mac?
- require "extend/os/mac/diagnostic"
-end
+require "extend/os/mac/diagnostic" if OS.mac?
diff --git a/Library/Homebrew/extend/os/emoji.rb b/Library/Homebrew/extend/os/emoji.rb
index fe3e7f44e..8fd99e1d3 100644
--- a/Library/Homebrew/extend/os/emoji.rb
+++ b/Library/Homebrew/extend/os/emoji.rb
@@ -1,6 +1,3 @@
require "os"
require "emoji"
-
-if OS.mac?
- require "extend/os/mac/emoji"
-end
+require "extend/os/mac/emoji" if OS.mac?
diff --git a/Library/Homebrew/extend/os/extend/ENV/shared.rb b/Library/Homebrew/extend/os/extend/ENV/shared.rb
index 676159b37..e9574eb58 100644
--- a/Library/Homebrew/extend/os/extend/ENV/shared.rb
+++ b/Library/Homebrew/extend/os/extend/ENV/shared.rb
@@ -1,5 +1,2 @@
require "extend/ENV/shared"
-
-if OS.mac?
- require "extend/os/mac/extend/ENV/shared"
-end
+require "extend/os/mac/extend/ENV/shared" if OS.mac?
diff --git a/Library/Homebrew/extend/os/extend/ENV/std.rb b/Library/Homebrew/extend/os/extend/ENV/std.rb
index 320f9981f..8e6b13a61 100644
--- a/Library/Homebrew/extend/os/extend/ENV/std.rb
+++ b/Library/Homebrew/extend/os/extend/ENV/std.rb
@@ -1,5 +1,2 @@
require "extend/ENV/std"
-
-if OS.mac?
- require "extend/os/mac/extend/ENV/std"
-end
+require "extend/os/mac/extend/ENV/std" if OS.mac?
diff --git a/Library/Homebrew/extend/os/extend/ENV/super.rb b/Library/Homebrew/extend/os/extend/ENV/super.rb
index fd4e93c22..27c49eb84 100644
--- a/Library/Homebrew/extend/os/extend/ENV/super.rb
+++ b/Library/Homebrew/extend/os/extend/ENV/super.rb
@@ -1,5 +1,2 @@
require "extend/ENV/super"
-
-if OS.mac?
- require "extend/os/mac/extend/ENV/super"
-end
+require "extend/os/mac/extend/ENV/super" if OS.mac?
diff --git a/Library/Homebrew/extend/os/formula_cellar_checks.rb b/Library/Homebrew/extend/os/formula_cellar_checks.rb
index 4e30cd791..66b5b80d3 100644
--- a/Library/Homebrew/extend/os/formula_cellar_checks.rb
+++ b/Library/Homebrew/extend/os/formula_cellar_checks.rb
@@ -1,5 +1,2 @@
require "formula_cellar_checks"
-
-if OS.mac?
- require "extend/os/mac/formula_cellar_checks"
-end
+require "extend/os/mac/formula_cellar_checks" if OS.mac?
diff --git a/Library/Homebrew/extend/os/keg_relocate.rb b/Library/Homebrew/extend/os/keg_relocate.rb
index 2fde45d93..25a74286a 100644
--- a/Library/Homebrew/extend/os/keg_relocate.rb
+++ b/Library/Homebrew/extend/os/keg_relocate.rb
@@ -1,5 +1,2 @@
require "keg_relocate"
-
-if OS.mac?
- require "extend/os/mac/keg_relocate"
-end
+require "extend/os/mac/keg_relocate" if OS.mac?
diff --git a/Library/Homebrew/extend/os/mac/extend/ENV/shared.rb b/Library/Homebrew/extend/os/mac/extend/ENV/shared.rb
index 866204024..67a3944c3 100644
--- a/Library/Homebrew/extend/os/mac/extend/ENV/shared.rb
+++ b/Library/Homebrew/extend/os/mac/extend/ENV/shared.rb
@@ -2,13 +2,8 @@ module SharedEnvExtension
def no_weak_imports_support?
return false unless compiler == :clang
- if MacOS::Xcode.version && MacOS::Xcode.version < "8.0"
- return false
- end
-
- if MacOS::CLT.version && MacOS::CLT.version < "8.0"
- return false
- end
+ return false if MacOS::Xcode.version && MacOS::Xcode.version < "8.0"
+ return false if MacOS::CLT.version && MacOS::CLT.version < "8.0"
true
end
diff --git a/Library/Homebrew/extend/os/system_config.rb b/Library/Homebrew/extend/os/system_config.rb
index cf7b69cb6..edc007166 100644
--- a/Library/Homebrew/extend/os/system_config.rb
+++ b/Library/Homebrew/extend/os/system_config.rb
@@ -1,5 +1,2 @@
require "system_config"
-
-if OS.mac?
- require "extend/os/mac/system_config"
-end
+require "extend/os/mac/system_config" if OS.mac?
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index 5dce906b9..68029dc38 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -71,13 +71,13 @@ class Pathname
when Array
if src.empty?
opoo "tried to install empty array to #{self}"
- return
+ break
end
src.each { |s| install_p(s, File.basename(s)) }
when Hash
if src.empty?
opoo "tried to install empty hash to #{self}"
- return
+ break
end
src.each { |s, new_basename| install_p(s, new_basename) }
else
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 4b3ef33f2..7a5584cdf 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -395,9 +395,7 @@ class Formula
def oldname
@oldname ||= if tap
formula_renames = tap.formula_renames
- if formula_renames.value?(name)
- formula_renames.to_a.rassoc(name).first
- end
+ formula_renames.to_a.rassoc(name).first if formula_renames.value?(name)
end
end
@@ -1052,7 +1050,7 @@ class Formula
self.class.link_overwrite_paths.any? do |p|
p == to_check ||
to_check.start_with?(p.chomp("/") + "/") ||
- /^#{Regexp.escape(p).gsub('\*', ".*?")}$/ === to_check
+ to_check =~ /^#{Regexp.escape(p).gsub('\*', ".*?")}$/
end
end
@@ -1246,7 +1244,7 @@ class Formula
# @private
def <=>(other)
- return unless Formula === other
+ return unless other.is_a?(Formula)
name <=> other.name
end
@@ -1776,9 +1774,7 @@ class Formula
ENV["HOMEBREW_CC_LOG_PATH"] = logfn
# TODO: system "xcodebuild" is deprecated, this should be removed soon.
- if cmd.to_s.start_with? "xcodebuild"
- ENV.remove_cc_etc
- end
+ ENV.remove_cc_etc if cmd.to_s.start_with? "xcodebuild"
# Turn on argument filtering in the superenv compiler wrapper.
# We should probably have a better mechanism for this than adding
@@ -1786,9 +1782,7 @@ class Formula
if cmd == "python"
setup_py_in_args = %w[setup.py build.py].include?(args.first)
setuptools_shim_in_args = args.any? { |a| a.to_s.start_with? "import setuptools" }
- if setup_py_in_args || setuptools_shim_in_args
- ENV.refurbish_args
- end
+ ENV.refurbish_args if setup_py_in_args || setuptools_shim_in_args
end
$stdout.reopen(out)
@@ -2226,7 +2220,7 @@ class Formula
# If this formula conflicts with another one.
# <pre>conflicts_with "imagemagick", :because => "because this is just a stupid example"</pre>
def conflicts_with(*names)
- opts = Hash === names.last ? names.pop : {}
+ opts = names.last.is_a?(Hash) ? names.pop : {}
names.each { |name| conflicts << FormulaConflict.new(name, opts[:because]) }
end
diff --git a/Library/Homebrew/formula_cellar_checks.rb b/Library/Homebrew/formula_cellar_checks.rb
index 3805d0f45..89757dfb2 100644
--- a/Library/Homebrew/formula_cellar_checks.rb
+++ b/Library/Homebrew/formula_cellar_checks.rb
@@ -1,7 +1,7 @@
require "utils/shell"
module FormulaCellarChecks
- def check_PATH(bin)
+ def check_env_path(bin)
# warn the user if stuff was installed outside of their PATH
return unless bin.directory?
return if bin.children.empty?
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb
index f64b77026..6e8f2e3b7 100644
--- a/Library/Homebrew/formula_installer.rb
+++ b/Library/Homebrew/formula_installer.rb
@@ -24,7 +24,9 @@ class FormulaInstaller
private(*names)
names.each do |name|
predicate = "#{name}?"
- define_method(predicate) { !!send(name) }
+ define_method(predicate) do
+ send(name) ? true : false
+ end
private(predicate)
end
end
@@ -71,7 +73,8 @@ class FormulaInstaller
end
def build_bottle?
- !!@build_bottle && !formula.bottle_disabled?
+ return false unless @build_bottle
+ !formula.bottle_disabled?
end
def pour_bottle?(install_bottle_options = { warn: false })
@@ -254,9 +257,7 @@ class FormulaInstaller
unless @poured_bottle
not_pouring = !pour_bottle || @pour_failed
- if not_pouring && !ignore_deps?
- compute_and_install_dependencies
- end
+ compute_and_install_dependencies if not_pouring && !ignore_deps?
build
clean
end
@@ -543,7 +544,7 @@ class FormulaInstaller
@build_time ||= Time.now - @start_time if @start_time && !interactive?
end
- def sanitized_ARGV_options
+ def sanitized_argv_options
args = []
args << "--ignore-dependencies" if ignore_deps?
@@ -582,7 +583,7 @@ class FormulaInstaller
end
def build_argv
- sanitized_ARGV_options + options.as_flags
+ sanitized_argv_options + options.as_flags
end
def build
@@ -810,8 +811,8 @@ class FormulaInstaller
end
def audit_installed
- audit_check_output(check_PATH(formula.bin))
- audit_check_output(check_PATH(formula.sbin))
+ audit_check_output(check_env_path(formula.bin))
+ audit_check_output(check_env_path(formula.sbin))
super
end
diff --git a/Library/Homebrew/formula_lock.rb b/Library/Homebrew/formula_lock.rb
index 1ce62b328..8743eaef8 100644
--- a/Library/Homebrew/formula_lock.rb
+++ b/Library/Homebrew/formula_lock.rb
@@ -35,9 +35,8 @@ class FormulaLock
if @lockfile.nil? || @lockfile.closed?
@lockfile = @path.open(File::RDWR | File::CREAT)
@lockfile.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
- @lockfile
- else
- @lockfile
end
+
+ @lockfile
end
end
diff --git a/Library/Homebrew/formula_versions.rb b/Library/Homebrew/formula_versions.rb
index ec2e2a459..81e15d314 100644
--- a/Library/Homebrew/formula_versions.rb
+++ b/Library/Homebrew/formula_versions.rb
@@ -52,9 +52,7 @@ class FormulaVersions
rev_list(branch) do |rev|
formula_at_revision(rev) do |f|
bottle = f.bottle_specification
- unless bottle.checksums.empty?
- map[f.pkg_version] << bottle.rebuild
- end
+ map[f.pkg_version] << bottle.rebuild unless bottle.checksums.empty?
end
end
map
diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb
index 74f669413..a6ec45d3c 100644
--- a/Library/Homebrew/formulary.rb
+++ b/Library/Homebrew/formulary.rb
@@ -301,9 +301,7 @@ class Formulary
return TapLoader.new(ref)
end
- if File.extname(ref) == ".rb"
- return FromPathLoader.new(ref)
- end
+ return FromPathLoader.new(ref) if File.extname(ref) == ".rb"
formula_with_that_name = core_path(ref)
if formula_with_that_name.file?
@@ -311,9 +309,7 @@ class Formulary
end
possible_alias = CoreTap.instance.alias_dir/ref
- if possible_alias.file?
- return AliasLoader.new(possible_alias)
- end
+ return AliasLoader.new(possible_alias) if possible_alias.file?
possible_tap_formulae = tap_paths(ref)
if possible_tap_formulae.size > 1
diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb
index ecbc4c6e0..65ce6480a 100644
--- a/Library/Homebrew/keg.rb
+++ b/Library/Homebrew/keg.rb
@@ -62,12 +62,17 @@ class Keg
end
# locale-specific directories have the form language[_territory][.codeset][@modifier]
- LOCALEDIR_RX = /(locale|man)\/([a-z]{2}|C|POSIX)(_[A-Z]{2})?(\.[a-zA-Z\-0-9]+(@.+)?)?/
+ LOCALEDIR_RX = %r{(locale|man)/([a-z]{2}|C|POSIX)(_[A-Z]{2})?(\.[a-zA-Z\-0-9]+(@.+)?)?}
INFOFILE_RX = %r{info/([^.].*?\.info|dir)$}
TOP_LEVEL_DIRECTORIES = %w[bin etc include lib sbin share var Frameworks].freeze
ALL_TOP_LEVEL_DIRECTORIES = (TOP_LEVEL_DIRECTORIES + %w[lib/pkgconfig share/locale share/man opt]).freeze
- PRUNEABLE_DIRECTORIES = %w[bin etc include lib sbin share Frameworks LinkedKegs var/homebrew/linked].map do |d|
- case d when "LinkedKegs" then HOMEBREW_LIBRARY/d else HOMEBREW_PREFIX/d end
+ PRUNEABLE_DIRECTORIES = %w[bin etc include lib sbin share Frameworks LinkedKegs var/homebrew/linked].map do |dir|
+ case dir
+ when "LinkedKegs"
+ HOMEBREW_LIBRARY/dir
+ else
+ HOMEBREW_PREFIX/dir
+ end
end
# These paths relative to the keg's share directory should always be real
@@ -249,10 +254,10 @@ class Keg
def completion_installed?(shell)
dir = case shell
- when :bash then path.join("etc", "bash_completion.d")
- when :zsh then path.join("share", "zsh", "site-functions")
- when :fish then path.join("share", "fish", "vendor_completions.d")
- end
+ when :bash then path.join("etc", "bash_completion.d")
+ when :zsh then path.join("share", "zsh", "site-functions")
+ when :fish then path.join("share", "fish", "vendor_completions.d")
+ end
dir && dir.directory? && !dir.children.empty?
end
@@ -318,13 +323,13 @@ class Keg
when "locale/locale.alias" then :skip_file
when INFOFILE_RX then :info
when LOCALEDIR_RX then :mkpath
- when /^icons\/.*\/icon-theme\.cache$/ then :skip_file
+ when %r{^icons/.*/icon-theme\.cache$} then :skip_file
# all icons subfolders should also mkpath
- when /^icons\// then :mkpath
+ when %r{^icons/} then :mkpath
when /^zsh/ then :mkpath
when /^fish/ then :mkpath
# Lua, Lua51, Lua53 all need the same handling.
- when /^lua\// then :mkpath
+ when %r{^lua/} then :mkpath
when %r{^guile/} then :mkpath
when *SHARE_PATHS then :mkpath
else :link
@@ -362,7 +367,7 @@ class Keg
# the :link strategy. However, for Foo.framework and
# Foo.framework/Versions we have to use :mkpath so that multiple formulae
# can link their versions into it and `brew [un]link` works.
- if relative_path.to_s =~ /[^\/]*\.framework(\/Versions)?$/
+ if relative_path.to_s =~ %r{[^/]*\.framework(/Versions)?$}
:mkpath
else
:link
diff --git a/Library/Homebrew/language/haskell.rb b/Library/Homebrew/language/haskell.rb
index b5d0e1220..4b7f88a99 100644
--- a/Library/Homebrew/language/haskell.rb
+++ b/Library/Homebrew/language/haskell.rb
@@ -79,19 +79,16 @@ module Language
# if we have build flags, we have to pass them to cabal install to resolve the necessary
# dependencies, and call cabal configure afterwards to set the flags again for compile
- flags = ""
- if options[:flags]
- flags = "--flags=#{options[:flags].join(" ")}"
- end
+ flags = "--flags=#{options[:flags].join(" ")}" if options[:flags]
args_and_flags = args
- args_and_flags << flags unless flags.empty?
+ args_and_flags << flags unless flags.nil?
# install dependencies in the sandbox
cabal_install "--only-dependencies", *args_and_flags
# call configure if build flags are set
- cabal_configure flags unless flags.empty?
+ cabal_configure flags unless flags.nil?
# install the main package in the destination dir
cabal_install "--prefix=#{prefix}", *args
diff --git a/Library/Homebrew/migrator.rb b/Library/Homebrew/migrator.rb
index d31025119..d8c06de1a 100644
--- a/Library/Homebrew/migrator.rb
+++ b/Library/Homebrew/migrator.rb
@@ -337,9 +337,7 @@ class Migrator
end
def backup_oldname_cellar
- unless old_cellar.exist?
- FileUtils.mv(new_cellar, old_cellar)
- end
+ FileUtils.mv(new_cellar, old_cellar) unless old_cellar.exist?
end
def backup_old_tabs
diff --git a/Library/Homebrew/options.rb b/Library/Homebrew/options.rb
index 1d92fbf47..947ce5acd 100644
--- a/Library/Homebrew/options.rb
+++ b/Library/Homebrew/options.rb
@@ -14,7 +14,7 @@ class Option
end
def <=>(other)
- return unless Option === other
+ return unless other.is_a?(Option)
name <=> other.name
end
diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb
index 3aab9bf52..dac8b8f1e 100644
--- a/Library/Homebrew/os/mac/xcode.rb
+++ b/Library/Homebrew/os/mac/xcode.rb
@@ -175,7 +175,7 @@ module OS
# Returns true even if outdated tools are installed, e.g.
# tools from Xcode 4.x on 10.9
def installed?
- !!detect_version
+ !detect_version.nil?
end
def update_instructions
diff --git a/Library/Homebrew/patch.rb b/Library/Homebrew/patch.rb
index 1148389cf..74e58e526 100644
--- a/Library/Homebrew/patch.rb
+++ b/Library/Homebrew/patch.rb
@@ -89,7 +89,7 @@ class DATAPatch < EmbeddedPatch
path.open("rb") do |f|
begin
line = f.gets
- end until line.nil? || /^__END__$/ === line
+ end until line.nil? || line =~ /^__END__$/
data << line while line = f.gets
end
data
diff --git a/Library/Homebrew/pkg_version.rb b/Library/Homebrew/pkg_version.rb
index 4bf701f35..2868508e3 100644
--- a/Library/Homebrew/pkg_version.rb
+++ b/Library/Homebrew/pkg_version.rb
@@ -32,7 +32,7 @@ class PkgVersion
alias_method :to_str, :to_s
def <=>(other)
- return unless PkgVersion === other
+ return unless other.is_a?(PkgVersion)
(version <=> other.version).nonzero? || revision <=> other.revision
end
alias_method :eql?, :==
diff --git a/Library/Homebrew/requirement.rb b/Library/Homebrew/requirement.rb
index 4ea15774d..69cdec17f 100644
--- a/Library/Homebrew/requirement.rb
+++ b/Library/Homebrew/requirement.rb
@@ -56,7 +56,7 @@ class Requirement
def satisfied?
result = self.class.satisfy.yielder { |p| instance_eval(&p) }
@satisfied_result = result
- !!result
+ result ? true : false
end
# Overriding #fatal? is deprecated.
@@ -83,7 +83,7 @@ class Requirement
# PATH.
# This is undocumented magic and it should be removed, but we need to add
# a way to declare path-based requirements that work with superenv first.
- if Pathname === @satisfied_result
+ if @satisfied_result.is_a?(Pathname)
parent = @satisfied_result.parent
unless ENV["PATH"].split(File::PATH_SEPARATOR).include?(parent.to_s)
ENV.append_path("PATH", parent)
@@ -115,7 +115,7 @@ class Requirement
def to_dependency
f = self.class.default_formula
raise "No default formula defined for #{inspect}" if f.nil?
- if HOMEBREW_TAP_FORMULA_REGEX === f
+ if f =~ HOMEBREW_TAP_FORMULA_REGEX
TapDependency.new(f, tags, method(:modify_build_environment), name)
else
Dependency.new(f, tags, method(:modify_build_environment), name)
diff --git a/Library/Homebrew/requirements.rb b/Library/Homebrew/requirements.rb
index 68d21a2b7..274ba5c9b 100644
--- a/Library/Homebrew/requirements.rb
+++ b/Library/Homebrew/requirements.rb
@@ -22,7 +22,7 @@ class XcodeRequirement < Requirement
satisfy(build_env: false) { xcode_installed_version }
def initialize(tags)
- @version = tags.find { |t| tags.delete(t) if /(\d\.)+\d/ === t }
+ @version = tags.find { |tag| tags.delete(tag) if tag =~ /(\d\.)+\d/ }
super
end
@@ -39,11 +39,11 @@ class XcodeRequirement < Requirement
Installing just the Command Line Tools is not sufficient.
EOS
if MacOS.version >= :lion
- message += <<-EOS.undent
+ message + <<-EOS.undent
Xcode can be installed from the App Store.
EOS
else
- message += <<-EOS.undent
+ message + <<-EOS.undent
Xcode can be installed from https://developer.apple.com/xcode/downloads/
EOS
end
diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb
index 986dc5354..25373c322 100644
--- a/Library/Homebrew/software_spec.rb
+++ b/Library/Homebrew/software_spec.rb
@@ -65,11 +65,12 @@ class SoftwareSpec
end
def bottle_unneeded?
- !!@bottle_disable_reason && @bottle_disable_reason.unneeded?
+ return false unless @bottle_disable_reason
+ @bottle_disable_reason.unneeded?
end
def bottle_disabled?
- !!@bottle_disable_reason
+ @bottle_disable_reason ? true : false
end
attr_reader :bottle_disable_reason
@@ -116,12 +117,12 @@ class SoftwareSpec
def option(name, description = "")
opt = PREDEFINED_OPTIONS.fetch(name) do
- if Symbol === name
+ if name.is_a?(Symbol)
opoo "Passing arbitrary symbols to `option` is deprecated: #{name.inspect}"
puts "Symbols are reserved for future use, please pass a string instead"
name = name.to_s
end
- unless String === name
+ unless name.is_a?(String)
raise ArgumentError, "option name must be string or symbol; got a #{name.class}: #{name}"
end
raise ArgumentError, "option name is required" if name.empty?
@@ -318,7 +319,7 @@ class BottleSpecification
end
def tag?(tag)
- !!checksum_for(tag)
+ checksum_for(tag) ? true : false
end
# Checksum methods in the DSL's bottle block optionally take
diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb
index 12b23cc73..379f2e8a4 100644
--- a/Library/Homebrew/tab.rb
+++ b/Library/Homebrew/tab.rb
@@ -328,9 +328,9 @@ class Tab < OpenStruct
else
s << "Built from source"
end
- if time
- s << Time.at(time).strftime("on %Y-%m-%d at %H:%M:%S")
- end
+
+ s << Time.at(time).strftime("on %Y-%m-%d at %H:%M:%S") if time
+
unless used_options.empty?
s << "with:"
s << used_options.to_a.join(" ")
diff --git a/Library/Homebrew/test/test_diagnostic.rb b/Library/Homebrew/test/test_diagnostic.rb
index 5d0f5f386..37f56e961 100644
--- a/Library/Homebrew/test/test_diagnostic.rb
+++ b/Library/Homebrew/test/test_diagnostic.rb
@@ -154,7 +154,7 @@ class DiagnosticChecksTest < Homebrew::TestCase
def test_check_dyld_vars
ENV["DYLD_INSERT_LIBRARIES"] = "foo"
assert_match "Setting DYLD_INSERT_LIBRARIES",
- @checks.check_DYLD_vars
+ @checks.check_dyld_vars
end
def test_check_for_symlinked_cellar
diff --git a/Library/Homebrew/test/test_download_strategies.rb b/Library/Homebrew/test/test_download_strategies.rb
index d107d14e8..87218fb12 100644
--- a/Library/Homebrew/test/test_download_strategies.rb
+++ b/Library/Homebrew/test/test_download_strategies.rb
@@ -118,7 +118,7 @@ class GitDownloadStrategyTests < Homebrew::TestCase
def test_source_modified_time
setup_git_repo
- assert_equal 1242860651, @strategy.source_modified_time.to_i
+ assert_equal 1_242_860_651, @strategy.source_modified_time.to_i
end
def test_last_commit
diff --git a/Library/Homebrew/test/test_pathname.rb b/Library/Homebrew/test/test_pathname.rb
index 0cd2876d0..492c09c67 100644
--- a/Library/Homebrew/test/test_pathname.rb
+++ b/Library/Homebrew/test/test_pathname.rb
@@ -26,7 +26,7 @@ class PathnameTests < Homebrew::TestCase
mkdir_p @dir/"a-directory"
touch @dir/".DS_Store"
touch @dir/"a-file"
- File.truncate(@dir/"a-file", 1048576)
+ File.truncate(@dir/"a-file", 1_048_576)
ln_s @dir/"a-file", @dir/"a-symlink"
ln @dir/"a-file", @dir/"a-hardlink"
assert_equal 3, @dir.file_count
diff --git a/Library/Homebrew/utils/git.rb b/Library/Homebrew/utils/git.rb
index 837cc22e4..dfe47f890 100644
--- a/Library/Homebrew/utils/git.rb
+++ b/Library/Homebrew/utils/git.rb
@@ -22,9 +22,7 @@ module Utils
return if git_available?
# we cannot install brewed git if homebrew/core is unavailable.
- unless CoreTap.instance.installed?
- raise "Git is unavailable"
- end
+ raise "Git is unavailable" unless CoreTap.instance.installed?
begin
oh1 "Installing git"
diff --git a/Library/Homebrew/version.rb b/Library/Homebrew/version.rb
index 520db6626..c0e5324ea 100644
--- a/Library/Homebrew/version.rb
+++ b/Library/Homebrew/version.rb
@@ -208,7 +208,7 @@ class Version
end
def <=>(other)
- return unless Version === other
+ return unless other.is_a?(Version)
return 0 if version == other.version
return 1 if head? && !other.head?
return -1 if !head? && other.head?
@@ -386,7 +386,7 @@ class Version
# e.g. http://mirrors.jenkins-ci.org/war/1.486/jenkins.war
# e.g. https://github.com/foo/bar/releases/download/0.10.11/bar.phar
- m = /\/(\d\.\d+(\.\d+)?)\//.match(spec_s)
+ m = %r{/(\d\.\d+(\.\d+)?)}.match(spec_s)
return m.captures.first unless m.nil?
# e.g. http://www.ijg.org/files/jpegsrc.v8d.tar.gz