Merge pull request #3633 from MikeMcQuaid/lines_cop_version
lines_cop: flag `depends_on :perl => "1.0"`.
This commit is contained in:
commit
09bfb2a8f0
@ -70,6 +70,7 @@ module Homebrew
|
|||||||
def check_style_impl(files, output_type, options = {})
|
def check_style_impl(files, output_type, options = {})
|
||||||
fix = options[:fix]
|
fix = options[:fix]
|
||||||
|
|
||||||
|
Homebrew.install_gem_setup_path! "parser", HOMEBREW_RUBOCOP_PARSER_VERSION, "ruby-parse"
|
||||||
Homebrew.install_gem_setup_path! "rubocop", HOMEBREW_RUBOCOP_VERSION
|
Homebrew.install_gem_setup_path! "rubocop", HOMEBREW_RUBOCOP_VERSION
|
||||||
require "rubocop"
|
require "rubocop"
|
||||||
require_relative "../rubocops"
|
require_relative "../rubocops"
|
||||||
|
|||||||
@ -2,4 +2,5 @@
|
|||||||
|
|
||||||
# RuboCop version used for `brew style` and `brew cask style`
|
# RuboCop version used for `brew style` and `brew cask style`
|
||||||
HOMEBREW_RUBOCOP_VERSION = "0.51.0"
|
HOMEBREW_RUBOCOP_VERSION = "0.51.0"
|
||||||
|
HOMEBREW_RUBOCOP_PARSER_VERSION = "2.4.0.0" # for Ruby 2.3.3
|
||||||
HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.15.1" # has to be updated when RuboCop version changes
|
HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.15.1" # has to be updated when RuboCop version changes
|
||||||
|
|||||||
@ -146,7 +146,7 @@ module RuboCop
|
|||||||
# Returns nil if does not depend on dependency_name
|
# Returns nil if does not depend on dependency_name
|
||||||
# args: node - dependency_name - dependency's name
|
# args: node - dependency_name - dependency's name
|
||||||
def depends_on?(dependency_name, *types)
|
def depends_on?(dependency_name, *types)
|
||||||
types = [:required, :build, :optional, :recommended, :run] if types.empty?
|
types = [:any] if types.empty?
|
||||||
dependency_nodes = find_every_method_call_by_name(@body, :depends_on)
|
dependency_nodes = find_every_method_call_by_name(@body, :depends_on)
|
||||||
idx = dependency_nodes.index do |n|
|
idx = dependency_nodes.index do |n|
|
||||||
types.any? { |type| depends_on_name_type?(n, dependency_name, type) }
|
types.any? { |type| depends_on_name_type?(n, dependency_name, type) }
|
||||||
@ -168,14 +168,14 @@ module RuboCop
|
|||||||
case type
|
case type
|
||||||
when :required
|
when :required
|
||||||
type_match = required_dependency?(node)
|
type_match = required_dependency?(node)
|
||||||
if type_match && !name_match
|
name_match ||= required_dependency_name?(node, name) if type_match
|
||||||
name_match = required_dependency_name?(node, name)
|
|
||||||
end
|
|
||||||
when :build, :optional, :recommended, :run
|
when :build, :optional, :recommended, :run
|
||||||
type_match = dependency_type_hash_match?(node, type)
|
type_match = dependency_type_hash_match?(node, type)
|
||||||
if type_match && !name_match
|
name_match ||= dependency_name_hash_match?(node, name) if type_match
|
||||||
name_match = dependency_name_hash_match?(node, name)
|
when :any
|
||||||
end
|
type_match = true
|
||||||
|
name_match ||= required_dependency_name?(node, name)
|
||||||
|
name_match ||= dependency_name_hash_match?(node, name)
|
||||||
else
|
else
|
||||||
type_match = false
|
type_match = false
|
||||||
end
|
end
|
||||||
@ -214,7 +214,7 @@ module RuboCop
|
|||||||
EOS
|
EOS
|
||||||
|
|
||||||
def_node_search :dependency_name_hash_match?, <<~EOS
|
def_node_search :dependency_name_hash_match?, <<~EOS
|
||||||
(hash (pair ({str sym} %1) ({str sym} _)))
|
(hash (pair ({str sym} %1) ({str sym array} _)))
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
# To compare node with appropriate Ruby variable
|
# To compare node with appropriate Ruby variable
|
||||||
@ -467,7 +467,7 @@ module RuboCop
|
|||||||
end
|
end
|
||||||
|
|
||||||
def problem(msg)
|
def problem(msg)
|
||||||
add_offense(@offensive_node, @offense_source_range, msg)
|
add_offense(@offensive_node, location: @offense_source_range, message: msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@ -3,6 +3,7 @@ source "https://rubygems.org"
|
|||||||
require_relative "../constants"
|
require_relative "../constants"
|
||||||
|
|
||||||
gem "parallel_tests"
|
gem "parallel_tests"
|
||||||
|
gem "parser", HOMEBREW_RUBOCOP_PARSER_VERSION
|
||||||
gem "rspec"
|
gem "rspec"
|
||||||
gem "rspec-its", require: false
|
gem "rspec-its", require: false
|
||||||
gem "rspec-wait", require: false
|
gem "rspec-wait", require: false
|
||||||
|
|||||||
@ -58,6 +58,7 @@ PLATFORMS
|
|||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
codecov
|
codecov
|
||||||
parallel_tests
|
parallel_tests
|
||||||
|
parser (= 2.4.0.0)
|
||||||
rspec
|
rspec
|
||||||
rspec-its
|
rspec-its
|
||||||
rspec-wait
|
rspec-wait
|
||||||
@ -65,4 +66,4 @@ DEPENDENCIES
|
|||||||
simplecov
|
simplecov
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.15.4
|
1.16.0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user