This is a vim plugin to execute McCabe complexity check (mccabe.py) and reports the results in location-list window.
If you are using NeoBundle, add the following line in your vimrc.
NeoBundle 'miyakogi/vim-mccabepy'
Then reload vim and execute :NeoBundleInstall
.
Before run this plugin, please install mccabe.py, by pip install mccabe
or any other proper way. If you are going to use this plugin in virtual environment made by virtualenv
, please install mccabe.py
into the virtual environment.
Open *.py file and execute :MccabePy
.
Threashold of the complexity to be reported is set to 10 by default. To change this value, set b:mccabepy_min_complexity
or g:mccabepy_min_complexity
. If buffer local variable b:mccabepy_min_complexity
exists, g:mccabepy_min_complexity
is ignored.
By default, results will be reported in the location-list window. This action can be changed by using g:mccabepy_loc_open_cmd
option. For example, if you are a Unite user and you want to use Unite location-list
window, add the following lines in your vimrc. Then, the results will be reported in the Unite window.
let g:mccabepy_loc_open_cmd = 'Unite location-list -no-quit -buffer-name=mccabepy'
If there were nothing to be reported, no window will appear. If location-list window is opened, it will be closed automatically. To change this behaviour, use g:mccabepy_loc_close_cmd
.
Example 1) Do not close location-list window.
let g:mccabepy_loc_close_cmd = ''
Example 2) To close Unite location-list
window if there are nothing to be reported.
let g:mccabepy_loc_close_cmd = 'UniteClose mccabepy'