Class: Collie::Linter::Rules::ConsistentTagNaming

Inherits:
Base
  • Object
show all
Defined in:
lib/collie/linter/rules/consistent_tag_naming.rb

Overview

Detects inconsistent type tag naming

Instance Method Summary collapse

Methods inherited from Base

#autocorrectable?, #initialize

Constructor Details

This class inherits a constructor from Collie::Linter::Base

Instance Method Details

#check(ast, _context = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/collie/linter/rules/consistent_tag_naming.rb', line 13

def check(ast, _context = {})
  tags = collect_type_tags(ast)
  return @offenses if tags.size < 2

  styles = tags.group_by { |tag, _| detect_style(tag) }

  # If we have multiple styles, report inconsistency
  add_inconsistency_offense(ast, styles) if styles.size > 1

  @offenses
end