From d9ed75cc085442fe4ffb4f3ca4d2996fe3e0115a Mon Sep 17 00:00:00 2001 From: Jeremy Dubreil Date: Wed, 18 Jan 2017 18:18:21 -0800 Subject: [PATCH] [infer][toplevel] remove dead code from the python bucklib.py scripts Reviewed By: jvillard Differential Revision: D4431686 fbshipit-source-id: 0ddfcf9 --- infer/lib/python/infer.py | 1 + infer/lib/python/inferlib/analyze.py | 9 ++--- infer/lib/python/inferlib/bucklib.py | 33 ++----------------- infer/lib/python/inferlib/capture/ant.py | 1 + infer/lib/python/inferlib/capture/gradle.py | 1 + infer/lib/python/inferlib/capture/mvn.py | 1 + .../lib/python/inferlib/capture/xcodebuild.py | 1 + infer/lib/python/inferlib/issues.py | 1 - infer/lib/python/inferlib/jwlib.py | 1 - infer/lib/python/inferlib/source.py | 1 - infer/lib/python/report.py | 1 + 11 files changed, 11 insertions(+), 40 deletions(-) diff --git a/infer/lib/python/infer.py b/infer/lib/python/infer.py index dd91ecaa1..841cf4196 100755 --- a/infer/lib/python/infer.py +++ b/infer/lib/python/infer.py @@ -184,5 +184,6 @@ def main(): global_argparser.print_help() sys.exit(os.EX_OK) + if __name__ == '__main__': main() diff --git a/infer/lib/python/inferlib/analyze.py b/infer/lib/python/inferlib/analyze.py index b78c56e2b..1856bc5c2 100644 --- a/infer/lib/python/inferlib/analyze.py +++ b/infer/lib/python/inferlib/analyze.py @@ -12,16 +12,11 @@ from __future__ import unicode_literals import argparse import csv -import json -import logging import multiprocessing -import os -import shutil -import subprocess import sys -import time -from . import config, issues, utils + +from . import config, utils # Increase the limit of the CSV parser to sys.maxlimit csv.field_size_limit(sys.maxsize) diff --git a/infer/lib/python/inferlib/bucklib.py b/infer/lib/python/inferlib/bucklib.py index 0fe5bb38a..a48f7b9af 100644 --- a/infer/lib/python/inferlib/bucklib.py +++ b/infer/lib/python/inferlib/bucklib.py @@ -13,20 +13,15 @@ from __future__ import print_function from __future__ import unicode_literals import argparse -import csv import json import logging -import multiprocessing import os -import platform -import re import shutil import stat import subprocess import sys import tempfile import time -import traceback import zipfile from inferlib import config, issues, utils @@ -55,10 +50,7 @@ def prepare_build(args): configuration that tells buck to use that script. """ - infer_options = [ - '--buck', - '--analyzer', args.analyzer, - ] + infer_options = ['--buck'] if args.java_jar_compiler is not None: infer_options += [ @@ -66,15 +58,6 @@ def prepare_build(args): args.java_jar_compiler, ] - if args.debug: - infer_options.append('--debug') - - if args.no_filtering: - infer_options.append('--no-filtering') - - if args.debug_exceptions: - infer_options += ['--debug-exceptions', '--no-filtering'] - # Create a temporary directory as a cache for jar files. infer_cache_dir = os.path.join(args.infer_out, 'cache') if not os.path.isdir(infer_cache_dir): @@ -92,10 +75,6 @@ def prepare_build(args): logging.info('Setup Infer analysis mode for Buck: export INFER_ANALYSIS=1') os.environ['INFER_ANALYSIS'] = '1' - # Export the Infer command as environment variables - os.environ['INFER_JAVA_BUCK_OPTIONS'] = json.dumps(infer_command) - os.environ['INFER_RULE_KEY'] = utils.infer_key(args.analyzer) - # Create a script to be called by buck infer_script = None with tempfile.NamedTemporaryFile(delete=False, @@ -164,13 +143,6 @@ def collect_results(args, start_time, targets): """ all_json_rows = set() - accumulation_whitelist = list(map(re.compile, [ - '^cores$', - '^time$', - '^start_time$', - '.*_pc', - ])) - for path in get_output_jars(targets): try: with zipfile.ZipFile(path) as jar: @@ -194,7 +166,8 @@ def collect_results(args, start_time, targets): bugs_out = os.path.join(args.infer_out, config.BUGS_FILENAME) issues.print_and_save_errors(args.infer_out, args.project_root, json_report, bugs_out, args.pmd_xml) - shutil.copy(bugs_out, os.path.join(args.infer_out, ANALYSIS_SUMMARY_OUTPUT)) + shutil.copy(bugs_out, os.path.join(args.infer_out, + ANALYSIS_SUMMARY_OUTPUT)) def cleanup(temp_files): diff --git a/infer/lib/python/inferlib/capture/ant.py b/infer/lib/python/inferlib/capture/ant.py index 33e6640d6..808691383 100644 --- a/infer/lib/python/inferlib/capture/ant.py +++ b/infer/lib/python/inferlib/capture/ant.py @@ -22,6 +22,7 @@ LANG = ['java'] def gen_instance(*args): return AntCapture(*args) + # This creates an empty argparser for the module, which provides only # description/usage information and no arguments. create_argparser = util.base_argparser(MODULE_DESCRIPTION, MODULE_NAME) diff --git a/infer/lib/python/inferlib/capture/gradle.py b/infer/lib/python/inferlib/capture/gradle.py index 8732afcae..0681fff82 100644 --- a/infer/lib/python/inferlib/capture/gradle.py +++ b/infer/lib/python/inferlib/capture/gradle.py @@ -25,6 +25,7 @@ LANG = ['java'] def gen_instance(*args): return GradleCapture(*args) + # This creates an empty argparser for the module, which provides only # description/usage information and no arguments. create_argparser = util.base_argparser(MODULE_DESCRIPTION, MODULE_NAME) diff --git a/infer/lib/python/inferlib/capture/mvn.py b/infer/lib/python/inferlib/capture/mvn.py index 380093a63..e56e04a80 100644 --- a/infer/lib/python/inferlib/capture/mvn.py +++ b/infer/lib/python/inferlib/capture/mvn.py @@ -24,6 +24,7 @@ LANG = ['java'] def gen_instance(*args): return MavenCapture(*args) + # This creates an empty argparser for the module, which provides only # description/usage information and no arguments. create_argparser = util.base_argparser(MODULE_DESCRIPTION, MODULE_NAME) diff --git a/infer/lib/python/inferlib/capture/xcodebuild.py b/infer/lib/python/inferlib/capture/xcodebuild.py index 02fd05981..f2e666b71 100644 --- a/infer/lib/python/inferlib/capture/xcodebuild.py +++ b/infer/lib/python/inferlib/capture/xcodebuild.py @@ -31,6 +31,7 @@ CLANGPLUSPLUS_WRAPPER = os.path.join(config.XCODE_WRAPPERS_DIRECTORY, def gen_instance(*args): return XcodebuildCapture(*args) + create_argparser = util.base_argparser(MODULE_DESCRIPTION, MODULE_NAME) diff --git a/infer/lib/python/inferlib/issues.py b/infer/lib/python/inferlib/issues.py index abc40e53d..6793b1bf2 100644 --- a/infer/lib/python/inferlib/issues.py +++ b/infer/lib/python/inferlib/issues.py @@ -149,7 +149,6 @@ def _text_of_report_list(project_root, reports, bugs_txt_path, limit=None, 'see %s or run `inferTraceBugs` for the remaining issues.') % (limit, bugs_txt_path), colorize.HEADER, formatter) - issues_found = 'Found {n_issues}'.format( n_issues=utils.get_plural('issue', n_issues), ) diff --git a/infer/lib/python/inferlib/jwlib.py b/infer/lib/python/inferlib/jwlib.py index 0d9e0d1eb..2a6c1ebc1 100644 --- a/infer/lib/python/inferlib/jwlib.py +++ b/infer/lib/python/inferlib/jwlib.py @@ -11,7 +11,6 @@ from __future__ import division from __future__ import print_function from __future__ import unicode_literals -import logging import os import subprocess from . import config diff --git a/infer/lib/python/inferlib/source.py b/infer/lib/python/inferlib/source.py index 682bf33d9..9d366262e 100644 --- a/infer/lib/python/inferlib/source.py +++ b/infer/lib/python/inferlib/source.py @@ -83,7 +83,6 @@ def build_source_context(source_name, mode, report_line): line_number += 1 excerpt = colorize.syntax_highlighting(source_name, mode, excerpt) - # number lines and add caret at the right position n_length = len(str(last_line)) s = '' diff --git a/infer/lib/python/report.py b/infer/lib/python/report.py index 045d537a9..c00276dd3 100755 --- a/infer/lib/python/report.py +++ b/infer/lib/python/report.py @@ -42,5 +42,6 @@ def main(): issues.print_and_save_errors(args.results_dir, args.project_root, args.issues_json, bugs_out, args.pmd_xml) + if __name__ == '__main__': main()