Skip to content

Commit

Permalink
Check should be a wrapper over log+analyze+store
Browse files Browse the repository at this point in the history
  • Loading branch information
whisperity committed May 9, 2017
1 parent aef3a7b commit f2baeab
Show file tree
Hide file tree
Showing 10 changed files with 645 additions and 581 deletions.
98 changes: 1 addition & 97 deletions bin/CodeChecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,102 +221,6 @@ def _warn_deprecated_command(cmd_name):
jobs_help_msg = 'Number of jobs. ' \
'Start multiple processes for faster analysis.'

log_argument_help_msg = """Path to the log file which is created
during the build. \nIf there is an already generated log file
with the compilation commands\ngenerated by \'CodeChecker log\' or
\'cmake -DCMAKE_EXPORT_COMPILE_COMMANDS\' \n CodeChecker check can
use it for the analysis in that case running the original build
will \nbe left out from the analysis process (no log is needed)."""

suppress_help_msg = """Path to suppress file.\nSuppress file can be used
to suppress analysis results during the analysis.\nIt is based on the
bug identifier generated by the compiler which is experimental.\nDo
not depend too much on this file because identifier or file format
can be changed.\nFor other in source suppress features see the user
guide."""

# --------------------------------------
# check commands
check_parser = subparsers.add_parser('check',
formatter_class=ADHF,
help=''' \
Run the supported source code analyzers on a project.''')
old_subcommands.append('check')

check_parser.add_argument('-w', '--workspace', type=str,
default=util.get_default_workspace(),
dest="workspace",
help=workspace_help_msg)

check_parser.add_argument('-n', '--name', type=str,
dest="name", required=True,
default=argparse.SUPPRESS,
help=name_help_msg)

checkgroup = check_parser.add_mutually_exclusive_group(required=True)

checkgroup.add_argument('-b', '--build', type=str, dest="command",
default=argparse.SUPPRESS,
required=False, help='''\
Build command which is used to build the project.''')

checkgroup.add_argument('-l', '--log', type=str, dest="logfile",
default=argparse.SUPPRESS,
required=False,
help=log_argument_help_msg)

check_parser.add_argument('-j', '--jobs', type=int, dest="jobs",
default=1, required=False,
help=jobs_help_msg)

check_parser.add_argument('-u', '--suppress', type=str,
dest="suppress",
default=argparse.SUPPRESS,
required=False,
help=suppress_help_msg)
check_parser.add_argument('-c', '--clean',
default=argparse.SUPPRESS,
action=DeprecatedOptionAction)

check_parser.add_argument('--update', action=DeprecatedOptionAction,
dest="update", default=False, required=False,
help="Incremental parsing, update the "
"results of a previous run. "
"Only the files changed since the last "
"build will be reanalyzed. Depends on"
" the build system.")

check_parser.add_argument('--force', action="store_true",
dest="force", default=False, required=False,
help="Delete analysis results form the "
"database if a run with the "
"given name already exists.")

check_parser.add_argument('-s', '--skip', type=str, dest="skipfile",
default=argparse.SUPPRESS,
required=False, help='Path to skip file.')

check_parser.add_argument('--quiet-build',
action='store_true',
default=False,
required=False,
help='Do not print out the output of the '
'original build.')

check_parser.add_argument('--add-compiler-defaults',
action='store_true',
default=False,
required=False,
help='Fetch built in compiler include '
'paths and defines '
'and pass them to Clang. This is '
'useful when you do cross-compilation.')

add_analyzer_arguments(check_parser)
add_database_arguments(check_parser)
logger.add_verbose_arguments(check_parser)
check_parser.set_defaults(func=arg_handler.handle_check)

# --------------------------------------
# Checkers parser.
checker_p = subparsers.add_parser('checkers',
Expand Down Expand Up @@ -588,7 +492,7 @@ def _warn_deprecated_command(cmd_name):
except Exception:
import traceback
traceback.print_exc(file=sys.stdout)
sys.exit(2)
sys.exit(1)


# -----------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions bin/codechecker-check
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# DO_NOT_INSTALL_TO_PATH
This file marks 'CodeChecker check' to be a valid command, but prohibits
use as 'codechecker-check'.
221 changes: 112 additions & 109 deletions docs/user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,113 @@ Used ports:

CodeChecker provides, along with the more fine-tuneable commands, some easy
out-of-the-box invocations to ensure the most user-friendly operation. These
two modes are called **quickcheck** and **check**.
two modes are called **check** and **quickcheck**.

## Check

`check` is the basic, most used and most important command used in
_CodeChecker_. It analyzes your project and stores the reported code defects
in a database, which can be viewed in a Web Browser later on (via `CodeChecker
server`).

To analyse your project by doing a build and reporting every
found issue in the built files, execute

~~~~~~~~~~~~~~~~~~~~~
CodeChecker check --build "make" --name "run_name"
~~~~~~~~~~~~~~~~~~~~~

Please make sure your build command actually compiles (builds) the source
files you intend to analyse, as CodeChecker only analyzes files that had been
used by the build system.

If you have an already existing JSON Compilation Commands file, you can also
supply it to `check`:

~~~~~~~~~~~~~~~~~~~~~
CodeChecker check --logfile ./my-build.json --name "run_name"
~~~~~~~~~~~~~~~~~~~~~

`check` is a wrapper over the following calls:

* If `--build` is specified, the build is executed as if `CodeChecker log`
were invoked.
* The resulting logfile, or a `--logfile` specified is used for `CodeChecker
analyze`
* The analysis results are feeded for `CodeChecker store`.

After the results has been stored in the database, the temporary files
used for the analysis are cleaned up.

Please see the individual help for `log`, `analyze` and `store` (below in this
_User guide_) for information about the arguments of `check`.

~~~~~~~~~~~~~~~~~~~~~
usage: CodeChecker check [-h] [--keep-tmp] [-c] [--update] -n NAME
[-w WORKSPACE] [-f] [-q] (-b COMMAND | -l LOGFILE)
[-j JOBS] [-i SKIPFILE]
[--analyzers ANALYZER [ANALYZER ...]]
[--add-compiler-defaults]
[--saargs CLANGSA_ARGS_CFG_FILE]
[--tidyargs TIDY_ARGS_CFG_FILE]
[-e checker/checker-group] [-d checker/checker-group]
[-u SUPPRESS] [--sqlite | --postgresql]
[--dbaddress DBADDRESS] [--dbport DBPORT]
[--dbusername DBUSERNAME] [--dbname DBNAME]
[--verbose {info,debug,debug_analyzer}]
Run analysis for a project with storing results in the database. Check only
needs a build command or an already existing logfile and performs every step
of doing the analysis in batch.
optional arguments:
-h, --help show this help message and exit
--keep-tmp
-c , --clean
--update
-n NAME, --name NAME
-w WORKSPACE, --workspace WORKSPACE
Directory where CodeChecker can store analysis related
data, such as intermediate result files and the
database. (default: /home/<username>/.codechecker)
-f, --force
-u SUPPRESS, --suppress SUPPRESS
--verbose {info,debug,debug_analyzer}
Set verbosity level. (default: info)
log arguments:
-q, --quiet-build
-b COMMAND, --build COMMAND
-l LOGFILE, --logfile LOGFILE
analyzer arguments:
-j JOBS, --jobs JOBS
-i SKIPFILE, --skip SKIPFILE
--analyzers ANALYZER [ANALYZER ...]
--add-compiler-defaults
--saargs CLANGSA_ARGS_CFG_FILE
--tidyargs TIDY_ARGS_CFG_FILE
checker configuration:
-e checker/checker-group, --enable checker/checker-group
-d checker/checker-group, --disable checker/checker-group
database arguments:
--sqlite (Usage of this argument is DEPRECATED and has no
effect!)
--postgresql
PostgreSQL arguments:
--dbaddress DBADDRESS
--dbport DBPORT
--dbusername DBUSERNAME
--dbname DBNAME
~~~~~~~~~~~~~~~~~~~~~

## Quickcheck

Expand Down Expand Up @@ -152,9 +258,12 @@ output arguments:

# Available CodeChecker commands

## 1. log mode:
## 1. `log` mode

Just build your project and create a log file but do not invoke the source code analysis.
The first step in performing an analysis on your project is to record
information about the files in your project for the analyzers. This is done by
recording a build of your project, which is done by the command `CodeChecker
log`.

~~~~~~~~~~~~~~~~~~~~~
usage: CodeChecker log [-h] -o LOGFILE -b COMMAND [-q]
Expand Down Expand Up @@ -659,112 +768,6 @@ CodeChecker store ./my_plists
~~~~


## 2. check mode:

### Basic Usage

Database and connections will be automatically configured.
The main script starts and setups everything what is required for analyzing a project (database server, tables ...).

~~~~~~~~~~~~~~~~~~~~~
CodeChecker check -w codechecker_workspace -n myTestProject -b "make"
~~~~~~~~~~~~~~~~~~~~~

Static analysis can be started also by using an already generated buildlog (see log mode).
If log is not available the analyzer will automatically create it.
An already created CMake json compilation database can be used as well.

~~~~~~~~~~~~~~~~~~~~~
CodeChecker check -w ~/codechecker_wp -n myProject -l ~/codechecker_wp/build_log.json
~~~~~~~~~~~~~~~~~~~~~

### Advanced Usage

~~~~~~~~~~~~~~~~~~~~~
usage: CodeChecker check [-h] [-w WORKSPACE] -n NAME (-b COMMAND | -l LOGFILE)
[-j JOBS] [-u SUPPRESS] [-c [DEPRECATED]]
[--update [DEPRECATED]] [--force] [-s SKIPFILE]
[--quiet-build] [--add-compiler-defaults] [-e ENABLE]
[-d DISABLE] [--keep-tmp]
[--analyzers ANALYZERS [ANALYZERS ...]]
[--saargs CLANGSA_ARGS_CFG_FILE]
[--tidyargs TIDY_ARGS_CFG_FILE]
[--sqlite [DEPRECATED]] [--postgresql]
[--dbport DBPORT] [--dbaddress DBADDRESS]
[--dbname DBNAME] [--dbusername DBUSERNAME]
[--verbose {info,debug,debug_analyzer}]
optional arguments:
-h, --help show this help message and exit
-w WORKSPACE, --workspace WORKSPACE
Directory where the CodeChecker can store analysis
related data. (default: /home/<user_home>/.codechecker)
-n NAME, --name NAME Name of the analysis.
-b COMMAND, --build COMMAND
Build command which is used to build the project.
-l LOGFILE, --log LOGFILE
Path to the log file which is created during the
build. If there is an already generated log file with
the compilation commands generated by 'CodeChecker
log' or 'cmake -DCMAKE_EXPORT_COMPILE_COMMANDS'
CodeChecker check can use it for the analysis in that
case running the original build will be left out from
the analysis process (no log is needed).
-j JOBS, --jobs JOBS Number of jobs. Start multiple processes for faster
analysis. (default: 1)
-u SUPPRESS, --suppress SUPPRESS
Path to suppress file. Suppress file can be used to
suppress analysis results during the analysis. It is
based on the bug identifier generated by the compiler
which is experimental. Do not depend too much on this
file because identifier or file format can be changed.
For other in source suppress features see the user
guide.
-c [DEPRECATED], --clean [DEPRECATED]
DEPRECATED argument! (default: None)
--update [DEPRECATED]
DEPRECATED argument! (default: None)
--force Delete analysis results form the database if a run
with the given name already exists. (default: False)
-s SKIPFILE, --skip SKIPFILE
Path to skip file.
--quiet-build Do not print out the output of the original build.
(default: False)
--add-compiler-defaults
Fetch built in compiler include paths and defines and
pass them to Clang. This is useful when you do cross-
compilation. (default: False)
-e ENABLE, --enable ENABLE
Enable checker.
-d DISABLE, --disable DISABLE
Disable checker.
--keep-tmp Keep temporary report files generated during the
analysis. (default: False)
--analyzers ANALYZERS [ANALYZERS ...]
Select which analyzer should be enabled. Currently
supported analyzers are: clangsa clang-tidy e.g. '--
analyzers clangsa clang-tidy' (default: ['clangsa',
'clang-tidy'])
--saargs CLANGSA_ARGS_CFG_FILE
File with arguments which will be forwarded directly
to the Clang static analyzer without modification.
--tidyargs TIDY_ARGS_CFG_FILE
File with arguments which will be forwarded directly
to the Clang tidy analyzer without modification.
--sqlite [DEPRECATED]
DEPRECATED argument! (default: None)
--postgresql Use PostgreSQL database. (default: False)
--dbport DBPORT Postgres server port. (default: 5432)
--dbaddress DBADDRESS
Postgres database server address. (default: localhost)
--dbname DBNAME Name of the database. (default: codechecker)
--dbusername DBUSERNAME
Database user name. (default: codechecker)
--verbose {info,debug,debug_analyzer}
Set verbosity level. (default: info)
~~~~~~~~~~~~~~~~~~~~~


### Using SQLite for database:

CodeChecker can also use SQLite for storing the results. In this case the
Expand Down
Loading

0 comments on commit f2baeab

Please sign in to comment.