Class: RuboCop::TodoAudit Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/todo_audit.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Audits .rubocop_todo.yml for Exclude entries that are no longer needed: files a cop would not flag anymore, or files that no longer exist. Used by the --report-unused-todo-entries option.

Defined Under Namespace

Classes: Entry

Instance Method Summary collapse

Constructor Details

#initialize(config_store, options) ⇒ TodoAudit

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of TodoAudit.



11
12
13
14
# File 'lib/rubocop/todo_audit.rb', line 11

def initialize(config_store, options)
  @config_store = config_store
  @options = options
end

Instance Method Details

#todo_fileObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



28
29
30
# File 'lib/rubocop/todo_audit.rb', line 28

def todo_file
  CLI::Command::AutoGenerateConfig::AUTO_GENERATED_FILE
end

#unused_entriesArray<Entry>?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the unused entries, or nil when there is no todo file to audit.

Returns:

  • (Array<Entry>, nil)

    the unused entries, or nil when there is no todo file to audit



18
19
20
21
22
23
24
25
26
# File 'lib/rubocop/todo_audit.rb', line 18

def unused_entries
  return nil unless todo_path

  entries = todo_exclude_entries
  return [] if entries.empty?

  offending_cops = offending_cops_without_todo(entries)
  entries.reject { |entry| offending_cops[absolute(entry.path)]&.include?(entry.cop_name) }
end