From bc2bcef1ba084e271ecdfd523a96e6db477e6475 Mon Sep 17 00:00:00 2001 From: Gautham Goli Date: Sun, 30 Jul 2017 20:14:59 +0530 Subject: audit: Port classname and template comments audit rules from line_problems method to rubocop --- Library/Homebrew/rubocops/extend/formula_cop.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Library/Homebrew/rubocops/extend') diff --git a/Library/Homebrew/rubocops/extend/formula_cop.rb b/Library/Homebrew/rubocops/extend/formula_cop.rb index 4be0c0fe3..e7a23ecae 100644 --- a/Library/Homebrew/rubocops/extend/formula_cop.rb +++ b/Library/Homebrew/rubocops/extend/formula_cop.rb @@ -302,6 +302,15 @@ module RuboCop end end + # Yields to a block with comment text as parameter + def audit_comments + @processed_source.comments.each do |comment_node| + @offensive_node = comment_node + @offense_source_range = :expression + yield comment_node.text + end + end + # Returns the begin position of the node's line in source code def line_start_column(node) node.source_range.source_buffer.line_range(node.loc.line).begin_pos @@ -312,6 +321,11 @@ module RuboCop node.source_range.begin_pos end + # Returns the ending position of the node in source code + def end_column(node) + node.source_range.end_pos + end + # Returns the line number of the node def line_number(node) node.loc.line -- cgit v1.2.3