diff --git a/Makefile b/Makefile index a4bf97a7b..99ca3595b 100644 --- a/Makefile +++ b/Makefile @@ -694,8 +694,6 @@ endif $(INSTALL_DATA) -C \{\} '$(DESTDIR)$(libdir)'/infer/\{\} $(INSTALL_PROGRAM) -C infer/lib/python/inferTraceBugs \ '$(DESTDIR)$(libdir)'/infer/infer/lib/python/inferTraceBugs - $(INSTALL_PROGRAM) -C infer/lib/python/report.py \ - '$(DESTDIR)$(libdir)'/infer/infer/lib/python/report.py $(INSTALL_PROGRAM) -C '$(INFER_BIN)' '$(DESTDIR)$(libdir)'/infer/infer/bin/ (cd '$(DESTDIR)$(bindir)/' && \ $(REMOVE) infer && \ diff --git a/infer/lib/python/inferlib/issues.py b/infer/lib/python/inferlib/issues.py index 3b37e6246..972544671 100644 --- a/infer/lib/python/inferlib/issues.py +++ b/infer/lib/python/inferlib/issues.py @@ -176,77 +176,3 @@ def _text_of_report_list(project_root, reports, bugs_txt_path, limit=None, utils.stdout(summary) return bug_list + summary - - -def _get_censored_reason(report): - return report.get(JSON_INDEX_CENSORED_REASON) - -def _is_user_visible(report): - if _get_censored_reason(report) is not None: - return False - else: - return report[JSON_INDEX_SEVERITY] in [ - ISSUE_SEVERITY_ERROR, - ISSUE_SEVERITY_WARNING, - ISSUE_SEVERITY_ADVICE, - ISSUE_SEVERITY_LIKE] - - -def print_and_save_errors(infer_out, project_root, json_report, bugs_out, - pmd_xml, console_out): - if pmd_xml: - errors = utils.load_json_from_path(json_report) - errors = [e for e in errors if _is_user_visible(e)] - xml_out = os.path.join(infer_out, config.PMD_XML_FILENAME) - with codecs.open(xml_out, 'w', - encoding=config.CODESET, - errors='replace') as file_out: - file_out.write(_pmd_xml_of_issues(errors)) - - -def _pmd_xml_of_issues(issues): - if etree is None: - print('ERROR: "lxml" Python package not found.') - print('ERROR: You need to install it to use Infer with --pmd-xml') - sys.exit(1) - root = etree.Element('pmd') - root.attrib['version'] = '5.4.1' - root.attrib['date'] = datetime.datetime.now().isoformat() - for issue in issues: - successful_java = False - if issue[JSON_INDEX_FILENAME].endswith('.java'): - fully_qualified_method_name = re.search( - '(.*)\(.*', issue[JSON_INDEX_PROCEDURE]) - if fully_qualified_method_name is not None: - # probably Java, let's try - try: - info = fully_qualified_method_name.groups()[0].split('.') - class_name = info[-2:-1][0] - method = info[-1] - package = '.'.join(info[0:-2]) - successful_java = True - except IndexError: - successful_java = False - if not successful_java: - class_name = '' - package = '' - method = issue[JSON_INDEX_PROCEDURE] - file_node = etree.Element('file') - file_node.attrib['name'] = issue[JSON_INDEX_FILENAME] - violation = etree.Element('violation') - violation.attrib['begincolumn'] = '0' - violation.attrib['beginline'] = str(issue[JSON_INDEX_LINE]) - violation.attrib['endcolumn'] = '0' - violation.attrib['endline'] = str(issue[JSON_INDEX_LINE] + 1) - violation.attrib['class'] = class_name - violation.attrib['method'] = method - violation.attrib['package'] = package - violation.attrib['priority'] = '1' - violation.attrib['rule'] = issue[JSON_INDEX_TYPE] - violation.attrib['ruleset'] = 'Infer Rules' - violation.attrib['externalinfourl'] = ( - ISSUE_TYPES_URL + issue[JSON_INDEX_TYPE]) - violation.text = issue[JSON_INDEX_QUALIFIER] - file_node.append(violation) - root.append(file_node) - return etree.tostring(root, pretty_print=True, encoding=config.CODESET) diff --git a/infer/lib/python/report.py b/infer/lib/python/report.py deleted file mode 100755 index 125817322..000000000 --- a/infer/lib/python/report.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python2.7 - -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals - -import argparse -import sys - -from inferlib import issues, utils - -arg_parser = argparse.ArgumentParser(add_help=False) -arg_parser.add_argument('--issues-json', metavar='', required=True, - help='Location of the json report') -arg_parser.add_argument('--issues-txt', metavar='', - help='Location of the text report') -arg_parser.add_argument('--issues-xml', metavar='', - help='Location of the xml report (ignored for now)') -arg_parser.add_argument('--pmd-xml', action='store_true', - help='Output issues in (PMD) XML format.') -arg_parser.add_argument('--project-root', metavar='', required=True, - help='Location of the project root') -arg_parser.add_argument('--quiet', action='store_true', - help='Silence console output.') -arg_parser.add_argument('--results-dir', metavar='', required=True, - help='Location of the results directory') - - -def main(): - sys_argv = map(utils.decode, sys.argv) - args = arg_parser.parse_args(sys_argv[1:]) - issues.print_and_save_errors(args.results_dir, args.project_root, - args.issues_json, args.issues_txt, - args.pmd_xml, console_out=not args.quiet) - - -if __name__ == '__main__': - main() diff --git a/infer/man/man1/infer-full.txt b/infer/man/man1/infer-full.txt index d8c44220e..b67859338 100644 --- a/infer/man/man1/infer-full.txt +++ b/infer/man/man1/infer-full.txt @@ -785,10 +785,6 @@ OPTIONS Specify the file containing perf profiler data to read See also infer-analyze(1). - --pmd-xml - Activates: Output issues in (PMD) XML format (Conversely: - --no-pmd-xml) See also infer-run(1). - --print-active-checkers Activates: Print the active checkers before starting the analysis (Conversely: --no-print-active-checkers) See also infer-analyze(1). diff --git a/infer/man/man1/infer-run.txt b/infer/man/man1/infer-run.txt index 0c64f72ab..89c772bae 100644 --- a/infer/man/man1/infer-run.txt +++ b/infer/man/man1/infer-run.txt @@ -88,10 +88,6 @@ OPTIONS Show this manual with all internal options in the INTERNAL OPTIONS section - --pmd-xml - Activates: Output issues in (PMD) XML format (Conversely: - --no-pmd-xml) - --print-logs Activates: Also log messages to stdout and stderr (Conversely: --no-print-logs) diff --git a/infer/man/man1/infer.txt b/infer/man/man1/infer.txt index 29f8d4e3f..fbdae39d1 100644 --- a/infer/man/man1/infer.txt +++ b/infer/man/man1/infer.txt @@ -785,10 +785,6 @@ OPTIONS Specify the file containing perf profiler data to read See also infer-analyze(1). - --pmd-xml - Activates: Output issues in (PMD) XML format (Conversely: - --no-pmd-xml) See also infer-run(1). - --print-active-checkers Activates: Print the active checkers before starting the analysis (Conversely: --no-print-active-checkers) See also infer-analyze(1). diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml index dfa9377ec..cba03d82a 100644 --- a/infer/src/base/Config.ml +++ b/infer/src/base/Config.ml @@ -1698,12 +1698,6 @@ and patterns_skip_translation = "Matcher or list of matchers for names of files that should not be analyzed at all." ) -and pmd_xml = - CLOpt.mk_bool ~long:"pmd-xml" - ~in_help:InferCommand.[(Run, manual_generic)] - "Output issues in (PMD) XML format" - - and print_active_checkers = CLOpt.mk_bool ~long:"print-active-checkers" ~in_help:InferCommand.[(Analyze, manual_generic)] @@ -2870,8 +2864,6 @@ and patterns_skip_implementation = match patterns_skip_implementation with k, r and patterns_skip_translation = match patterns_skip_translation with k, r -> (k, !r) -and pmd_xml = !pmd_xml - and print_active_checkers = !print_active_checkers and print_builtins = !print_builtins diff --git a/infer/src/base/Config.mli b/infer/src/base/Config.mli index 97686c344..6ab03c48f 100644 --- a/infer/src/base/Config.mli +++ b/infer/src/base/Config.mli @@ -465,8 +465,6 @@ val only_show : bool val perf_profiler_data_file : string option -val pmd_xml : bool - val print_active_checkers : bool val print_builtins : bool diff --git a/infer/src/integration/Driver.ml b/infer/src/integration/Driver.ml index 2d69512d7..89eaeeb41 100644 --- a/infer/src/integration/Driver.ml +++ b/infer/src/integration/Driver.ml @@ -293,28 +293,7 @@ let report ?(suppress_console = false) () = ~report_json:issues_json ) ; if Config.(test_determinator && process_clang_ast) then TestDeterminator.merge_test_determinator_results () ; - match Config.report_hook with - | Some prog when (not Config.buck_cache_mode) && Config.pmd_xml -> - let if_true key opt args = if not opt then args else key :: args in - let args = - if_true "--pmd-xml" Config.pmd_xml - @@ if_true "--quiet" - (Config.quiet || suppress_console) - [ "--issues-json" - ; issues_json - ; "--issues-txt" - ; Config.(results_dir ^/ report_txt) - ; "--project-root" - ; Config.project_root - ; "--results-dir" - ; Config.results_dir ] - in - if is_error (Unix.waitpid (Unix.fork_exec ~prog ~argv:(prog :: args) ())) then - L.external_error - "** Error running the reporting script:@\n** %s %s@\n** See error above@." prog - (String.concat ~sep:" " args) - | _ -> - () + () (* shadowed for tracing *) diff --git a/infer/tests/build_systems/results_xml/Makefile b/infer/tests/build_systems/results_xml/Makefile deleted file mode 100644 index fc6eb80e0..000000000 --- a/infer/tests/build_systems/results_xml/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -TESTS_DIR = ../.. - -CODETOANALYZE_DIR = ../codetoanalyze - -CLANG_OPTIONS = -c -INFER_OPTIONS = --project-root $(CODETOANALYZE_DIR) --pmd-xml -INFERPRINT_OPTIONS = --issues-tests - -SOURCES = $(CODETOANALYZE_DIR)/hello.c - -include $(TESTS_DIR)/clang.make - -issues.exp.test: infer-out/report.json -# grab only a few interesting fields from the xml to prevent flakiness - $(QUIET)grep --only-matching -e ' \(name\|method\|rule\)="[^"]*"' infer-out/report.xml > $@ diff --git a/infer/tests/build_systems/results_xml/issues.exp b/infer/tests/build_systems/results_xml/issues.exp deleted file mode 100644 index 43fc40a51..000000000 --- a/infer/tests/build_systems/results_xml/issues.exp +++ /dev/null @@ -1,3 +0,0 @@ - name="hello.c" - method="test" - rule="NULL_DEREFERENCE" diff --git a/infer/tests/codetoanalyze/cpp/errors/Makefile b/infer/tests/codetoanalyze/cpp/errors/Makefile index beb20560b..ce5dcd8b4 100644 --- a/infer/tests/codetoanalyze/cpp/errors/Makefile +++ b/infer/tests/codetoanalyze/cpp/errors/Makefile @@ -8,7 +8,7 @@ TESTS_DIR = ../../.. # use our own clang's standard library so that the tests are uniform across distributions CLANG_OPTIONS = -x c++ -std=c++1y -isystem$(ROOT_DIR) -c --stdlib=libc++ INFER_OPTIONS = --biabduction-only --ml-buckets cpp --debug-exceptions --project-root $(TESTS_DIR) \ - --pmd-xml --report-custom-error + --report-custom-error INFERPRINT_OPTIONS = --issues-tests SOURCES = \