Class: PmdTester::LiquidProjectRenderer
- Inherits:
-
Object
- Object
- PmdTester::LiquidProjectRenderer
- Includes:
- PmdTester, LiquidRenderer, ProjectHasher
- Defined in:
- lib/pmdtester/builders/liquid_renderer.rb
Overview
Renders the index of a project diff report.
Constant Summary
Constants included from PmdTester
BASE, PATCH, PR_NUM_ENV_VAR, VERSION
Instance Method Summary collapse
- #dump_violations_json(project, branch = 'diff') ⇒ Object
- #write_project_index(project, root) ⇒ Object
Methods included from LiquidRenderer
#copy_resource, #render_and_write, #render_liquid, #write_file
Methods included from PmdTester
Methods included from ProjectHasher
#change_type, #configerror_to_hash, #configerrors_to_h, #error_to_hash, #errors_to_h, #link_template, #report_diff_to_h, #sanitize_stacktrace, #violations_to_hash
Instance Method Details
#dump_violations_json(project, branch = 'diff') ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/pmdtester/builders/liquid_renderer.rb', line 77 def dump_violations_json(project, branch = 'diff') violations_by_file = if branch == BASE project.report_diff.base_report.violations_by_file.to_h elsif branch == PATCH project.report_diff.patch_report.violations_by_file.to_h else project.report_diff.violation_diffs_by_file end h = { 'source_link_base' => project.webview_url, 'source_link_template' => link_template(project), **violations_to_hash(project, violations_by_file, branch == 'diff') } project_data = JSON.fast_generate(h, indent: ' ', object_nl: "\n", array_nl: "\n") "let project = #{project_data}" end |
#write_project_index(project, root) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/pmdtester/builders/liquid_renderer.rb', line 48 def write_project_index(project, root) liquid_env = { 'diff' => report_diff_to_h(project.report_diff), 'error_diffs' => errors_to_h(project), 'configerror_diffs' => configerrors_to_h(project), 'project_name' => project.name } # Renders index.html using liquid write_file("#{root}/index.html", render_liquid('project_diff_report.html', liquid_env)) # generate array of violations in json write_file("#{root}/project_data.js", dump_violations_json(project)) # copy original pmd reports copy_file("#{root}/base_pmd_report.xml", project.report_diff.base_report.file) copy_file("#{root}/patch_pmd_report.xml", project.report_diff.patch_report.file) # copy stdout and stderr outputs copy_file("#{root}/base_stdout.txt", "#{project.report_diff.base_report.report_folder}/stdout.txt") copy_file("#{root}/base_stderr.txt", "#{project.report_diff.base_report.report_folder}/stderr.txt") copy_file("#{root}/patch_stdout.txt", "#{project.report_diff.patch_report.report_folder}/stdout.txt") copy_file("#{root}/patch_stderr.txt", "#{project.report_diff.patch_report.report_folder}/stderr.txt") # render full pmd reports write_file("#{root}/base_pmd_report.html", render_liquid('project_pmd_report.html', pmd_report_liquid_env(project, BASE))) write_file("#{root}/base_data.js", dump_violations_json(project, BASE)) write_file("#{root}/patch_pmd_report.html", render_liquid('project_pmd_report.html', pmd_report_liquid_env(project, PATCH))) write_file("#{root}/patch_data.js", dump_violations_json(project, PATCH)) end |