From 2a1788484af2f7fc6acbbe03bdd6f36b8bad17a7 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 20 Sep 2016 15:06:04 +0200 Subject: Remove dependency on `rubocop-cask`. --- Library/Homebrew/cask/.rubocop.yml | 60 ++++++++++++++++++++++++++++++++++---- Library/Homebrew/cask/Gemfile | 4 --- Library/Homebrew/cask/Gemfile.lock | 17 ----------- Library/Homebrew/cask/Rakefile | 7 ----- 4 files changed, 54 insertions(+), 34 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/.rubocop.yml b/Library/Homebrew/cask/.rubocop.yml index 31a2a193d..5b026887a 100644 --- a/Library/Homebrew/cask/.rubocop.yml +++ b/Library/Homebrew/cask/.rubocop.yml @@ -1,10 +1,9 @@ -require: 'rubocop-cask' - AllCops: TargetRubyVersion: 2.0 + Include: + - '**/.simplecov' Exclude: - '**/Casks/**/*' - - 'developer/**/*' - '**/vendor/**/*' Metrics/AbcSize: @@ -16,10 +15,10 @@ Metrics/ClassLength: Metrics/CyclomaticComplexity: Enabled: false -Metrics/MethodLength: +Metrics/LineLength: Enabled: false -Metrics/PerceivedComplexity: +Metrics/MethodLength: Enabled: false Metrics/ModuleLength: @@ -29,6 +28,19 @@ Metrics/ModuleLength: - 'lib/hbc/macos.rb' - 'lib/hbc/utils.rb' +Metrics/PerceivedComplexity: + Enabled: false + +Performance/StringReplacement: + Enabled: false + +Style/AlignHash: + EnforcedHashRocketStyle: table + EnforcedColonStyle: table + +Style/BarePercentLiterals: + EnforcedStyle: percent_q + Style/BlockDelimiters: EnforcedStyle: semantic FunctionalMethods: @@ -75,15 +87,51 @@ Style/BlockDelimiters: - lambda - proc - Style/ClassAndModuleChildren: EnforcedStyle: compact +Style/Documentation: + Enabled: false + +Style/EmptyElse: + Enabled: false + +Style/FileName: + Enabled: false + +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/PredicateName: NameWhitelist: is_32_bit?, is_64_bit? Style/RaiseArgs: EnforcedStyle: exploded +Style/RegexpLiteral: + EnforcedStyle: percent_r + Style/StringLiterals: 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" -- cgit v1.2.3 From b957a1b7e6c1305617cff429f16f73f0c8ec604c Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 20 Sep 2016 15:11:20 +0200 Subject: Enable `Style/EmptyElse` cop. --- Library/Homebrew/cask/.rubocop.yml | 3 --- 1 file changed, 3 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/.rubocop.yml b/Library/Homebrew/cask/.rubocop.yml index 5b026887a..2677748ad 100644 --- a/Library/Homebrew/cask/.rubocop.yml +++ b/Library/Homebrew/cask/.rubocop.yml @@ -93,9 +93,6 @@ Style/ClassAndModuleChildren: Style/Documentation: Enabled: false -Style/EmptyElse: - Enabled: false - Style/FileName: Enabled: false -- cgit v1.2.3 From 59212445da7048233ef32705433e548783fcf84b Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 20 Sep 2016 15:11:33 +0200 Subject: Run `rubocop —auto-correct`. --- Library/Homebrew/cask/.rubocop.yml | 7 ++- .../cask/lib/hbc/artifact/abstract_flight_block.rb | 2 +- Library/Homebrew/cask/lib/hbc/artifact/moved.rb | 6 +-- Library/Homebrew/cask/lib/hbc/cache.rb | 30 ++++++------- Library/Homebrew/cask/lib/hbc/cask.rb | 45 ++++++++++--------- Library/Homebrew/cask/lib/hbc/caskroom.rb | 52 +++++++++++----------- Library/Homebrew/cask/lib/hbc/cli.rb | 4 +- Library/Homebrew/cask/lib/hbc/cli/audit.rb | 2 +- Library/Homebrew/cask/lib/hbc/cli/cleanup.rb | 2 +- Library/Homebrew/cask/lib/hbc/cli/doctor.rb | 10 ++--- Library/Homebrew/cask/lib/hbc/cli/install.rb | 2 +- .../lib/hbc/cli/internal_audit_modified_casks.rb | 8 ++-- Library/Homebrew/cask/lib/hbc/cli/internal_dump.rb | 2 +- .../Homebrew/cask/lib/hbc/cli/internal_stanza.rb | 2 +- Library/Homebrew/cask/lib/hbc/cli/list.rb | 2 +- Library/Homebrew/cask/lib/hbc/cli/uninstall.rb | 4 +- Library/Homebrew/cask/lib/hbc/dsl.rb | 12 ++++- Library/Homebrew/cask/lib/hbc/dsl/base.rb | 16 +++++-- Library/Homebrew/cask/lib/hbc/dsl/stanza_proxy.rb | 20 ++++++--- Library/Homebrew/cask/lib/hbc/installer.rb | 24 +++++----- .../cask/lib/hbc/source/tapped_qualified.rb | 2 +- Library/Homebrew/cask/lib/hbc/system_command.rb | 2 +- Library/Homebrew/cask/lib/hbc/url_checker.rb | 2 +- Library/Homebrew/cask/lib/hbc/utils.rb | 15 ++++--- .../Homebrew/cask/spec/cask/cli/cleanup_spec.rb | 2 +- Library/Homebrew/cask/spec/spec_helper.rb | 2 +- .../test/cask/artifact/two_apps_correct_test.rb | 9 ++-- Library/Homebrew/cask/test/cask/cli/list_test.rb | 4 +- Library/Homebrew/cask/test/test_helper.rb | 2 +- 29 files changed, 158 insertions(+), 134 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/.rubocop.yml b/Library/Homebrew/cask/.rubocop.yml index 2677748ad..7ba758a90 100644 --- a/Library/Homebrew/cask/.rubocop.yml +++ b/Library/Homebrew/cask/.rubocop.yml @@ -31,9 +31,6 @@ Metrics/ModuleLength: Metrics/PerceivedComplexity: Enabled: false -Performance/StringReplacement: - Enabled: false - Style/AlignHash: EnforcedHashRocketStyle: table EnforcedColonStyle: table @@ -129,6 +126,8 @@ Style/RegexpLiteral: Style/StringLiterals: EnforcedStyle: double_quotes +Style/StringLiteralsInInterpolation: + EnforcedStyle: double_quotes + Style/TrailingCommaInLiteral: EnforcedStyleForMultiline: comma - 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" -- cgit v1.2.3 From a5f050245e1d10654c3f90e1df30de56f49b059e Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 20 Sep 2016 19:36:32 +0200 Subject: Add Regex for `Style/FileName` cop. --- Library/.rubocop_rules.yml | 10 +++++++--- Library/Homebrew/cask/.rubocop.yml | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'Library') diff --git a/Library/.rubocop_rules.yml b/Library/.rubocop_rules.yml index cde310930..88e0e25e6 100644 --- a/Library/.rubocop_rules.yml +++ b/Library/.rubocop_rules.yml @@ -98,10 +98,14 @@ Style/IfUnlessModifier: 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 diff --git a/Library/Homebrew/cask/.rubocop.yml b/Library/Homebrew/cask/.rubocop.yml index 7ba758a90..770b8728e 100644 --- a/Library/Homebrew/cask/.rubocop.yml +++ b/Library/Homebrew/cask/.rubocop.yml @@ -91,7 +91,7 @@ Style/Documentation: Enabled: false Style/FileName: - Enabled: false + 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 -- cgit v1.2.3 From 14362a7e5fe34be9a26eebda7424858c1458e0b2 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 20 Sep 2016 20:37:18 +0200 Subject: Include `.simplecov` in RuboCop. --- Library/.rubocop.yml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Library') 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/**/*' -- cgit v1.2.3 From 0581dda187934933128a578400205557d9b27adc Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 20 Sep 2016 20:50:29 +0200 Subject: Auto-correct guard clauses. --- Library/Homebrew/descriptions.rb | 4 +--- Library/Homebrew/diagnostic.rb | 8 ++------ 2 files changed, 3 insertions(+), 9 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/descriptions.rb b/Library/Homebrew/descriptions.rb index 5e7a5b06c..24e342474 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 diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 650ff3eab..ae5a64c1d 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 -- cgit v1.2.3 From 77bd30574b309d0cba46ceb5fef0b37c7db5d704 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 20 Sep 2016 20:55:00 +0200 Subject: Disable Style/GuardClause only in Taps. --- Library/.rubocop_rules.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/.rubocop_rules.yml b/Library/.rubocop_rules.yml index 88e0e25e6..d4dd15334 100644 --- a/Library/.rubocop_rules.yml +++ b/Library/.rubocop_rules.yml @@ -93,7 +93,8 @@ Style/AlignParameters: # counterproductive in formulas, notably within the install method Style/GuardClause: - Enabled: false + Exclude: + - 'Taps/**/*' Style/IfUnlessModifier: Enabled: false -- cgit v1.2.3 From eec68a1e05f94970091feb19814a02b0b8471d4d Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 20 Sep 2016 20:55:39 +0200 Subject: Disable Style/IfUnlessModifier only in Taps. --- Library/.rubocop_rules.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/.rubocop_rules.yml b/Library/.rubocop_rules.yml index d4dd15334..16ffe6c75 100644 --- a/Library/.rubocop_rules.yml +++ b/Library/.rubocop_rules.yml @@ -96,7 +96,8 @@ Style/GuardClause: Exclude: - 'Taps/**/*' Style/IfUnlessModifier: - Enabled: false + Exclude: + - 'Taps/**/*' # dashes in filenames are typical Style/FileName: -- cgit v1.2.3 From 8b921c087cde0b3ca2dbcdc11b900ca4ae8a4fec Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 20 Sep 2016 21:13:04 +0200 Subject: Disable new Style/VariableNumber cop. --- Library/.rubocop_rules.yml | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Library') diff --git a/Library/.rubocop_rules.yml b/Library/.rubocop_rules.yml index 16ffe6c75..f1e3e6ec5 100644 --- a/Library/.rubocop_rules.yml +++ b/Library/.rubocop_rules.yml @@ -99,6 +99,11 @@ Style/IfUnlessModifier: Exclude: - 'Taps/**/*' +# TODO: enforce when rubocop has fixed this +# https://github.com/bbatsov/rubocop/issues/3516 +Style/VariableNumber: + Enabled: false + # dashes in filenames are typical Style/FileName: # matches: -- cgit v1.2.3 From 129dfcac4ad8c7f577039f3d0277cf0243eb053c Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 20 Sep 2016 21:24:50 +0200 Subject: Remove `.simplecov` from cask’s RuboCop config. --- Library/Homebrew/cask/.rubocop.yml | 2 -- 1 file changed, 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cask/.rubocop.yml b/Library/Homebrew/cask/.rubocop.yml index 770b8728e..cc505c812 100644 --- a/Library/Homebrew/cask/.rubocop.yml +++ b/Library/Homebrew/cask/.rubocop.yml @@ -1,7 +1,5 @@ AllCops: TargetRubyVersion: 2.0 - Include: - - '**/.simplecov' Exclude: - '**/Casks/**/*' - '**/vendor/**/*' -- cgit v1.2.3 From be22265860bd32deede9536035310c592d82583d Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 20 Sep 2016 21:36:04 +0200 Subject: Set Style/NumericLiterals MinDigits to 7. --- Library/.rubocop_rules.yml | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Library') diff --git a/Library/.rubocop_rules.yml b/Library/.rubocop_rules.yml index f1e3e6ec5..6d14287b6 100644 --- a/Library/.rubocop_rules.yml +++ b/Library/.rubocop_rules.yml @@ -7,6 +7,10 @@ Style/StringLiterals: Style/StringLiteralsInInterpolation: EnforcedStyle: double_quotes +# only for numbers >= 1_000_000 +Style/NumericLiterals: + MinDigits: 7 + # percent-x is allowed for multiline Style/CommandLiteral: EnforcedStyle: mixed -- cgit v1.2.3 From db37920fa71060d8557dc83013c06f8ff61ef4a1 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 20 Sep 2016 21:36:24 +0200 Subject: Run `rubocop`. --- Library/Homebrew/requirements.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/requirements.rb b/Library/Homebrew/requirements.rb index 68d21a2b7..3774319ee 100644 --- a/Library/Homebrew/requirements.rb +++ b/Library/Homebrew/requirements.rb @@ -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 -- cgit v1.2.3 From 52ff98853068c03b3bfa777932da1da69e35e583 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 20 Sep 2016 22:03:08 +0200 Subject: Fix RuboCop CaseEquality. --- Library/.rubocop_todo.yml | 144 +++++++++++++++++++++++++------ Library/Homebrew/cask/.rubocop.yml | 1 + Library/Homebrew/cleanup.rb | 4 +- Library/Homebrew/cmd/search.rb | 2 +- Library/Homebrew/cxxstdlib.rb | 2 +- Library/Homebrew/debrew.rb | 26 +++--- Library/Homebrew/dependencies.rb | 2 +- Library/Homebrew/dependency_collector.rb | 6 +- Library/Homebrew/download_strategy.rb | 6 +- Library/Homebrew/formula.rb | 6 +- Library/Homebrew/options.rb | 2 +- Library/Homebrew/patch.rb | 2 +- Library/Homebrew/pkg_version.rb | 2 +- Library/Homebrew/requirement.rb | 4 +- Library/Homebrew/requirements.rb | 2 +- Library/Homebrew/software_spec.rb | 4 +- Library/Homebrew/version.rb | 2 +- 17 files changed, 156 insertions(+), 61 deletions(-) (limited to 'Library') diff --git a/Library/.rubocop_todo.yml b/Library/.rubocop_todo.yml index a898d2f79..4be619071 100644 --- a/Library/.rubocop_todo.yml +++ b/Library/.rubocop_todo.yml @@ -1,6 +1,6 @@ # 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-20 22:03:20 +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 @@ -80,12 +80,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,9 +89,9 @@ Metrics/BlockNesting: # Offense count: 20 # Configuration parameters: CountComments. Metrics/ModuleLength: - Max: 400 + Max: 373 -# Offense count: 1 +# Offense count: 2 # Configuration parameters: CountKeywordArgs. Metrics/ParameterLists: Max: 6 @@ -125,25 +120,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. @@ -193,11 +173,103 @@ Style/GlobalVars: - 'Homebrew/diagnostic.rb' - 'Homebrew/utils.rb' +# Offense count: 97 +# Configuration parameters: MinBodyLength. +Style/GuardClause: + Exclude: + - 'Taps/**/*' + - 'Homebrew/brew.rb' + - 'Homebrew/build.rb' + - 'Homebrew/caveats.rb' + - 'Homebrew/cleaner.rb' + - 'Homebrew/cmd/cleanup.rb' + - 'Homebrew/cmd/diy.rb' + - 'Homebrew/cmd/info.rb' + - 'Homebrew/cmd/install.rb' + - 'Homebrew/cmd/reinstall.rb' + - 'Homebrew/cmd/search.rb' + - 'Homebrew/cmd/update-report.rb' + - 'Homebrew/dependency_collector.rb' + - 'Homebrew/dev-cmd/audit.rb' + - 'Homebrew/dev-cmd/bottle.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: 2 Style/IdenticalConditionalBranches: Exclude: - 'Homebrew/formula_lock.rb' +# Offense count: 52 +# Cop supports --auto-correct. +# Configuration parameters: MaxLineLength. +Style/IfUnlessModifier: + Exclude: + - 'Taps/**/*' + - 'Homebrew/dev-cmd/audit.rb' + - 'Homebrew/dev-cmd/bottle.rb' + - 'Homebrew/dev-cmd/edit.rb' + - 'Homebrew/dev-cmd/mirror.rb' + - 'Homebrew/dev-cmd/pull.rb' + - 'Homebrew/dev-cmd/test-bot.rb' + - 'Homebrew/extend/ENV/std.rb' + - 'Homebrew/extend/ENV/super.rb' + - 'Homebrew/extend/os/blacklist.rb' + - 'Homebrew/extend/os/bottles.rb' + - 'Homebrew/extend/os/cleaner.rb' + - 'Homebrew/extend/os/development_tools.rb' + - 'Homebrew/extend/os/diagnostic.rb' + - 'Homebrew/extend/os/emoji.rb' + - 'Homebrew/extend/os/extend/ENV/shared.rb' + - 'Homebrew/extend/os/extend/ENV/std.rb' + - 'Homebrew/extend/os/extend/ENV/super.rb' + - 'Homebrew/extend/os/formula_cellar_checks.rb' + - 'Homebrew/extend/os/keg_relocate.rb' + - 'Homebrew/extend/os/mac/extend/ENV/shared.rb' + - 'Homebrew/extend/os/system_config.rb' + - 'Homebrew/formula.rb' + - 'Homebrew/formula_installer.rb' + - 'Homebrew/formula_versions.rb' + - 'Homebrew/formulary.rb' + - 'Homebrew/language/haskell.rb' + - 'Homebrew/migrator.rb' + - 'Homebrew/os/mac/cctools_mach.rb' + - 'Homebrew/tab.rb' + - 'Homebrew/utils/git.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: 5 # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: snake_case, camelCase @@ -249,6 +321,11 @@ Style/Next: Exclude: - 'Homebrew/dev-cmd/test-bot.rb' +# Offense count: 1 +# Cop supports --auto-correct. +Style/NumericLiterals: + MinDigits: 6 + # Offense count: 9 Style/OpMethod: Exclude: @@ -291,3 +368,18 @@ Style/Semicolon: Style/SingleLineBlockParams: Exclude: - 'Homebrew/diagnostic.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: SupportedStyles. +# SupportedStyles: use_perl_names, use_english_names +Style/SpecialGlobalVars: + EnforcedStyle: use_perl_names + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, AllowSafeAssignment. +# SupportedStyles: require_parentheses, require_no_parentheses +Style/TernaryParentheses: + Exclude: + - 'Homebrew/formula.rb' diff --git a/Library/Homebrew/cask/.rubocop.yml b/Library/Homebrew/cask/.rubocop.yml index cc505c812..1f473e07b 100644 --- a/Library/Homebrew/cask/.rubocop.yml +++ b/Library/Homebrew/cask/.rubocop.yml @@ -1,6 +1,7 @@ AllCops: TargetRubyVersion: 2.0 Exclude: + - '**/.simplecov' - '**/Casks/**/*' - '**/vendor/**/*' diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb index 265f06d26..42be339a0 100644 --- a/Library/Homebrew/cleanup.rb +++ b/Library/Homebrew/cleanup.rb @@ -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 diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb index 50d9f5f74..3f00e8a10 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`" [] 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..99aa2db9a 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) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index cabb22c22..048153c16 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -668,7 +668,7 @@ class GitDownloadStrategy < VCSDownloadStrategy 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 @@ -1021,9 +1021,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/formula.rb b/Library/Homebrew/formula.rb index 4b3ef33f2..cd1890a43 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1052,7 +1052,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 +1246,7 @@ class Formula # @private def <=>(other) - return unless Formula === other + return unless other.is_a?(Formula) name <=> other.name end @@ -2226,7 +2226,7 @@ class Formula # If this formula conflicts with another one. #
conflicts_with "imagemagick", :because => "because this is just a stupid example"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/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/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..7ab3aaeed 100644 --- a/Library/Homebrew/requirement.rb +++ b/Library/Homebrew/requirement.rb @@ -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 3774319ee..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 diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index 986dc5354..8e42e20da 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -116,12 +116,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? diff --git a/Library/Homebrew/version.rb b/Library/Homebrew/version.rb index 520db6626..b15fc3693 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? -- cgit v1.2.3 From 23eac7ab897818689eeff6a810354d85543ad2bb Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 20 Sep 2016 22:24:31 +0200 Subject: Fix DoubleNegation. --- Library/.rubocop_todo.yml | 4 ---- Library/Homebrew/extend/ARGV.rb | 2 +- Library/Homebrew/formula_installer.rb | 7 +++++-- Library/Homebrew/os/mac/xcode.rb | 2 +- Library/Homebrew/requirement.rb | 2 +- Library/Homebrew/software_spec.rb | 7 ++++--- 6 files changed, 12 insertions(+), 12 deletions(-) (limited to 'Library') diff --git a/Library/.rubocop_todo.yml b/Library/.rubocop_todo.yml index 4be619071..b81d8e0ef 100644 --- a/Library/.rubocop_todo.yml +++ b/Library/.rubocop_todo.yml @@ -151,13 +151,9 @@ Style/ConstantName: # 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. 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/formula_installer.rb b/Library/Homebrew/formula_installer.rb index f64b77026..303617218 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 }) 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/requirement.rb b/Library/Homebrew/requirement.rb index 7ab3aaeed..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. diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index 8e42e20da..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 @@ -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 -- cgit v1.2.3 From b97b0bac6c5904e369778245f2c7074d9c4810ea Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Tue, 20 Sep 2016 22:33:30 +0200 Subject: Update .rubocop_todo.yml. --- Library/.rubocop_todo.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Library') diff --git a/Library/.rubocop_todo.yml b/Library/.rubocop_todo.yml index b81d8e0ef..feae1d37b 100644 --- a/Library/.rubocop_todo.yml +++ b/Library/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 100` -# on 2016-09-20 22:03:20 +0200 using RuboCop version 0.43.0. +# on 2016-09-20 22:27:29 +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 @@ -148,7 +148,7 @@ Style/ConstantName: Exclude: - 'Homebrew/os/mac.rb' -# Offense count: 10 +# Offense count: 3 Style/DoubleNegation: Exclude: - 'Homebrew/os/mac/cctools_keg.rb' -- cgit v1.2.3 From 3540c94df6ff6d1e6d7baadde74e1d27ad066c6b Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 21 Sep 2016 07:53:29 +0200 Subject: Add `define_method` and `define_singleton_method`. --- Library/Homebrew/cask/.rubocop.yml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/cask/.rubocop.yml b/Library/Homebrew/cask/.rubocop.yml index 1f473e07b..08696fdb8 100644 --- a/Library/Homebrew/cask/.rubocop.yml +++ b/Library/Homebrew/cask/.rubocop.yml @@ -67,6 +67,8 @@ Style/BlockDelimiters: - chdir - context - create + - define_method + - define_singleton_method - each_with_object - fork - measure -- cgit v1.2.3 From 42efb44e7d942e9b96ec40f29e5c79e9f7b1e250 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 21 Sep 2016 08:32:57 +0200 Subject: Fix Lint/EndAlignment. --- Library/.rubocop_todo.yml | 10 ---------- Library/Homebrew/dependency_collector.rb | 8 ++++---- Library/Homebrew/download_strategy.rb | 11 +++++++---- Library/Homebrew/keg.rb | 8 ++++---- 4 files changed, 15 insertions(+), 22 deletions(-) (limited to 'Library') diff --git a/Library/.rubocop_todo.yml b/Library/.rubocop_todo.yml index feae1d37b..2f522a8fd 100644 --- a/Library/.rubocop_todo.yml +++ b/Library/.rubocop_todo.yml @@ -6,16 +6,6 @@ # 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: diff --git a/Library/Homebrew/dependency_collector.rb b/Library/Homebrew/dependency_collector.rb index 99aa2db9a..0b35e7fb4 100644 --- a/Library/Homebrew/dependency_collector.rb +++ b/Library/Homebrew/dependency_collector.rb @@ -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/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 048153c16..2762f01b0 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -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 @@ -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 diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index ecbc4c6e0..db3705bc1 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -249,10 +249,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 -- cgit v1.2.3 From 240e49052cf113b74c0b2940531d7b6a28ab83af Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 21 Sep 2016 08:49:04 +0200 Subject: Fix Performance/FixedSize. --- Library/.rubocop_todo.yml | 6 ------ Library/Homebrew/dev-cmd/audit.rb | 2 +- Library/Homebrew/dev-cmd/bottle.rb | 2 +- 3 files changed, 2 insertions(+), 8 deletions(-) (limited to 'Library') diff --git a/Library/.rubocop_todo.yml b/Library/.rubocop_todo.yml index 2f522a8fd..fde1d853f 100644 --- a/Library/.rubocop_todo.yml +++ b/Library/.rubocop_todo.yml @@ -86,12 +86,6 @@ Metrics/ModuleLength: 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: diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 20e9a8aff..55f545d0c 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -467,7 +467,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. diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index f4d6a463a..fe07526f3 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -436,7 +436,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!( -- cgit v1.2.3 From 1c632f9c1ee8727c084e6020552c5983b1127b1c Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 21 Sep 2016 08:55:07 +0200 Subject: Fix Style/CaseIndentation. --- Library/.rubocop_todo.yml | 8 -------- Library/Homebrew/keg.rb | 9 +++++++-- 2 files changed, 7 insertions(+), 10 deletions(-) (limited to 'Library') diff --git a/Library/.rubocop_todo.yml b/Library/.rubocop_todo.yml index fde1d853f..421944874 100644 --- a/Library/.rubocop_todo.yml +++ b/Library/.rubocop_todo.yml @@ -109,14 +109,6 @@ Style/CaseEquality: Exclude: - 'Homebrew/compilers.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: Exclude: diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index db3705bc1..e49c8126b 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -66,8 +66,13 @@ class Keg 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 -- cgit v1.2.3 From 4064084c58138a22d234c19fc171e7d0b7a440d0 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 21 Sep 2016 09:07:04 +0200 Subject: Fix Style/MethodName. --- Library/.rubocop_todo.yml | 12 ------------ Library/Homebrew/cleanup.rb | 4 ++-- Library/Homebrew/diagnostic.rb | 2 +- Library/Homebrew/formula_cellar_checks.rb | 2 +- Library/Homebrew/formula_installer.rb | 8 ++++---- Library/Homebrew/test/test_diagnostic.rb | 2 +- 6 files changed, 9 insertions(+), 21 deletions(-) (limited to 'Library') diff --git a/Library/.rubocop_todo.yml b/Library/.rubocop_todo.yml index 421944874..dd8b34df7 100644 --- a/Library/.rubocop_todo.yml +++ b/Library/.rubocop_todo.yml @@ -242,18 +242,6 @@ Style/IfUnlessModifier: Style/IndentArray: EnforcedStyle: special_inside_parentheses -# Offense count: 5 -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: snake_case, camelCase -Style/MethodName: - Exclude: - - 'Homebrew/compat/**/*' - - 'Homebrew/cleanup.rb' - - 'Homebrew/diagnostic.rb' - - 'Homebrew/formula_cellar_checks.rb' - - 'Homebrew/formula_installer.rb' - - 'Homebrew/os/mac/cctools_mach.rb' - # Offense count: 7 # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: module_function, extend_self diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb index 42be339a0..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 @@ -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/diagnostic.rb b/Library/Homebrew/diagnostic.rb index ae5a64c1d..8f158ddd8 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -595,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? 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 303617218..f63ecdcb9 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -546,7 +546,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? @@ -585,7 +585,7 @@ class FormulaInstaller end def build_argv - sanitized_ARGV_options + options.as_flags + sanitized_argv_options + options.as_flags end def build @@ -813,8 +813,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/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 -- cgit v1.2.3 From 23dacc752529bcba88248899cd5b67a66499dc40 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 21 Sep 2016 09:21:27 +0200 Subject: Fix Style/Next. --- Library/.rubocop_todo.yml | 8 -------- Library/Homebrew/dev-cmd/test-bot.rb | 9 ++++----- 2 files changed, 4 insertions(+), 13 deletions(-) (limited to 'Library') diff --git a/Library/.rubocop_todo.yml b/Library/.rubocop_todo.yml index dd8b34df7..3b5a91c5e 100644 --- a/Library/.rubocop_todo.yml +++ b/Library/.rubocop_todo.yml @@ -273,14 +273,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: 1 # Cop supports --auto-correct. Style/NumericLiterals: diff --git a/Library/Homebrew/dev-cmd/test-bot.rb b/Library/Homebrew/dev-cmd/test-bot.rb index 7a5853c48..aa3a49610 100644 --- a/Library/Homebrew/dev-cmd/test-bot.rb +++ b/Library/Homebrew/dev-cmd/test-bot.rb @@ -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 -- cgit v1.2.3 From 9ce3c8d8a4059be6187dfcfd3daddfa7ef48c656 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 21 Sep 2016 09:22:21 +0200 Subject: Fix Style/NumericLiterals. --- Library/.rubocop_rules.yml | 12 ++++-------- Library/.rubocop_todo.yml | 5 ----- Library/Homebrew/dev-cmd/test-bot.rb | 4 ++-- Library/Homebrew/test/test_download_strategies.rb | 2 +- Library/Homebrew/test/test_pathname.rb | 2 +- 5 files changed, 8 insertions(+), 17 deletions(-) (limited to 'Library') diff --git a/Library/.rubocop_rules.yml b/Library/.rubocop_rules.yml index 6d14287b6..915b2e570 100644 --- a/Library/.rubocop_rules.yml +++ b/Library/.rubocop_rules.yml @@ -11,6 +11,10 @@ Style/StringLiteralsInInterpolation: 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 @@ -62,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: diff --git a/Library/.rubocop_todo.yml b/Library/.rubocop_todo.yml index 3b5a91c5e..0b29efe30 100644 --- a/Library/.rubocop_todo.yml +++ b/Library/.rubocop_todo.yml @@ -273,11 +273,6 @@ Style/MutableConstant: - 'Homebrew/tab.rb' - 'Homebrew/tap.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Style/NumericLiterals: - MinDigits: 6 - # Offense count: 9 Style/OpMethod: Exclude: diff --git a/Library/Homebrew/dev-cmd/test-bot.rb b/Library/Homebrew/dev-cmd/test-bot.rb index aa3a49610..d63f88a1c 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}" 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 -- cgit v1.2.3 From 0b473ebba9c84724274d8d49d1ddc88de3479b7f Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 21 Sep 2016 09:48:24 +0200 Subject: Fix Style/PredicateName. --- Library/.rubocop_rules.yml | 1 + Library/.rubocop_todo.yml | 11 ----------- Library/Homebrew/cask/.rubocop.yml | 3 --- Library/Homebrew/download_strategy.rb | 8 ++++---- 4 files changed, 5 insertions(+), 18 deletions(-) (limited to 'Library') diff --git a/Library/.rubocop_rules.yml b/Library/.rubocop_rules.yml index 915b2e570..c5a0018f8 100644 --- a/Library/.rubocop_rules.yml +++ b/Library/.rubocop_rules.yml @@ -145,6 +145,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 0b29efe30..47a262a76 100644 --- a/Library/.rubocop_todo.yml +++ b/Library/.rubocop_todo.yml @@ -281,17 +281,6 @@ 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. diff --git a/Library/Homebrew/cask/.rubocop.yml b/Library/Homebrew/cask/.rubocop.yml index 08696fdb8..076b87f61 100644 --- a/Library/Homebrew/cask/.rubocop.yml +++ b/Library/Homebrew/cask/.rubocop.yml @@ -115,9 +115,6 @@ Style/PercentLiteralDelimiters: '%W': '[]' '%x': '()' -Style/PredicateName: - NameWhitelist: is_32_bit?, is_64_bit? - Style/RaiseArgs: EnforcedStyle: exploded diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 2762f01b0..d19d131a7 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -663,7 +663,7 @@ class GitDownloadStrategy < VCSDownloadStrategy @shallow && support_depth? end - def is_shallow_clone? + def shallow_dir? git_dir.join("shallow").exist? end @@ -675,7 +675,7 @@ class GitDownloadStrategy < VCSDownloadStrategy cached_location.join(".git") end - def has_ref? + def ref? quiet_system "git", "--git-dir", git_dir, "rev-parse", "-q", "--verify", "#{@ref}^{commit}" end @@ -717,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" -- cgit v1.2.3 From 4be3aff253d56b65067a747795a4c46d602fa0c1 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 21 Sep 2016 09:58:26 +0200 Subject: Fix Lint/NonLocalExitFromIterator. --- Library/.rubocop_todo.yml | 5 ----- Library/Homebrew/extend/pathname.rb | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) (limited to 'Library') diff --git a/Library/.rubocop_todo.yml b/Library/.rubocop_todo.yml index 47a262a76..7bbad3c87 100644 --- a/Library/.rubocop_todo.yml +++ b/Library/.rubocop_todo.yml @@ -42,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: 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 -- cgit v1.2.3 From 21e0a7efb998b65c921885858969503513cad14b Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 21 Sep 2016 09:59:45 +0200 Subject: Update `rubocop` dependency to `0.43.0`. --- Library/Homebrew/cmd/style.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb index f28d50cc1..c598e9062 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 -- cgit v1.2.3 From ce6994b001520b8e5d26e5e15b410c9146072104 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 21 Sep 2016 12:43:05 +0200 Subject: RuboCop has to be run inside `HOMEBREW_LIBRARY`. --- Library/Homebrew/cmd/style.rb | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb index c598e9062..db61116be 100644 --- a/Library/Homebrew/cmd/style.rb +++ b/Library/Homebrew/cmd/style.rb @@ -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 -- cgit v1.2.3 From d7a312f6cf1a17e36891f4533ec48e53c5276e3d Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 21 Sep 2016 13:43:02 +0200 Subject: Fix Style/IdenticalConditionalBranches. --- Library/.rubocop_todo.yml | 5 ----- Library/Homebrew/formula_lock.rb | 5 ++--- 2 files changed, 2 insertions(+), 8 deletions(-) (limited to 'Library') diff --git a/Library/.rubocop_todo.yml b/Library/.rubocop_todo.yml index 7bbad3c87..04a2cdd6e 100644 --- a/Library/.rubocop_todo.yml +++ b/Library/.rubocop_todo.yml @@ -188,11 +188,6 @@ Style/GuardClause: - 'Homebrew/utils/popen.rb' - 'Homebrew/version.rb' -# Offense count: 2 -Style/IdenticalConditionalBranches: - Exclude: - - 'Homebrew/formula_lock.rb' - # Offense count: 52 # Cop supports --auto-correct. # Configuration parameters: MaxLineLength. 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 -- cgit v1.2.3 From 0406f918a67c75559f926f6372a6d8aed5b18d1e Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 21 Sep 2016 14:36:11 +0200 Subject: Fix Style/SingleLineBlockParams. --- Library/.rubocop_todo.yml | 7 ------- Library/Homebrew/diagnostic.rb | 4 ++-- 2 files changed, 2 insertions(+), 9 deletions(-) (limited to 'Library') diff --git a/Library/.rubocop_todo.yml b/Library/.rubocop_todo.yml index 04a2cdd6e..d044796fe 100644 --- a/Library/.rubocop_todo.yml +++ b/Library/.rubocop_todo.yml @@ -288,13 +288,6 @@ 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' - # Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: SupportedStyles. diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 8f158ddd8..62e916ce1 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -78,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 -- cgit v1.2.3 From 4861ee6c2d5bdda8ae155a1fb1f4c66ff562732d Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 21 Sep 2016 14:36:20 +0200 Subject: Fix Style/Semicolon. --- Library/.rubocop_todo.yml | 7 ------- Library/Homebrew/descriptions.rb | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) (limited to 'Library') diff --git a/Library/.rubocop_todo.yml b/Library/.rubocop_todo.yml index d044796fe..58eb67657 100644 --- a/Library/.rubocop_todo.yml +++ b/Library/.rubocop_todo.yml @@ -281,13 +281,6 @@ Style/RegexpLiteral: - 'Homebrew/keg.rb' - 'Homebrew/version.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: AllowAsExpressionSeparator. -Style/Semicolon: - Exclude: - - 'Homebrew/descriptions.rb' - # Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: SupportedStyles. diff --git a/Library/Homebrew/descriptions.rb b/Library/Homebrew/descriptions.rb index 24e342474..0ef4316d3 100644 --- a/Library/Homebrew/descriptions.rb +++ b/Library/Homebrew/descriptions.rb @@ -136,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 -- cgit v1.2.3 From b5f8de8bf42d25fed56e71be8e95933030d6a52b Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 21 Sep 2016 14:44:22 +0200 Subject: Fix Style/RegexpLiteral. --- Library/.rubocop_todo.yml | 10 ---------- Library/Homebrew/diagnostic.rb | 2 +- Library/Homebrew/keg.rb | 10 +++++----- Library/Homebrew/version.rb | 2 +- 4 files changed, 7 insertions(+), 17 deletions(-) (limited to 'Library') diff --git a/Library/.rubocop_todo.yml b/Library/.rubocop_todo.yml index 58eb67657..c6a4f279e 100644 --- a/Library/.rubocop_todo.yml +++ b/Library/.rubocop_todo.yml @@ -271,16 +271,6 @@ Style/OpMethod: - 'Homebrew/install_renamed.rb' - 'Homebrew/options.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: 2 # Cop supports --auto-correct. # Configuration parameters: SupportedStyles. diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 62e916ce1..743c653d2 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -754,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/keg.rb b/Library/Homebrew/keg.rb index e49c8126b..65ce6480a 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -62,7 +62,7 @@ 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 @@ -323,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 @@ -367,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/version.rb b/Library/Homebrew/version.rb index b15fc3693..c0e5324ea 100644 --- a/Library/Homebrew/version.rb +++ b/Library/Homebrew/version.rb @@ -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 -- cgit v1.2.3 From 6d3de5cf60b771ee9320c41921eb5f20142895cf Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 21 Sep 2016 15:14:15 +0200 Subject: Temporarily disable Style/TernaryParentheses. --- Library/.rubocop_rules.yml | 5 +++++ Library/.rubocop_todo.yml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'Library') diff --git a/Library/.rubocop_rules.yml b/Library/.rubocop_rules.yml index c5a0018f8..95f8ae0a3 100644 --- a/Library/.rubocop_rules.yml +++ b/Library/.rubocop_rules.yml @@ -104,6 +104,11 @@ Style/IfUnlessModifier: 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 Style/FileName: # matches: diff --git a/Library/.rubocop_todo.yml b/Library/.rubocop_todo.yml index c6a4f279e..e27d89617 100644 --- a/Library/.rubocop_todo.yml +++ b/Library/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 100` -# on 2016-09-20 22:27:29 +0200 using RuboCop version 0.43.0. +# on 2016-09-21 14:04:48 +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 -- cgit v1.2.3 From a5b11a6a5c7e29b9040f93fd211f52479507dd01 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 22 Sep 2016 20:12:28 +0200 Subject: Fix Style/GuardClause. --- Library/.rubocop_todo.yml | 35 ++----------- Library/Homebrew/brew.rb | 6 +-- Library/Homebrew/build.rb | 5 +- Library/Homebrew/caveats.rb | 51 ++++++++++-------- Library/Homebrew/cleaner.rb | 6 +-- Library/Homebrew/cmd/cleanup.rb | 14 ++--- Library/Homebrew/cmd/diy.rb | 8 ++- Library/Homebrew/cmd/info.rb | 7 +-- Library/Homebrew/cmd/install.rb | 10 ++-- Library/Homebrew/cmd/reinstall.rb | 9 ++-- Library/Homebrew/cmd/search.rb | 7 +-- Library/Homebrew/dev-cmd/audit.rb | 103 ++++++++++++++++++------------------- Library/Homebrew/dev-cmd/bottle.rb | 64 +++++++++++------------ 13 files changed, 150 insertions(+), 175 deletions(-) (limited to 'Library') diff --git a/Library/.rubocop_todo.yml b/Library/.rubocop_todo.yml index e27d89617..c6e126a9e 100644 --- a/Library/.rubocop_todo.yml +++ b/Library/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 100` -# on 2016-09-21 14:04:48 +0200 using RuboCop version 0.43.0. +# 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 @@ -74,7 +74,7 @@ Metrics/BlockNesting: # Offense count: 20 # Configuration parameters: CountComments. Metrics/ModuleLength: - Max: 373 + Max: 370 # Offense count: 2 # Configuration parameters: CountKeywordArgs. @@ -119,13 +119,6 @@ Style/ConstantName: Exclude: - 'Homebrew/os/mac.rb' -# Offense count: 3 -Style/DoubleNegation: - Exclude: - - 'Homebrew/os/mac/cctools_keg.rb' - - 'Homebrew/os/mac/ruby_keg.rb' - - 'Homebrew/os/mac/xcode.rb' - # Offense count: 1 # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: format, sprintf, percent @@ -140,25 +133,14 @@ Style/GlobalVars: - 'Homebrew/diagnostic.rb' - 'Homebrew/utils.rb' -# Offense count: 97 +# Offense count: 70 # Configuration parameters: MinBodyLength. Style/GuardClause: Exclude: - 'Taps/**/*' - - 'Homebrew/brew.rb' - - 'Homebrew/build.rb' - - 'Homebrew/caveats.rb' - - 'Homebrew/cleaner.rb' - - 'Homebrew/cmd/cleanup.rb' - - 'Homebrew/cmd/diy.rb' - - 'Homebrew/cmd/info.rb' - - 'Homebrew/cmd/install.rb' - - 'Homebrew/cmd/reinstall.rb' - - 'Homebrew/cmd/search.rb' - 'Homebrew/cmd/update-report.rb' - 'Homebrew/dependency_collector.rb' - 'Homebrew/dev-cmd/audit.rb' - - 'Homebrew/dev-cmd/bottle.rb' - 'Homebrew/dev-cmd/pull.rb' - 'Homebrew/dev-cmd/test-bot.rb' - 'Homebrew/download_strategy.rb' @@ -188,7 +170,7 @@ Style/GuardClause: - 'Homebrew/utils/popen.rb' - 'Homebrew/version.rb' -# Offense count: 52 +# Offense count: 51 # Cop supports --auto-correct. # Configuration parameters: MaxLineLength. Style/IfUnlessModifier: @@ -221,7 +203,6 @@ Style/IfUnlessModifier: - 'Homebrew/formulary.rb' - 'Homebrew/language/haskell.rb' - 'Homebrew/migrator.rb' - - 'Homebrew/os/mac/cctools_mach.rb' - 'Homebrew/tab.rb' - 'Homebrew/utils/git.rb' @@ -277,11 +258,3 @@ Style/OpMethod: # SupportedStyles: use_perl_names, use_english_names Style/SpecialGlobalVars: EnforcedStyle: use_perl_names - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, AllowSafeAssignment. -# SupportedStyles: require_parentheses, require_no_parentheses -Style/TernaryParentheses: - Exclude: - - 'Homebrew/formula.rb' 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