Class: RubomaticHtml::Cop::Style::PartialInstanceVariable

Inherits:
Base
  • Object
show all
Defined in:
lib/rubomatic-html/cop/style/partial_instance_variable.rb

Instance Attribute Summary

Attributes inherited from Base

#config, #file

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

department

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from RubomaticHtml::Cop::Base

Class Method Details

.abstract_cop?Boolean

Returns:

  • (Boolean)

See Also:

  • super


9
10
11
# File 'lib/rubomatic-html/cop/style/partial_instance_variable.rb', line 9

def abstract_cop?
  false
end

.allowed_config_transformObject

See Also:

  • super


19
20
21
# File 'lib/rubomatic-html/cop/style/partial_instance_variable.rb', line 19

def allowed_config_transform
  super.merge({ 'AllowedIdentifiers' => :allowed_identifiers }).freeze
end

.nameObject

See Also:

  • super


14
15
16
# File 'lib/rubomatic-html/cop/style/partial_instance_variable.rb', line 14

def name
  [department, 'PartialInstanceVariable'].join('/')
end

Instance Method Details

#run_for_line(line, index) ⇒ Object

See Also:

  • super


25
26
27
28
29
30
31
32
33
# File 'lib/rubomatic-html/cop/style/partial_instance_variable.rb', line 25

def run_for_line(line, index)
  return unless File.basename(file).match?(/^_/i)

  return unless line.match?(/@/i)

  return if allowed_identifiers.any? { |ai| line[/@.+/].start_with?(ai) }

  puts("#{file}:#{index}: uses an instance variable")
end