Class: LinterChanges::Linter::RuboCop::Adapter

Inherits:
Base
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/linter_changes/linter/rubocop/adapter.rb

Instance Attribute Summary

Attributes inherited from Base

#name

Instance Method Summary collapse

Methods inherited from Base

#changed_files, #initialize, #run

Constructor Details

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

Instance Method Details

#config_changed?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/linter_changes/linter/rubocop/adapter.rb', line 24

def config_changed?
  # Check if any of the config files have changed
  return true if super

  # TODO: get the location of Gemfile.lock with bundle command
  # Check if Gemfile.lock has changed and contains something related to rubocop
  if changed_files.include?('Gemfile.lock') && @git_diff.changed_lines_contains?(file: 'Gemfile.lock',
                                                                                 pattern: 'rubocop')
    Logger.debug 'Something related to rubocop gem version changed in Gemfile.lock'
    return true
  end
  false
end

#list_target_filesObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/linter_changes/linter/rubocop/adapter.rb', line 10

def list_target_files
  cmd = "#{@base_command} --list-target-files"
  Logger.debug "Executing command: #{cmd}"

  stdout, stderr, status = Open3.capture3(cmd)
  unless status.success?
    Logger.error "Error listing RuboCop target files: #{stderr}"
    exit 1
  end

  stdout.strip.split("\n")
end