def postprocess_result(self, skip_handler: Optional[SkipListHandler]): """ Generate analyzer result output file which can be parsed and stored into the database. """ LOG.debug_analyzer(self.analyzer_stdout) tidy_stdout = self.analyzer_stdout.splitlines() reports = Parser().get_reports_from_iter(tidy_stdout) reports = [r for r in reports if not r.skip(skip_handler)] # In the earlier versions of CodeChecker Clang Tidy never used context # free hash even if we enabled it with '--report-hash context-free' # when calling the analyze command. To do not break every hash # automatically when using this option we introduced a new choice for # --report-hash option ('context-free-v2') and we still do not use # context free hash for 'context-free' choice. hash_type = HashType.PATH_SENSITIVE if self.report_hash_type == 'context-free-v2': hash_type = HashType.CONTEXT_FREE elif self.report_hash_type == 'diagnostic-message': hash_type = HashType.DIAGNOSTIC_MESSAGE for report in reports: report.report_hash = get_report_hash(report, hash_type) report_file.create(self.analyzer_result_file, reports, self.checker_labels, self.analyzer_info)
def test_html_output_for_empty_plist(self): """ Test that HTML files for empty plist files will not be generated. """ with tempfile.TemporaryDirectory() as tmp_dir: plist_file_name = 'empty.plist' plist_file_path = os.path.join(tmp_dir, plist_file_name) report_file.create(plist_file_path, []) test_project_notes = os.path.join(self.test_workspaces['NORMAL'], "test_files", "notes", "notes.plist") shutil.copy(test_project_notes, tmp_dir) output_path = os.path.join(tmp_dir, 'html') extract_cmd = [ 'CodeChecker', 'parse', '-e', 'html', '-o', output_path, tmp_dir ] out, err, result = call_command(extract_cmd, cwd=self.test_dir, env=self.env) self.assertEqual(result, 2) self.assertFalse(err) self.assertTrue(f'No report data in {plist_file_path}' in out) self.assertTrue(f'Html file was generated:' in out) self.assertTrue('Summary' in out) self.assertTrue('statistics.html' in out) self.assertTrue('index.html' in out) self.assertTrue( os.path.exists(os.path.join(output_path, 'index.html'))) self.assertTrue( os.path.exists(os.path.join(output_path, 'statistics.html'))) self.assertTrue( os.path.exists(os.path.join(output_path, 'notes.plist.html'))) self.assertFalse( os.path.exists( os.path.join(output_path, f'{plist_file_name}.html')))
def postprocess_result(self, skip_handler: Optional[SkipListHandler]): """ Generate analyzer result output file which can be parsed and stored into the database. """ if os.path.exists(self.analyzer_result_file): reports = report_file.get_reports(self.analyzer_result_file, self.checker_labels) reports = [r for r in reports if not r.skip(skip_handler)] hash_type = None if self.report_hash_type in ['context-free', 'context-free-v2']: hash_type = HashType.CONTEXT_FREE elif self.report_hash_type == 'diagnostic-message': hash_type = HashType.DIAGNOSTIC_MESSAGE if hash_type is not None: for report in reports: report.report_hash = get_report_hash(report, hash_type) report_file.create(self.analyzer_result_file, reports, self.checker_labels, self.analyzer_info)