Module: PmdTester::PmdTesterUtils
Overview
Some functions that that don’t belong in a specific class,
Constant Summary
Constants included from PmdTester
BASE, PATCH, PR_NUM_ENV_VAR, VERSION
Instance Method Summary collapse
-
#build_cpd_report_diff(base_report_file, patch_report_file, base_info, patch_info, impl_changed:) ⇒ Object
Parse the base and the patch CPD report, compute their diff Returns a
CpdReportDiff. -
#build_html_reports(projects, base_branch_details, patch_branch_details, filter_set, rules_changed:, impl_changed:) ⇒ Object
Build the diff reports and write them all.
-
#build_report_diff(base_report_file, patch_report_file, base_info, patch_info, filter_set = nil, rules_changed: true) ⇒ Object
Parse the base and the patch report, compute their diff Returns a
ReportDiff. -
#compute_project_diffs(projects, base_branch, patch_branch, filter_set, rules_changed:, impl_changed:) ⇒ Object
Fill the report_diff field of every project.
- #parse_cpd_report(report_file, branch, report_details) ⇒ Object
-
#parse_pmd_report(report_file, branch, report_details, filter_set = nil) ⇒ Object
Parse the
report_fileto produce aReport.
Methods included from PmdTester
Instance Method Details
#build_cpd_report_diff(base_report_file, patch_report_file, base_info, patch_info, impl_changed:) ⇒ Object
Parse the base and the patch CPD report, compute their diff Returns a CpdReportDiff
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/pmdtester/pmd_tester_utils.rb', line 41 def build_cpd_report_diff(base_report_file, patch_report_file, base_info, patch_info, impl_changed:) base_details = PmdReportDetail.load(base_info) base_report = parse_cpd_report(base_report_file, BASE, base_details) if impl_changed patch_details = PmdReportDetail.load(patch_info) patch_report = parse_cpd_report(patch_report_file, PATCH, patch_details) else patch_report = base_report end logger.info 'Calculating CPD diffs' CpdReportDiff.new(base_report: base_report, patch_report: patch_report) end |
#build_html_reports(projects, base_branch_details, patch_branch_details, filter_set, rules_changed:, impl_changed:) ⇒ Object
Build the diff reports and write them all
77 78 79 80 81 82 83 84 85 |
# File 'lib/pmdtester/pmd_tester_utils.rb', line 77 def build_html_reports(projects, base_branch_details, patch_branch_details, filter_set, rules_changed:, impl_changed:) compute_project_diffs(projects, base_branch_details.branch_name, patch_branch_details.branch_name, filter_set, rules_changed: rules_changed, impl_changed: impl_changed) SummaryReportBuilder.new.write_all_projects(projects, base_branch_details, patch_branch_details) end |
#build_report_diff(base_report_file, patch_report_file, base_info, patch_info, filter_set = nil, rules_changed: true) ⇒ Object
Parse the base and the patch report, compute their diff Returns a ReportDiff
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pmdtester/pmd_tester_utils.rb', line 10 def build_report_diff(base_report_file, patch_report_file, base_info, patch_info, filter_set = nil, rules_changed: true) base_details = PmdReportDetail.load(base_info) base_report = parse_pmd_report(base_report_file, BASE, base_details, filter_set) if rules_changed patch_details = PmdReportDetail.load(patch_info) patch_report = parse_pmd_report(patch_report_file, PATCH, patch_details) else patch_report = base_report end logger.info 'Calculating diffs' ReportDiff.new(base_report: base_report, patch_report: patch_report) end |
#compute_project_diffs(projects, base_branch, patch_branch, filter_set, rules_changed:, impl_changed:) ⇒ Object
Fill the report_diff field of every project
67 68 69 70 71 72 73 74 |
# File 'lib/pmdtester/pmd_tester_utils.rb', line 67 def compute_project_diffs(projects, base_branch, patch_branch, filter_set, rules_changed:, impl_changed:) projects.each do |project| logger.info "Preparing report for #{project.name}" logger.info " with filter #{filter_set}" unless filter_set.nil? project.compute_report_diff(base_branch, patch_branch, filter_set, rules_changed: rules_changed, impl_changed: impl_changed) end end |
#parse_cpd_report(report_file, branch, report_details) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/pmdtester/pmd_tester_utils.rb', line 56 def parse_cpd_report(report_file, branch, report_details) logger.info "Parsing CPD Report #{report_file}" doc = CpdReportDocument.new(branch, report_details.working_dir).parse(report_file) CpdReport.new( report_details: report_details, report_document: doc, file: report_file ) end |
#parse_pmd_report(report_file, branch, report_details, filter_set = nil) ⇒ Object
Parse the report_file to produce a Report. For the schema of xml reports, refer to pmd.github.io/schema/report_2_0_0.xsd
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/pmdtester/pmd_tester_utils.rb', line 28 def parse_pmd_report(report_file, branch, report_details, filter_set = nil) logger.info "Parsing PMD Report #{report_file}" doc = PmdReportDocument.new(branch, report_details.working_dir, filter_set) .parse(report_file) Report.new( report_details: report_details, report_document: doc, file: report_file ) end |