Skip to content

Commit 4379446

Browse files
committed
Run rubocop lint
1 parent 837dba1 commit 4379446

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

lib/erblint-github/linters/github/accessibility/avoid_generic_link_text_counter.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ class AvoidGenericLinkTextCounter < Linter
2222
def run(processed_source)
2323
processed_source.ast.children.each_with_index do |node, index|
2424
next unless node.methods.include?(:type) && node.type == :text
25+
2526
text = node.children.join.strip
2627
# Checks HTML tags
2728
if banned_text?(text)
28-
prev_node = processed_source.ast.children[index-1]
29-
next_node = processed_source.ast.children[index+1]
30-
29+
prev_node = processed_source.ast.children[index - 1]
30+
next_node = processed_source.ast.children[index + 1]
31+
3132
next unless tag_type?(prev_node) && tag_type?(next_node)
32-
33+
3334
text_node_tag = BetterHtml::Tree::Tag.from_node(node)
3435
prev_node_tag = BetterHtml::Tree::Tag.from_node(prev_node)
3536
next_node_tag = BetterHtml::Tree::Tag.from_node(next_node)
@@ -41,23 +42,22 @@ def run(processed_source)
4142
generate_offense_from_source_range(self.class, source_range)
4243
end
4344
end
44-
45+
4546
# Checks Rails link helpers like `link_to`
4647
erb_node = node.type == :erb ? node : node.descendants(:erb).first
4748
next unless erb_node
49+
4850
_, _, code_node = *erb_node
4951
source = code_node.loc.source
5052
ruby_node = extract_ruby_node(source)
5153
send_node = ruby_node&.descendants(:send)&.first
52-
if send_node.methods.include?(:method_name) && send_node.method_name == :link_to
53-
send_node.child_nodes.each do |child_node|
54-
if child_node.methods.include?(:type) && child_node.type == :str
55-
if banned_text?(child_node.children.join)
56-
tag = BetterHtml::Tree::Tag.from_node(code_node)
57-
generate_offense(self.class, processed_source, tag)
58-
end
54+
next unless send_node.methods.include?(:method_name) && send_node.method_name == :link_to
55+
56+
send_node.child_nodes.each do |child_node|
57+
if child_node.methods.include?(:type) && child_node.type == :str && banned_text?(child_node.children.join)
58+
tag = BetterHtml::Tree::Tag.from_node(code_node)
59+
generate_offense(self.class, processed_source, tag)
5960
end
60-
end
6161
end
6262
end
6363
counter_correct?(processed_source)
@@ -82,7 +82,7 @@ def autocorrect(processed_source, offense)
8282
def banned_text?(text)
8383
BANNED_GENERIC_TEXT.map(&:downcase).include?(text.downcase)
8484
end
85-
85+
8686
def extract_ruby_node(source)
8787
BetterHtml::TestHelper::RubyNode.parse(source)
8888
rescue ::Parser::SyntaxError

0 commit comments

Comments
 (0)