[other] 代码量代码复杂度统计-lizard

[other] 代码量代码复杂度统计-lizard

lizard的可以用来统计下面的一些数据

  1. 不包含代码注释的代码行数
  2. CCN 代码的复杂度,也就是分支复杂度
  3. token的个数(关键字,标示符,常量,标点符号,操作符)
  4. 函数的参数个数

支持下列的一些语言

  • C/C++ (works with C++14)
  • Java
  • C# (C Sharp)
  • JavaScript
  • Objective C
  • Swift
  • Python
  • Ruby
  • TTCN-3
  • PHP
  • Scala
  • GDScript

https://github.com/terryyin/lizard

优点

  1. 不需要头文件全部指定(宏展开可能有失偏颇)
  2. 能够同时统计代码量和代码复杂度
  3. 能够产生和cppNCSS相同的报告

缺点

  1. c/c++的三字符组和双字符组
  2. c/c++的代码预处理和宏扩展没有实现
  3. c++的一些模版

对应的可以选择的参数

usage: lizard [options] [PATH or FILE] [PATH] ...lizard is an extensible Cyclomatic Complexity Analyzer for many programming
languages including C/C++ (doesn't require all the header files). For more
information visit http://www.lizard.wspositional arguments:paths                 list of the filename/paths.optional arguments:-h, --help            show this help message and exit--version             show program's version number and exit-l LANGUAGES, --languages LANGUAGESList the programming languages you want to analyze. ifleft empty, it'll search for all languages it knows.`lizard -l cpp -l java`searches for C++ and Java code.The available languages are: cpp, java, csharp,javascript, python, objectivec, ttcn, ruby, php,swift, scala, GDScript-V, --verbose         Output in verbose mode (long function name)-C CCN, --CCN CCN     Threshold for cyclomatic complexity number warning.The default value is 15. Functions with CCN biggerthan it will generate warning-f INPUT_FILE, --input_file INPUT_FILEget a list of filenames from the given file-L LENGTH, --length LENGTHThreshold for maximum function length warning. Thedefault value is 1000. Functions length bigger than itwill generate warning-a ARGUMENTS, --arguments ARGUMENTSLimit for number of parameters-w, --warnings_only   Show warnings only, using clang/gcc's warning formatfor printing warnings.http://clang.llvm.org/docs/UsersManual.html#cmdoption-fdiagnostics-format--warning-msvs        Show warnings only, using Visual Studio's warningformat for printing warnings.https://msdn.microsoft.com/en-us/library/yxkt8b26.aspx-i NUMBER, --ignore_warnings NUMBERIf the number of warnings is equal or less than thenumber, the tool will exit normally; otherwise, itwill generate error. If the number is negative, thetool exits normally regardless of the number ofwarnings. Useful in makefile for legacy code.-x EXCLUDE, --exclude EXCLUDEExclude files that match this pattern. * matcheseverything, ? matches any single character,"./folder/*" exclude everything in the folderrecursively. Multiple patterns can be specified. Don'tforget to add "" around the pattern.-t WORKING_THREADS, --working_threads WORKING_THREADSnumber of working threads. The default value is 1.Using a bigger number can fully utilize the CPU andoften faster.-X, --xml             Generate XML in cppncss style instead of the tabularoutput. Useful to generate report in Jenkins server-H, --html            Output HTML report-m, --modified        Calculate modified cyclomatic complexity number-E EXTENSIONS, --extension EXTENSIONSUser the extensions. The available extensions are:-Ecpre: it will ignore code in the #else branch.-Ewordcount: count word frequencies and generate tagcloud. -Eoutside: include the global code as onefunction. -EIgnoreAssert: to ignore all code inassert. -ENS: count nested control structures.-s SORTING, --sort SORTINGSort the warning with field. The field can be nloc,cyclomatic_complexity, token_count, p#arameter_count,etc. Or an customized field.-T THRESHOLDS, --Threshold THRESHOLDSSet the limit for a field. The field can be nloc,cyclomatic_complexity, token_count, parameter_count,etc. Or an customized file. Lizard will report warningif a function exceed the limit-W WHITELIST, --whitelist WHITELISTThe path and file name to the whitelist file. It's'./whitelizard.txt' by default. Find more informationin README.

结果如下

(venv) ➜  fff git:(master) ✗ lizard
================================================NLOC    CCN   token  PARAM  length  location
------------------------------------------------4      1     14      1       4 driver_write@6-9@./examples/driver_testing/driver.c4      1     11      0       4 driver_read@11-14@./examples/driver_testing/driver.c9      2     35      0       9 driver_init_device@16-24@./examples/driver_testing/driver.c6      1     17      1       6 IO_MEM_RD8@15-20@./examples/driver_testing/driver.test.cpp6      1     21      2       6 IO_MEM_WR8@25-30@./examples/driver_testing/driver.test.cpp7      1     34      2       7 TEST@33-39@./examples/driver_testing/driver.test.cpp8      1     40      2       8 TEST@42-49@./examples/driver_testing/driver.test.cpp.........................................................................................4      1      8      0      48 output_macro_counting_shortcuts@351-398@./fakegen.rb8      1      9      0       9 output_c_and_cpp@400-408@./fakegen.rb
25 file analyzed.
==============================================================
NLOC    Avg.NLOC  AvgCCN  Avg.token  function_cnt    file
--------------------------------------------------------------19       5.7     1.3       20.0         3     ./examples/driver_testing/driver.c4       0.0     0.0        0.0         0     ./examples/driver_testing/driver.h43       6.8     1.0       28.0         4     ./examples/driver_testing/driver.test.cpp47       8.5     1.0       57.8         4     ./examples/driver_testing/driver.test.fff.cpp3       0.0     0.0        0.0         0     ./examples/driver_testing/hardware_abstraction.h0       0.0     0.0        0.0         0     ./examples/driver_testing/registers.h5       0.0     0.0        0.0         0     ./examples/embedded_ui/DISPLAY.h2       0.0     0.0        0.0         0     ./examples/embedded_ui/SYSTEM.h21       6.7     1.0       27.7         3     ./examples/embedded_ui/test_suite_template.c41       7.0     1.4       22.8         5     ./examples/embedded_ui/UI.c6       0.0     0.0        0.0         0     ./examples/embedded_ui/UI.h129       8.7     1.0       49.8        13     ./examples/embedded_ui/UI_test_ansic.c97       7.1     1.0       37.8        11     ./examples/embedded_ui/UI_test_cpp.cpp4917       8.2     2.4       56.1       503     ./gtest/gtest-all.cc5       4.0     1.0       27.0         1     ./gtest/gtest-main.cc11679       5.5     1.3       63.7       774     ./gtest/gtest.h4       0.0     0.0        0.0         0     ./test/c_test_framework.h79      19.7     1.0      118.0         3     ./test/fff_test_c.c25       6.5     1.0       34.0         2     ./test/fff_test_cpp.cpp56      26.0     1.0      151.5         2     ./test/fff_test_global_c.c17       7.0     1.0       24.0         1     ./test/fff_test_global_cpp.cpp10       0.0     0.0        0.0         0     ./test/global_fakes.c23       0.0     0.0        0.0         0     ./test/global_fakes.h300       8.1     1.3       24.5        35     ./fakegen.rb8       0.0     0.0        0.0         0     ./fff.h=========================================================================================
!!!! Warnings (cyclomatic_complexity > 15 or parameter_count > 100 or length > 1000) !!!!
================================================NLOC    CCN   token  PARAM  length  location
------------------------------------------------65     17    397      0     131 testing::internal::UnitTestImpl::RunAllTests@5449-5579@./gtest/gtest-all.cc49     26    372      2      67 testing::internal::ParseGoogleTestFlagsOnlyImpl@6076-6142@./gtest/gtest-all.cc19     16    147      3      20 testing::internal::AtomMatchesChar@8005-8024@./gtest/gtest-all.cc
==========================================================================================
Total nloc   Avg.NLOC  AvgCCN  Avg.token   Fun Cnt  Warning cnt   Fun Rt   nloc Rt
------------------------------------------------------------------------------------------17540       6.7     1.7       59.2     1364            3      0.00    0.01

posted on 2017-04-26 22:22 secularbird 阅读(...) 评论(...) 编辑 收藏

转载于:https://www.cnblogs.com/zelos/p/6771388.html

[other] 代码量代码复杂度统计-lizard相关推荐

  1. 统计代码量-代码统计工具 CLOC | gitlab统计代码量

    文章目录 一.代码统计工具 CLOC 什么是CLOC? 下载安装 clocs使用 二.gitlab统计代码量 命令行统计 图形化统计 IDE Statistic统计代码插件 一.代码统计工具 CLOC ...

  2. 用StatSVN统计SVN服务器项目的代码量

    用StatSVN统计SVN服务器项目的代码量 下载并安装SVN统计工具StatSVN 1)下载地址:sourceforge.net/projects/statsvn/ 2)解压压缩包,到一个目录,如D ...

  3. cd返回上一 git_git统计代码量脚本

    在工作中,我想统计各开发人员,在一定日期范围内的编码情况,故有了此脚本. 一.先贴图,看看效果: 此图中,用"开发者姓名"代替了实际项目中git的账号名称,输出结果按提交次数倒序输 ...

  4. Git命令按人统计提交次数和代码量

    统计个人的代码量 git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git lo ...

  5. 统计代码行数_推荐一波代码量、行数、提交量、作者等全维度统计神器

    背景 代码各种维度的统计在有些时候是很重要的,这里总结一些常用的牛逼的代码统计工具,着重介绍了个人使用的 Statistic 插件.但是如果你是想统计团队维度的数据,推荐后面介绍的 git_stats ...

  6. 【git学习】统计git项目某user的代码量

    查看自己的代码量:(直接awk编程) git log --author="username" --pretty=tformat: --numstat | awk '{ add += ...

  7. 用python内置函数算复杂度吗_Python减少代码量的两个内置函数

    Python减少代码量的两个内置函数 前言 Python中内置了几个非常好用的函数. 当你掌握了这几个函数的用法后,有些场景下,不用自己去实现多余的冗余代码编写,只需要调用这些函数,便能很简短的帮你实 ...

  8. eclipse代码量统计插件_Android Studio 代码行数统计插件Statistic的简单使用

    在项目开发过程中,有时候需要统计代码行数(比如组长想关心一下你的代码量,或者要申请软件著作权时),需要统计的文件类型主要是 .java..xml..kt等,已经有人开发好相关插件了,如果你是用Andr ...

  9. 如何统计自己写的代码量

    一背景介绍 在公司实习,需要统计自己写了多少代码: 或者需要统计某个系统自己贡献度如何,也或者是自己就是想计算一下自己代码能力,个人觉得,代码量这个东西,没有多大度量价值,可是HR喜欢啊. 二 统计命 ...

最新文章

  1. C语言基础(6)-char类型
  2. 员工没热情?这8个简单方法比加薪都管用
  3. HANA Calculation View
  4. 阿里P7大牛手把手教你!一眼就能看懂的Android自学手册,真香!
  5. 程序员的压力有多大?
  6. WCF中使用自定义behavior提示错误的解决方法
  7. QT utf8编码转gb2312编码,互相转换的源代码
  8. word打开文档很久很慢_打开Word文档出现假死或超慢的原因及解决方法
  9. python语音验证码识别_python语音验证码接口_python语音接口_python语音验证码_语音验证码代码示例_互亿无线...
  10. FlyThings OS:基于Linux实现现代化人机交互体验的新嵌入式操作系统
  11. 高速公路ETC卡签之我见2-卡片消费
  12. JAVA 繁体 转 简体 简体转翻译 繁体简体互转
  13. 自制三维激光扫描建模
  14. 关于mindspore.ops.operation.Conv2d算子使用
  15. Window线程安全与线程控制函数
  16. 怎样将文件后缀名统一重命名并为大写字母
  17. Oracle数据库注入-墨者学院(SQL手工注入漏洞测试(Oracle数据库))
  18. PAT甲级 1030 Travel Plan
  19. PVE7.0 CPU功耗调节
  20. 这个饭店每天只卖一道菜,月入百万?

热门文章

  1. 怎样给Spark传递函数—怎样让你的Spark应用更高效更健壮
  2. 解释清楚智能指针二【用自己的话,解释清楚】
  3. POJ2146 Confusing Login Names [最小字符串编辑距离]
  4. ACCESS中执行sql语句
  5. 风力涡轮机巨头维斯塔斯遭网络攻击
  6. 谷歌发布基于浏览器的 Spectre 攻击的 PoC exploit
  7. nginx模块使用详解
  8. Spring boot入门(三):集成AdminLTE(Freemarker),结合generate代码生成器,利用DataTable和PageHelper分页...
  9. android开发实践之1:安装部署环境设置
  10. android 线性布局