Exemple #1
0
def _do_quickcheck(args):
    """
    Handles the "quickcheck" command.

    For arguments see main function in CodeChecker.py.
    It also requires an extra property in args object, namely workspace which
    is a directory path as a string.
    This function is called from handle_quickcheck.
    """

    try:
        context = generic_package_context.get_context()

        context.codechecker_workspace = args.workspace
        args.name = "quickcheck"

        # Load severity map from config file.
        if os.path.exists(context.checkers_severity_map_file):
            with open(context.checkers_severity_map_file, 'r') as sev_file:
                severity_config = sev_file.read()

            context.severity_map = json.loads(severity_config)

        log_file = build_manager.check_log_file(args, context)
        actions = log_parser.parse_log(log_file, args.add_compiler_defaults)
        analyzer.run_quick_check(args, context, actions)

    except Exception as ex:
        LOG.error("Running quickcheck failed.")
    finally:
        if not args.keep_tmp:
            if log_file:
                LOG.debug('Removing temporary log file: ' + log_file)
                os.remove(log_file)
Exemple #2
0
def _do_quickcheck(args):
    """
    Handles the "quickcheck" command.

    For arguments see main function in CodeChecker.py.
    It also requires an extra property in args object, namely workspace which
    is a directory path as a string.
    This function is called from handle_quickcheck.
    """

    try:
        context = generic_package_context.get_context()

        context.codechecker_workspace = args.workspace
        args.name = "quickcheck"

        log_file, set_in_cmdline = build_manager.check_log_file(args, context)
        actions = log_parser.parse_log(log_file, args.add_compiler_defaults)
        analyzer.run_quick_check(args, context, actions)

    except Exception as ex:
        LOG.error("Running quickcheck failed.")
    finally:
        if not args.keep_tmp:
            if log_file and not set_in_cmdline:
                LOG.debug('Removing temporary log file: ' + log_file)
                os.remove(log_file)
Exemple #3
0
def _do_quickcheck(args):
    """
    Handles the "quickcheck" command.

    For arguments see main function in CodeChecker.py.
    It also requires an extra property in args object, namely workspace which
    is a directory path as a string.
    This function is called from handle_quickcheck.
    """

    try:
        context = generic_package_context.get_context()

        context.codechecker_workspace = args.workspace
        args.name = "quickcheck"

        # Load severity map from config file.
        if os.path.exists(context.checkers_severity_map_file):
            with open(context.checkers_severity_map_file, 'r') as sev_file:
                severity_config = sev_file.read()

            context.severity_map = json.loads(severity_config)

        log_file = build_manager.check_log_file(args, context)
        actions = log_parser.parse_log(log_file,
                                       args.add_compiler_defaults)
        analyzer.run_quick_check(args, context, actions)

    except Exception as ex:
        LOG.error("Running quickcheck failed.")
    finally:
        if not args.keep_tmp:
            if log_file:
                LOG.debug('Removing temporary log file: ' + log_file)
                os.remove(log_file)
Exemple #4
0
def _do_quickcheck(args):
    '''
    Handles the "quickcheck" command.

    For arguments see main function in CodeChecker.py. It also requires an extra
    property in args object, namely workspace which is a directory path as a
    string. This function is called from handle_quickcheck.
    '''

    context = generic_package_context.get_context()
    context.codechecker_workspace = args.workspace

    check_env = analyzer_env.get_check_env(context.path_env_extra,
                                           context.ld_lib_path_extra)

    compiler_bin = context.compiler_bin
    if not host_check.check_clang(compiler_bin, check_env):
        sys.exit(1)

    # load severity map from config file
    if os.path.exists(context.checkers_severity_map_file):
        with open(context.checkers_severity_map_file, 'r') as sev_conf_file:
            severity_config = sev_conf_file.read()

        context.severity_map = json.loads(severity_config)

    log_file = _check_generate_log_file(args, context, silent=True)
    try:
        actions = log_parser.parse_log(log_file)
    except Exception as ex:
        LOG.error(ex)
        sys.exit(1)

    if not actions:
        LOG.warning('There are no build actions in the log file.')
        sys.exit(1)

    static_analyzer = analyzer.StaticAnalyzer(context)
    static_analyzer.workspace = args.workspace
    static_analyzer.checkers = context.default_checkers

    # add user defined checkers
    try:
        static_analyzer.checkers = args.ordered_checker_args
    except AttributeError:
        LOG.debug('No checkers were defined in the command line')

    for action in actions:
        analyzer.run_quick_check(static_analyzer,
                                 action,
                                 print_steps=args.print_steps)
Exemple #5
0
def _do_quickcheck(args):
    """
    Handles the "quickcheck" command.

    For arguments see main function in CodeChecker.py.
    It also requires an extra property in args object, namely workspace which
    is a directory path as a string.
    This function is called from handle_quickcheck.
    """

    context = generic_package_context.get_context()

    try:
        workspace = args.workspace
    except AttributeError:
        # If no workspace value was set for some reason
        # in args set the default value.
        workspace = util.get_default_workspace()

    context.codechecker_workspace = workspace
    args.name = "quickcheck"

    # Load severity map from config file.
    if os.path.exists(context.checkers_severity_map_file):
        with open(context.checkers_severity_map_file, 'r') as sev_conf_file:
            severity_config = sev_conf_file.read()

        context.severity_map = json.loads(severity_config)

    log_file = build_manager.check_log_file(args)

    if not log_file:
        log_file = build_manager.generate_log_file(args,
                                                   context,
                                                   args.quiet_build)
    if not log_file:
        LOG.error("Failed to generate compilation command file: " + log_file)
        sys.exit(1)

    try:
        actions = log_parser.parse_log(log_file)
    except Exception as ex:
        LOG.error(ex)
        sys.exit(1)

    if not actions:
        LOG.warning('There are no build actions in the log file.')
        sys.exit(1)

    analyzer.run_quick_check(args, context, actions)
Exemple #6
0
def _do_quickcheck(args):
    """
    Handles the "quickcheck" command.

    For arguments see main function in CodeChecker.py. It also requires an extra
    property in args object, namely workspace which is a directory path as a
    string. This function is called from handle_quickcheck.
    """

    context = generic_package_context.get_context()

    try:
        workspace = args.workspace
    except AttributeError:
        # If no workspace value was set for some reason
        # in args set the default value.
        workspace = util.get_default_workspace()

    context.codechecker_workspace = workspace
    args.jobs = 1
    args.name = "quickcheck"

    # Load severity map from config file.
    if os.path.exists(context.checkers_severity_map_file):
        with open(context.checkers_severity_map_file, 'r') as sev_conf_file:
            severity_config = sev_conf_file.read()

        context.severity_map = json.loads(severity_config)

    log_file = build_manager.check_log_file(args)

    if not log_file:
        log_file = build_manager.generate_log_file(args,
                                                   context,
                                                   args.quiet_build)
    if not log_file:
        LOG.error("Failed to generate compilation command file: " + log_file)
        sys.exit(1)

    try:
        actions = log_parser.parse_log(log_file)
    except Exception as ex:
        LOG.error(ex)
        sys.exit(1)

    if not actions:
        LOG.warning('There are no build actions in the log file.')
        sys.exit(1)

    analyzer.run_quick_check(args, context, actions)