web developer & system programmer

coder . cl

ramblings and thoughts on programming...

bugbuster.py

published: 20-08-2011 / updated: 20-08-2011
by Daniel Molina Wegener

The bugbuster.py script is a tiny Python script that wraps around well known static analyzers, the splint static analyzer, the TenDRA compiler static checker and cppcheck static analyzer. It has various options that will allow you to easily manage error message from the compile command under Emacs or VIM. You can participate on the development process on github.com on the following URL: bugbuster repository.

It searches for the configuration file on the current directory as ./.bugbuster.ini and it has the following options:

defaults
This is only a global section option, and indicates which checkers should run for the given files.
includes
Directory list to search for include directories separated by colon characters, for example a valid value for this option is: /usr/include:/usr/local/include.
suppress
Suppress messages in other files rather than displaying messages for all files, for example external files like included headers.
flags
Additional flags that should be used with the current checker.
ignore
Ignore lines containing the given text values separated by colon characters, for example a value of Checking:__cplusplus will ignore all lines that contains Checking or __cplusplus.
noincludes
Removes the include directories with the given checker added on the globalincludes section.

A configuration file .bugbuster.ini. file should look as follows and you can run bugbuster with the –help flag to obtain a list of available command line options:

[global]
includes = /usr/include/libxml2:/usr ### include dirs
suppress = true                      ### suppress other file messages
defaults = cppcheck:tendra:splint    ### enabled checkers

[tendra]
flags = -Yxpg4:-Yposix2:-Yposix:-Xs  ### tendra flags
ignore = preprocessing:aborting      ### ignore lines with text

[splint]
flags = -bugslimit:100               ### splint flags
ignore = exported:observer           ### ignore lines with text

[cppcheck]
noincludes = true                    ### omit default includes
ignore = Checking:__cplusplus        ### ignore lines with text

The help screen looks as follows:

11:47 [dmw@www:0 ~]$ bugbuster.py --help
Usage: bugbuster.py [options]

Options:
  -h, --help            show this help message and exit
  -l BUG_LINT, --lint=BUG_LINT
                        Add a lint program to use (defaults: ['cppcheck',
                        'tendra', 'splint'])
  -e BUG_ENV, --env=BUG_ENV
                        Adds environment variable
  -c BUG_CONFIG, --config=BUG_CONFIG
                        Uses the configuration file
  -f FILES, --files=FILES
                        File to process (twice to add more files)
  -s, --suppress        Suppress messages in other files
  -i IGNORE, --ignore=IGNORE
                        Ignore lines with substring, twice to add
11:57 [dmw@www:0 ~]$ 


emacs integration

To integrate bugbuster.py in Emacs, you can add the following code in your .emacs file:

(global-set-key [C-f11] 'dmw-do-bugbuster)

(defun dmw-do-bugbuster ()
  (interactive)
  (set (make-local-variable 'compile-command)
       (let ((file (file-name-nondirectory buffer-file-name)))
         (format "bugbuster.py --file=%s" file)))
  (message compile-command)
  (compile compile-command))

Remember that bugbuster.py and the compile command will use the current file directory as current directory and will search there for the .bugbuster.ini file for available options.