Class: LinterChanges::Linter::RuboCop::Adapter
- Inherits:
-
Base
- Object
- Base
- LinterChanges::Linter::RuboCop::Adapter
show all
- Defined in:
- lib/linter/rubocop/adapter.rb
Constant Summary
collapse
- DEFAULT_CONFIG_FILES =
By default, anything containing rubocop on the file path will be consider a config file
[/rubocop/].freeze
- DEFAULT_COMMAND =
'bin/rubocop'.freeze
Instance Attribute Summary
Attributes inherited from Base
#name
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#config_changed?(changed_files) ⇒ Boolean
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/linter/rubocop/adapter.rb', line 33
def config_changed?(changed_files)
return true if super
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_files ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/linter/rubocop/adapter.rb', line 11
def list_target_files
cmd = "#{DEFAULT_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
|
#run(files: []) ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'lib/linter/rubocop/adapter.rb', line 24
def run(files: [])
cmd = if files.empty?
@command
else
"#{@command} #{files.join(' ')}"
end
execute_linter(cmd)
end
|