Class: PDK::Validate::Rubocop
Constant Summary
collapse
- ALLOW_EMPTY_TARGETS =
true
BaseValidator::IGNORE_DOTFILES, BaseValidator::INVOKE_STYLE
Class Method Summary
collapse
allow_empty_targets?, cmd_path, ignore_dotfiles?, ignore_pathspec, invoke, parse_targets, process_invalid, process_skipped
Class Method Details
.cmd ⇒ Object
12
13
14
|
# File 'lib/pdk/validate/ruby/rubocop.rb', line 12
def self.cmd
'rubocop'
end
|
.name ⇒ Object
8
9
10
|
# File 'lib/pdk/validate/ruby/rubocop.rb', line 8
def self.name
'rubocop'
end
|
.parse_options(options, targets) ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'lib/pdk/validate/ruby/rubocop.rb', line 24
def self.parse_options(options, targets)
cmd_options = ['--format', 'json']
if options[:auto_correct]
cmd_options << '--auto-correct'
end
cmd_options.concat(targets)
end
|
.parse_output(report, result, _targets) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/pdk/validate/ruby/rubocop.rb', line 34
def self.parse_output(report, result, _targets)
return if result[:stdout].empty?
begin
json_data = JSON.parse(result[:stdout])
rescue JSON::ParserError
raise PDK::Validate::ParseOutputError, result[:stdout]
end
return unless json_data.key?('files')
json_data['files'].each do |file_info|
next unless file_info.key?('offenses')
result = {
file: file_info['path'],
source: 'rubocop',
}
if file_info['offenses'].empty?
report.add_event(result.merge(state: :passed, severity: :ok))
else
file_info['offenses'].each do |offense|
report.add_event(
result.merge(
line: offense['location']['line'],
column: offense['location']['column'],
message: offense['message'],
severity: offense['corrected'] ? 'corrected' : offense['severity'],
test: offense['cop_name'],
state: :failure,
),
)
end
end
end
end
|
.pattern ⇒ Object
16
17
18
|
# File 'lib/pdk/validate/ruby/rubocop.rb', line 16
def self.pattern
'**/**.rb'
end
|
.spinner_text(_targets = nil) ⇒ Object
20
21
22
|
# File 'lib/pdk/validate/ruby/rubocop.rb', line 20
def self.spinner_text(_targets = nil)
_('Checking Ruby code style (%{pattern}).') % { pattern: pattern }
end
|