Skip to content
Snippets Groups Projects
Unverified Commit 3a91c37e authored by Mike McQuaid's avatar Mike McQuaid
Browse files

Fix RuboCop checks.

parent 33e5e157
No related branches found
No related tags found
No related merge requests found
Showing
with 62 additions and 46 deletions
......@@ -212,6 +212,10 @@ Style/GuardClause:
Style/HashSyntax:
EnforcedStyle: ruby19
# so many of these in formulae and can't be autocorrected
Style/StringConcatenation:
Enabled: false
# ruby style guide favorite
Style/StringLiterals:
EnforcedStyle: double_quotes
......
......@@ -63,7 +63,7 @@ Metrics/ModuleLength:
Max: 600
Metrics/PerceivedComplexity:
Enabled: true
Max: 80
Max: 90
# we won't change backward compatible predicate names
Naming/PredicateName:
......@@ -139,3 +139,7 @@ Style/FrozenStringLiteralComment:
# so many of these in formulae but none in here
Style/GuardClause:
Enabled: true
# so many of these in formulae but none in here
Style/StringConcatenation:
Enabled: true
......@@ -98,11 +98,11 @@ module Cask
@caskroom_path ||= Caskroom.path.join(token)
end
def outdated?(greedy = false)
!outdated_versions(greedy).empty?
def outdated?(greedy: false)
!outdated_versions(greedy: greedy).empty?
end
def outdated_versions(greedy = false)
def outdated_versions(greedy: false)
# special case: tap version is not available
return [] if version.nil?
......@@ -125,7 +125,7 @@ module Cask
def outdated_info(greedy, verbose, json)
return token if !verbose && !json
installed_versions = outdated_versions(greedy).join(", ")
installed_versions = outdated_versions(greedy: greedy).join(", ")
if json
{
......
......@@ -44,7 +44,7 @@ module Cask
attr_reader :token, :path
def initialize(path)
def initialize(path) # rubocop:disable Lint/MissingSuper
path = Pathname(path).expand_path
@token = path.basename(".rb").to_s
......@@ -79,7 +79,7 @@ module Cask
class FromURILoader < FromPathLoader
def self.can_load?(ref)
uri_regex = ::URI::DEFAULT_PARSER.make_regexp
return false unless ref.to_s.match?(Regexp.new('\A' + uri_regex.source + '\Z', uri_regex.options))
return false unless ref.to_s.match?(Regexp.new("\\A#{uri_regex.source}\\Z", uri_regex.options))
uri = URI(ref)
return false unless uri
......
......@@ -58,20 +58,22 @@ module Cask
}.freeze
def self.description
max_command_len = Cmd.commands.map(&:length).max
max_command_length = Cmd.commands.map(&:length).max
<<~EOS +
command_lines = Cmd.command_classes
.select(&:visible?)
.map do |klass|
" - #{"`#{klass.command_name}`".ljust(max_command_length + 2)} #{klass.short_description}\n"
end
<<~EOS
Homebrew Cask provides a friendly CLI workflow for the administration of macOS applications distributed as binaries.
Commands:
#{command_lines.join}
See also: `man brew`
EOS
Cmd.command_classes
.select(&:visible?)
.map do |klass|
" - #{"`#{klass.command_name}`".ljust(max_command_len + 2)} #{klass.short_description}\n"
end
.join +
"\nSee also: `man brew`"
end
def self.parser(&block)
......
......@@ -17,7 +17,7 @@ module Cask
def run
success = true
checks = Homebrew::Diagnostic::Checks.new true
checks = Homebrew::Diagnostic::Checks.new(verbose: true)
checks.cask_checks.each do |check|
out = checks.send(check)
......
......@@ -34,16 +34,16 @@ module Cask
end
def self.get_info(cask)
output = title_info(cask) + "\n"
output << Formatter.url(cask.homepage) + "\n" if cask.homepage
output = +"#{title_info(cask)}\n"
output << "#{Formatter.url(cask.homepage)}\n" if cask.homepage
output << installation_info(cask)
repo = repo_info(cask)
output << repo + "\n" if repo
output << "#{repo}\n" if repo
output << name_info(cask)
output << desc_info(cask)
language = language_info(cask)
output << language if language
output << artifact_info(cask) + "\n"
output << "#{artifact_info(cask)}\n"
caveats = Installer.caveats(cask)
output << caveats if caveats
output
......
......@@ -19,7 +19,7 @@ module Cask
def run
outdated_casks = casks(alternative: -> { Caskroom.casks }).select do |cask|
odebug "Checking update info of Cask #{cask}"
cask.outdated?(args.greedy?)
cask.outdated?(greedy: args.greedy?)
end
verbose = ($stdout.tty? || args.verbose?) && !args.quiet?
......
......@@ -54,13 +54,13 @@ module Cask
outdated_casks = if casks.empty?
Caskroom.casks.select do |cask|
cask.outdated?(greedy)
cask.outdated?(greedy: greedy)
end
else
casks.select do |cask|
raise CaskNotInstalledError, cask unless cask.installed? || force
cask.outdated?(true)
cask.outdated?(greedy: true)
end
end
......
......@@ -292,7 +292,7 @@ module Cask
end
def respond_to_missing?(*)
true
super || true
end
def appdir
......
......@@ -30,7 +30,7 @@ module Cask
end
def respond_to_missing?(*)
true
super || true
end
end
end
......
......@@ -5,6 +5,8 @@ module Cask
class MultipleCaskErrors < CaskError
def initialize(errors)
super
@errors = errors
end
......@@ -20,6 +22,8 @@ module Cask
attr_reader :token, :reason
def initialize(token, reason = nil)
super()
@token = token
@reason = reason.to_s
end
......@@ -168,6 +172,8 @@ module Cask
attr_reader :path, :reason
def initialize(path, reason)
super
@path = path
@reason = reason
end
......
......@@ -85,7 +85,7 @@ module Cask
poo << "during #{section}" if section
poo << "on Cask #{token}."
opoo(poo.join(" ") + "\n" + error_message_with_suggestions)
opoo("#{poo.join(" ")}\n#{error_message_with_suggestions}")
end
end
end
......@@ -17,7 +17,7 @@ class Caveats
build = f.build
f.build = Tab.for_formula(f)
s = f.caveats.to_s
caveats << s.chomp + "\n" unless s.empty?
caveats << "#{s.chomp}\n" unless s.empty?
ensure
f.build = build
end
......
......@@ -28,7 +28,7 @@ class Cleaner
[@f.bin, @f.sbin, @f.lib].each { |d| clean_dir(d) if d.exist? }
# Get rid of any info 'dir' files, so they don't conflict at the link stage
info_dir_file = @f.info + "dir"
info_dir_file = @f.info/"dir"
observe_file_removal info_dir_file if info_dir_file.file? && !@f.skip_clean?(info_dir_file)
prune
......
......@@ -48,7 +48,7 @@ module Homebrew
mtime < days.days.ago && ctime < days.days.ago
end
def stale?(scrub = false)
def stale?(scrub: false)
return false unless resolved_path.file?
if dirname.basename.to_s == "Cask"
......@@ -308,7 +308,7 @@ module Homebrew
next
end
next cleanup_path(path) { path.unlink } if path.stale?(scrub?)
next cleanup_path(path) { path.unlink } if path.stale?(scrub: scrub?)
end
cleanup_unreferenced_downloads
......
......@@ -142,9 +142,9 @@ module Homebrew
if @table[switch] == true || @table[flag] == true
@cli_args << option
elsif @table[flag].instance_of? String
@cli_args << option + "=" + @table[flag]
@cli_args << "#{option}=#{@table[flag]}"
elsif @table[flag].instance_of? Array
@cli_args << option + "=" + @table[flag].join(",")
@cli_args << "#{option}=#{@table[flag].join(",")}"
end
end
@cli_args.freeze
......
......@@ -11,7 +11,7 @@ module Homebrew
@force_bottle = force_bottle
@flags = flags
__setobj__(@args)
super(@args)
end
def to_formulae
......
......@@ -83,26 +83,26 @@ module Homebrew
raise FormulaUnspecifiedError
end
puts_deps_tree dependents, recursive, args: args
puts_deps_tree dependents, recursive: recursive, args: args
return
elsif args.all?
puts_deps sorted_dependents(Formula.to_a + Cask::Cask.to_a), recursive, args: args
puts_deps sorted_dependents(Formula.to_a + Cask::Cask.to_a), recursive: recursive, args: args
return
elsif !args.no_named? && args.for_each?
puts_deps sorted_dependents(args.formulae_and_casks), recursive, args: args
puts_deps sorted_dependents(args.formulae_and_casks), recursive: recursive, args: args
return
end
if args.no_named?
raise FormulaUnspecifiedError unless args.installed?
puts_deps sorted_dependents(Formula.installed + Cask::Caskroom.casks), recursive, args: args
puts_deps sorted_dependents(Formula.installed + Cask::Caskroom.casks), recursive: recursive, args: args
return
end
dependents = dependents(args.formulae_and_casks)
all_deps = deps_for_dependents(dependents, recursive, args: args, &(args.union? ? :| : :&))
all_deps = deps_for_dependents(dependents, recursive: recursive, args: args, &(args.union? ? :| : :&))
condense_requirements(all_deps, args: args)
all_deps.map! { |d| dep_display_name(d, args: args) }
all_deps.uniq!
......@@ -144,7 +144,7 @@ module Homebrew
str
end
def deps_for_dependent(d, recursive = false, args:)
def deps_for_dependent(d, recursive: false, args:)
includes, ignores = args_includes_ignores(args)
deps = d.runtime_dependencies if @use_runtime_dependencies
......@@ -160,13 +160,13 @@ module Homebrew
deps + reqs.to_a
end
def deps_for_dependents(dependents, recursive = false, args:, &block)
dependents.map { |d| deps_for_dependent(d, recursive, args: args) }.reduce(&block)
def deps_for_dependents(dependents, recursive: false, args:, &block)
dependents.map { |d| deps_for_dependent(d, recursive: recursive, args: args) }.reduce(&block)
end
def puts_deps(dependents, recursive = false, args:)
def puts_deps(dependents, recursive: false, args:)
dependents.each do |dependent|
deps = deps_for_dependent(dependent, recursive, args: args)
deps = deps_for_dependent(dependent, recursive: recursive, args: args)
condense_requirements(deps, args: args)
deps.sort_by!(&:name)
deps.map! { |d| dep_display_name(d, args: args) }
......@@ -174,7 +174,7 @@ module Homebrew
end
end
def puts_deps_tree(dependents, recursive = false, args:)
def puts_deps_tree(dependents, recursive: false, args:)
dependents.each do |d|
puts d.full_name
@dep_stack = []
......
......@@ -31,7 +31,7 @@ module Homebrew
inject_dump_stats!(Diagnostic::Checks, /^check_*/) if args.audit_debug?
checks = Diagnostic::Checks.new args.verbose?
checks = Diagnostic::Checks.new(verbose: args.verbose?)
if args.list_checks?
puts checks.all.sort
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment