Module: RuboCop::Cop::ProjectIndexHelp

Included in:
Lint::ConstantReassignment
Defined in:
lib/rubocop/cop/mixin/project_index_help.rb

Overview

Common helpers for cops that consult the project-wide static-analysis index via Cop::Base#project_index.

Mixed-in cops gain the external_dependency_checksum override that invalidates the ResultCache whenever the indexed project files change on disk. To run index-backed analysis, cops should simply check whether project_index is non-nil; the runner only exposes a non-nil index when the user opted in via AllCops/UseProjectIndex and the underlying gem is available.

Constant Summary collapse

BUILTIN_DOCUMENT_URI =
'rubydex:built-in'
FILE_URI_PREFIX =
'file://'
WINDOWS_DRIVE_PREFIX =

Matches the spurious leading slash before a Windows drive letter that remains after stripping file:// from a file:///C:/... URI.

%r{\A/(?=[A-Za-z]:[/\\])}.freeze

Instance Method Summary collapse

Instance Method Details

#external_dependency_checksumObject



20
21
22
23
24
25
26
# File 'lib/rubocop/cop/mixin/project_index_help.rb', line 20

def external_dependency_checksum
  return nil unless project_index

  @external_dependency_checksum ||= Digest::SHA1.hexdigest(
    project_index_signature.join("\n")
  )
end