22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/cli.rb', line 22
def lint
Logger.debug_mode = options[:debug]
git_diff = GitDiff.new(target_branch: options[:target_branch])
changed_files = git_diff.changed_files
linters = select_linters git_diff
overall_success = true
linters.each do |linter|
Logger.debug "Running #{linter.name.capitalize} linter"
if linter.config_changed?(changed_files)
Logger.debug "#{linter.name.capitalize} configuration changed. Running linter globally."
success = linter.run
else
files_to_lint = linter.list_target_files & changed_files
if files_to_lint.empty?
Logger.debug "No files to lint for #{linter.name.capitalize}."
next
else
Logger.debug "Linting files with #{linter.name.capitalize}: #{files_to_lint.join(', ')}"
success = linter.run(files: files_to_lint)
end
end
overall_success &&= success
end
exit(overall_success ? 0 : 1)
end
|