custom comment generation for script/tatl_tael, refs SD-2295

test plan:
* tatl_tael still works (see test commits)

Change-Id: I1854693bd665f4018d1f0475dc922ac360b8d8d8
Reviewed-on: https://gerrit.instructure.com/109783
Tested-by: Jenkins
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
This commit is contained in:
Landon Wilkins 2017-04-26 01:03:28 -06:00
parent 2490de04d7
commit c83a8e8aa0
4 changed files with 15 additions and 8 deletions

View File

@ -53,7 +53,7 @@ module TatlTael
underscore_and_symbolize_keys(config[base_config_key])
end
def comments(changes)
def comments(changes:)
@comments ||= linters.map do |linter_class|
linter_class.new(config: config_for_linter(linter_class), changes: changes).run
end.flatten.compact

View File

@ -155,7 +155,7 @@ describe TatlTael::Linters do
it "collects linter comments" do
expect(linters).to receive(:linters).and_return(saved_linters)
expect(linters.comments(changes)).to match(%w[1 2 3])
expect(linters.comments(changes: changes)).to match(%w[1 2 3])
end
end
end

View File

@ -8,9 +8,10 @@ class Linter
boyscout_mode: true,
campsite_mode: true,
comment_post_processing: proc { |comments| comments },
custom_comment_generation: false,
env_sha: ENV['SHA'] || ENV['GERRIT_PATCHSET_REVISION'],
file_regex: /./,
gergich_capture: true,
generate_comment_proc: proc { },
gerrit_patchset: !!ENV['GERRIT_PATCHSET_REVISION'],
heavy_mode: false,
heavy_mode_proc: proc {},
@ -57,15 +58,18 @@ class Linter
private
# TODO: generate from DEFAULT_OPTIONS
attr_reader :append_files_to_command,
:boyscout_mode,
:campsite_mode,
:command,
:comment_post_processing,
:default_boyscout_mode,
:custom_comment_generation,
:env_sha,
:file_regex,
:format,
:generate_comment_proc,
:gergich_capture,
:gerrit_patchset,
:heavy_mode,
@ -117,10 +121,10 @@ class Linter
end
def generate_comments
if gergich_capture
comments
if custom_comment_generation
generate_comment_proc.call(changes: changes)
else
TatlTael::Linters.comments(changes)
comments
end
end

View File

@ -6,8 +6,11 @@ require_relative "./linter"
linter_options = {
linter_name: "tatl_tael",
skip_file_size_check: true,
skip_wips: true,
gergich_capture: false
skip_wips: false,
custom_comment_generation: true,
generate_comment_proc: proc do |config|
TatlTael::Linters.comments(config)
end
}
user_config_file = File.expand_path("../../gems/dr_diff/config/gergich_user_config.yml", __FILE__)