Class: RubocopTodoCorrector::IgnoreFile

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop_todo_corrector/ignore_file.rb

Instance Method Summary collapse

Constructor Details

#initialize(path:) ⇒ IgnoreFile

Returns a new instance of IgnoreFile.

Parameters:

  • path (String)


8
9
10
# File 'lib/rubocop_todo_corrector/ignore_file.rb', line 8

def initialize(path:)
  @path = path
end

Instance Method Details

#append_cop_name(cop_name) ⇒ Object

Parameters:

  • cop_name (String)


13
14
15
16
17
18
19
# File 'lib/rubocop_todo_corrector/ignore_file.rb', line 13

def append_cop_name(cop_name)
  return if include?(cop_name)

  appendix = "#{cop_name}\n"
  appendix.prepend("\n") if !content.empty? && !content.end_with?("\n")
  pathname.write("#{content}#{appendix}")
end

#ignored_cop_namesArray<String>

Returns:

  • (Array<String>)


22
23
24
25
26
# File 'lib/rubocop_todo_corrector/ignore_file.rb', line 22

def ignored_cop_names
  content.split("\n").map do |line|
    line.sub(/#.+/, '').strip
  end.reject(&:empty?)
end