aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/rubocops
diff options
context:
space:
mode:
authorMarkus Reiter2017-10-21 03:12:50 +0200
committerMarkus Reiter2017-10-24 19:39:40 +0200
commit7e970216a341c7ed4ff82114247bf33cafdd3266 (patch)
tree4da040488227cfe019ce1d51ce311ea70a719f82 /Library/Homebrew/rubocops
parentfd29511bae8ba381c72bbdc7effd842fc46b0fac (diff)
downloadbrew-7e970216a341c7ed4ff82114247bf33cafdd3266.tar.bz2
Refactor and fix RuboCop specs.
Diffstat (limited to 'Library/Homebrew/rubocops')
-rw-r--r--Library/Homebrew/rubocops/checksum_cop.rb1
-rw-r--r--Library/Homebrew/rubocops/conflicts_cop.rb6
-rw-r--r--Library/Homebrew/rubocops/extend/formula_cop.rb4
-rw-r--r--Library/Homebrew/rubocops/formula_desc_cop.rb6
-rw-r--r--Library/Homebrew/rubocops/lines_cop.rb26
5 files changed, 19 insertions, 24 deletions
diff --git a/Library/Homebrew/rubocops/checksum_cop.rb b/Library/Homebrew/rubocops/checksum_cop.rb
index dcaf60e7d..23a787809 100644
--- a/Library/Homebrew/rubocops/checksum_cop.rb
+++ b/Library/Homebrew/rubocops/checksum_cop.rb
@@ -24,6 +24,7 @@ module RuboCop
def audit_sha256(checksum)
return if checksum.nil?
if regex_match_group(checksum, /^$/)
+ @offense_source_range = @offensive_node.source_range
problem "sha256 is empty"
return
end
diff --git a/Library/Homebrew/rubocops/conflicts_cop.rb b/Library/Homebrew/rubocops/conflicts_cop.rb
index 1cca3f8ae..96edf480c 100644
--- a/Library/Homebrew/rubocops/conflicts_cop.rb
+++ b/Library/Homebrew/rubocops/conflicts_cop.rb
@@ -6,10 +6,8 @@ module RuboCop
module FormulaAudit
# This cop audits versioned Formulae for `conflicts_with`
class Conflicts < FormulaCop
- MSG = <<~EOS.freeze
- Versioned formulae should not use `conflicts_with`.
- Use `keg_only :versioned_formula` instead.
- EOS
+ MSG = "Versioned formulae should not use `conflicts_with`. " \
+ "Use `keg_only :versioned_formula` instead.".freeze
WHITELIST = %w[
node@
diff --git a/Library/Homebrew/rubocops/extend/formula_cop.rb b/Library/Homebrew/rubocops/extend/formula_cop.rb
index 7da4d0f10..2e9a7657e 100644
--- a/Library/Homebrew/rubocops/extend/formula_cop.rb
+++ b/Library/Homebrew/rubocops/extend/formula_cop.rb
@@ -186,11 +186,11 @@ module RuboCop
end
def_node_search :required_dependency?, <<~EOS
- (send nil :depends_on ({str sym} _))
+ (send nil? :depends_on ({str sym} _))
EOS
def_node_search :required_dependency_name?, <<~EOS
- (send nil :depends_on ({str sym} %1))
+ (send nil? :depends_on ({str sym} %1))
EOS
def_node_search :dependency_type_hash_match?, <<~EOS
diff --git a/Library/Homebrew/rubocops/formula_desc_cop.rb b/Library/Homebrew/rubocops/formula_desc_cop.rb
index 05f60c9d5..e56a4cc56 100644
--- a/Library/Homebrew/rubocops/formula_desc_cop.rb
+++ b/Library/Homebrew/rubocops/formula_desc_cop.rb
@@ -29,10 +29,8 @@ module RuboCop
desc_length = "#{@formula_name}: #{string_content(desc)}".length
max_desc_length = 80
return if desc_length <= max_desc_length
- problem <<~EOS
- Description is too long. "name: desc" should be less than #{max_desc_length} characters.
- Length is calculated as #{@formula_name} + desc. (currently #{desc_length})
- EOS
+ problem "Description is too long. \"name: desc\" should be less than #{max_desc_length} characters. " \
+ "Length is calculated as #{@formula_name} + desc. (currently #{desc_length})"
end
end
diff --git a/Library/Homebrew/rubocops/lines_cop.rb b/Library/Homebrew/rubocops/lines_cop.rb
index 9354f41f6..9c6c97b13 100644
--- a/Library/Homebrew/rubocops/lines_cop.rb
+++ b/Library/Homebrew/rubocops/lines_cop.rb
@@ -8,11 +8,11 @@ module RuboCop
def audit_formula(_node, _class_node, _parent_class_node, _body_node)
[:automake, :autoconf, :libtool].each do |dependency|
next unless depends_on?(dependency)
- problem ":#{dependency} is deprecated. Usage should be \"#{dependency}\""
+ problem ":#{dependency} is deprecated. Usage should be \"#{dependency}\"."
end
- problem ':apr is deprecated. Usage should be "apr-util"' if depends_on?(:apr)
- problem ":tex is deprecated" if depends_on?(:tex)
+ problem ':apr is deprecated. Usage should be "apr-util".' if depends_on?(:apr)
+ problem ":tex is deprecated." if depends_on?(:tex)
end
end
@@ -296,10 +296,8 @@ module RuboCop
end
find_method_with_args(body_node, :skip_clean, :all) do
- problem <<~EOS.chomp
- `skip_clean :all` is deprecated; brew no longer strips symbols
- Pass explicit paths to prevent Homebrew from removing empty folders.
- EOS
+ problem "`skip_clean :all` is deprecated; brew no longer strips symbols. " \
+ "Pass explicit paths to prevent Homebrew from removing empty folders."
end
if find_method_def(@processed_source.ast)
@@ -353,11 +351,11 @@ module RuboCop
end
def_node_search :conditional_dependencies, <<~EOS
- {$(if (send (send nil :build) ${:include? :with? :without?} $(str _))
- (send nil :depends_on $({str sym} _)) nil)
+ {$(if (send (send nil? :build) ${:include? :with? :without?} $(str _))
+ (send nil? :depends_on $({str sym} _)) nil?)
- $(if (send (send nil :build) ${:include? :with? :without?} $(str _)) nil
- (send nil :depends_on $({str sym} _)))}
+ $(if (send (send nil? :build) ${:include? :with? :without?} $(str _)) nil?
+ (send nil? :depends_on $({str sym} _)))}
EOS
# Match depends_on with hash as argument
@@ -371,13 +369,13 @@ module RuboCop
EOS
def_node_search :formula_path_strings, <<~EOS
- {(dstr (begin (send nil %1)) $(str _ ))
- (dstr _ (begin (send nil %1)) $(str _ ))}
+ {(dstr (begin (send nil? %1)) $(str _ ))
+ (dstr _ (begin (send nil? %1)) $(str _ ))}
EOS
# Node Pattern search for Language::Node
def_node_search :languageNodeModule?, <<~EOS
- (const (const nil :Language) :Node)
+ (const (const nil? :Language) :Node)
EOS
end
end