Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

New option to only show uncovered loc with codecoverage

  • Loading branch information...
commit 5525bc744ecae0d9bb83f184e300fee1c02a9198 1 parent 35ab286
@joonty authored
Showing with 46 additions and 35 deletions.
  1. +1 −1  README.md
  2. +6 −0 plugin/phpqa.vim
  3. +39 −34 plugin/python/codecoverage.vim
View
2  README.md
@@ -135,4 +135,4 @@ This plugin is released under the [MIT License][6].
[3]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html
[4]: https://github.com/gmarik/vundle
[5]: http://www.vim.org/scripts/script.php?script_id=124
-[6]: https://raw.github.com/joonty/vim-phpqa/master/LICENSE
+[6]: https://github.com/joonty/vim-phpqa/raw/master/LICENSE
View
6 plugin/phpqa.vim
@@ -72,6 +72,12 @@ if !exists("g:phpqa_codecoverage_showcovered")
let g:phpqa_codecoverage_showcovered = 1
endif
+" Whether to show signs for covered code (or only not covered)
+" It may speed things up to turn this off
+if !exists("g:phpqa_codecoverage_regex")
+ let g:phpqa_codecoverage_showcovered = 1
+endif
+
" Whether to automatically run codesniffer when saving a file
if !exists("g:phpqa_codesniffer_autorun")
let g:phpqa_codesniffer_autorun = 1
View
73 plugin/python/codecoverage.vim
@@ -24,47 +24,52 @@ Check the file modification time, and only re-parse
if it's been modified.
"""
try:
- doc
- if doc != None:
- cmtime = time.ctime(os.path.getmtime(clover))
- if cmtime > mtime:
- doc.freeDoc()
- doc = None
-except NameError:
- doc = None
+ try:
+ doc
+ if doc != None:
+ cmtime = time.ctime(os.path.getmtime(clover))
+ if cmtime > mtime:
+ doc.freeDoc()
+ doc = None
+ except NameError:
+ doc = None
-" t0 = time.time() "
+ " t0 = time.time() "
-if doc is None:
- doc = libxml2.parseFile(clover)
- mtime = time.ctime(os.path.getmtime(clover))
-
-ctxt = doc.xpathNewContext()
-res = ctxt.xpathEval("/coverage/project/file[@name='"+fileName+"']/line[@type='stmt']")
-cur_signs = int(vim.eval('g:phpqa_num_cc_signs'))
-showcovered = int(vim.eval('g:phpqa_codecoverage_showcovered'))
-cmd_list = ''
+ if doc is None:
+ doc = libxml2.parseFile(clover)
+ mtime = time.ctime(os.path.getmtime(clover))
+
+ ctxt = doc.xpathNewContext()
+ res = ctxt.xpathEval("/coverage/project/file[@name='"+fileName+"']/line[@type='stmt']")
+ cur_signs = int(vim.eval('g:phpqa_num_cc_signs'))
+ showcovered = int(vim.eval('g:phpqa_codecoverage_showcovered'))
+ cmd_list = ''
-for node in res:
- ctxt.setContextNode(node)
- lnum = node.prop('num')
- cnt = int(node.prop('count'))
- if showcovered == 0 and cnt > 0:
- continue
- cur_signs += 1
- sign = "CodeCoverageCovered" if cnt > 0 else "CodeCoverageNotCovered"
- cmd_list += 'exec "sign place 4783 name='+sign+' line='+lnum+' file='+fileName+'" | '
+ for node in res:
+ ctxt.setContextNode(node)
+ lnum = node.prop('num')
+ cnt = int(node.prop('count'))
+ if showcovered == 0 and cnt > 0:
+ continue
+ cur_signs += 1
+ sign = "CodeCoverageCovered" if cnt > 0 else "CodeCoverageNotCovered"
+ cmd_list += 'exec "sign place 4783 name='+sign+' line='+lnum+' file='+fileName+'" | '
-vim.command(cmd_list)
-vim.command('let g:phpqa_num_cc_signs='+str(cur_signs))
+ vim.command(cmd_list)
+ vim.command('let g:phpqa_num_cc_signs='+str(cur_signs))
-"""
-t = time.time() - t0
-print "Completed in "+str(t)+" seconds"
-"""
+ """
+ t = time.time() - t0
+ print "Completed in "+str(t)+" seconds"
+ """
-ctxt.xpathFreeContext()
+ ctxt.xpathFreeContext()
+except os.error:
+ vim.command('echohl Error | echo "Missing or inaccessible code coverage file" | echohl None')
+except:
+ vim.command('echohl Error | echo "An error has occured while parsing the code coverage file" | echohl None')
EOF
else
Please sign in to comment.
Something went wrong with that request. Please try again.