Skip to content
Snippets Groups Projects
Commit b4e8bfe7 authored by Markus Reiter's avatar Markus Reiter
Browse files

Fix RuboCop offenses.

parent 2c893b94
No related branches found
No related tags found
No related merge requests found
......@@ -45,7 +45,7 @@ module Cask
def <=>(other)
return unless other.class < AbstractArtifact
return 0 if self.class == other.class
return 0 if instance_of?(other.class)
@@sort_order ||= [ # rubocop:disable Style/ClassVars
PreflightBlock,
......
......@@ -54,8 +54,7 @@ HOMEBREW_CACHE_FORMULA = (HOMEBREW_CACHE/"Formula").freeze
HOMEBREW_LOGS = Pathname.new(get_env_or_raise("HOMEBREW_LOGS")).expand_path.freeze
# Must use `/tmp` instead of `TMPDIR` because long paths break Unix domain sockets
HOMEBREW_TEMP = begin
tmp = Pathname.new(get_env_or_raise("HOMEBREW_TEMP"))
HOMEBREW_TEMP = Pathname.new(get_env_or_raise("HOMEBREW_TEMP")).yield_self do |tmp|
tmp.mkpath unless tmp.exist?
tmp.realpath
end.freeze
......@@ -218,8 +218,7 @@ module Formulary
end
def load_file(flags:)
if url =~ %r{githubusercontent.com/[\w-]+/[\w-]+/[a-f0-9]{40}(/Formula)?/([\w+-.@]+).rb}
formula_name = Regexp.last_match(2)
if %r{githubusercontent.com/[\w-]+/[\w-]+/[a-f0-9]{40}(?:/Formula)?/(?<formula_name>[\w+-.@]+).rb} =~ url # rubocop:disable Style/CaseLikeIf
odisabled "Installation of #{formula_name} from a GitHub commit URL",
"'brew extract #{formula_name}' to stable tap on GitHub"
elsif url.match?(%r{^(https?|ftp)://})
......@@ -232,8 +231,8 @@ module Formulary
curl_download url, to: path
super
rescue MethodDeprecatedError => e
if url =~ %r{github.com/([\w-]+)/([\w-]+)/}
e.issues_url = "https://github.com/#{Regexp.last_match(1)}/#{Regexp.last_match(2)}/issues/new"
if %r{github.com/(?<user>[\w-]+)/(?<repo>[\w-]+)/} =~ url
e.issues_url = "https://github.com/#{user}/#{repo}/issues/new"
end
raise
end
......
......@@ -395,7 +395,7 @@ module RuboCop
@offense_source_range = method_node.source_range
params.all? do |given_param|
method_params.any? do |method_param|
if given_param.class == Regexp
if given_param.instance_of?(Regexp)
regex_match_group(method_param, given_param)
else
node_equals?(method_param, given_param)
......
......@@ -79,9 +79,9 @@ module RuboCop
def audit_formula(_node, _class_node, _parent_class_node, body_node)
find_method_with_args(body_node, :uses_from_macos, /^"(.+)"/).each do |method|
dep = if parameters(method).first.class == RuboCop::AST::StrNode
dep = if parameters(method).first.instance_of?(RuboCop::AST::StrNode)
parameters(method).first
elsif parameters(method).first.class == RuboCop::AST::HashNode
elsif parameters(method).first.instance_of?(RuboCop::AST::HashNode)
parameters(method).first.keys.first
end
......
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