adlint 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (465) hide show
  1. data/AUTHORS +27 -0
  2. data/COPYING +674 -0
  3. data/ChangeLog +820 -0
  4. data/INSTALL +78 -0
  5. data/MANIFEST +464 -0
  6. data/NEWS +38 -0
  7. data/README +74 -0
  8. data/Rakefile +167 -0
  9. data/TODO +29 -0
  10. data/bin/adlint +141 -0
  11. data/bin/adlint_chk +129 -0
  12. data/bin/adlint_cma +122 -0
  13. data/bin/adlint_sma +129 -0
  14. data/bin/adlintize +286 -0
  15. data/etc/conf.d/fallback/cinit.erb +11 -0
  16. data/etc/conf.d/fallback/traits.erb +216 -0
  17. data/etc/conf.d/i686-cygwin/cinit-gcc_4.3.4.erb +149 -0
  18. data/etc/conf.d/i686-cygwin/traits-gcc_4.3.4.erb +227 -0
  19. data/etc/conf.d/i686-devkit/cinit-gcc_4.5.2.erb +224 -0
  20. data/etc/conf.d/i686-devkit/traits-gcc_4.5.2.erb +226 -0
  21. data/etc/conf.d/i686-linux/cinit-gcc_4.5.1.erb +219 -0
  22. data/etc/conf.d/i686-linux/traits-gcc_4.5.1.erb +224 -0
  23. data/etc/conf.d/i686-mingw/cinit-gcc_4.6.1.erb +234 -0
  24. data/etc/conf.d/i686-mingw/traits-gcc_4.6.1.erb +226 -0
  25. data/etc/conf.d/noarch/GNUmakefile.erb +119 -0
  26. data/etc/conf.d/noarch/adlint_all_bat.erb +9 -0
  27. data/etc/conf.d/noarch/adlint_all_sh.erb +10 -0
  28. data/etc/conf.d/noarch/pinit.erb +11 -0
  29. data/etc/mesg.d/en_US/messages.yml +784 -0
  30. data/etc/mesg.d/ja_JP/messages.yml +784 -0
  31. data/lib/adlint/analyzer.rb +294 -0
  32. data/lib/adlint/c/branch.rb +251 -0
  33. data/lib/adlint/c/builtin.rb +92 -0
  34. data/lib/adlint/c/code.rb +490 -0
  35. data/lib/adlint/c/const.rb +465 -0
  36. data/lib/adlint/c/conv.rb +212 -0
  37. data/lib/adlint/c/ctrlexpr.rb +949 -0
  38. data/lib/adlint/c/domain.rb +7499 -0
  39. data/lib/adlint/c/environ.rb +133 -0
  40. data/lib/adlint/c/expr.rb +1725 -0
  41. data/lib/adlint/c/format.rb +3209 -0
  42. data/lib/adlint/c/interp.rb +1740 -0
  43. data/lib/adlint/c/lexer.rb +241 -0
  44. data/lib/adlint/c/mediator.rb +313 -0
  45. data/lib/adlint/c/message.rb +13597 -0
  46. data/lib/adlint/c/metric.rb +765 -0
  47. data/lib/adlint/c/object.rb +1018 -0
  48. data/lib/adlint/c/parser.rb +3800 -0
  49. data/lib/adlint/c/parser.y +2054 -0
  50. data/lib/adlint/c/phase.rb +712 -0
  51. data/lib/adlint/c/resolver.rb +270 -0
  52. data/lib/adlint/c/scanner.rb +248 -0
  53. data/lib/adlint/c/scope.rb +74 -0
  54. data/lib/adlint/c/syntax.rb +4279 -0
  55. data/lib/adlint/c/type.rb +7506 -0
  56. data/lib/adlint/c/util.rb +91 -0
  57. data/lib/adlint/c/value.rb +2310 -0
  58. data/lib/adlint/c.rb +56 -0
  59. data/lib/adlint/code.rb +500 -0
  60. data/lib/adlint/cpp/code.rb +189 -0
  61. data/lib/adlint/cpp/constexpr.rb +721 -0
  62. data/lib/adlint/cpp/constexpr.y +389 -0
  63. data/lib/adlint/cpp/eval.rb +1012 -0
  64. data/lib/adlint/cpp/lexer.rb +860 -0
  65. data/lib/adlint/cpp/macro.rb +637 -0
  66. data/lib/adlint/cpp/message.rb +992 -0
  67. data/lib/adlint/cpp/phase.rb +176 -0
  68. data/lib/adlint/cpp/scanner.rb +93 -0
  69. data/lib/adlint/cpp/source.rb +169 -0
  70. data/lib/adlint/cpp/subst.rb +300 -0
  71. data/lib/adlint/cpp/syntax.rb +1412 -0
  72. data/lib/adlint/cpp/util.rb +97 -0
  73. data/lib/adlint/cpp.rb +43 -0
  74. data/lib/adlint/driver.rb +147 -0
  75. data/lib/adlint/error.rb +179 -0
  76. data/lib/adlint/lang.rb +97 -0
  77. data/lib/adlint/ld/message.rb +259 -0
  78. data/lib/adlint/ld/metric.rb +57 -0
  79. data/lib/adlint/ld/object.rb +542 -0
  80. data/lib/adlint/ld/phase.rb +193 -0
  81. data/lib/adlint/ld/typedef.rb +109 -0
  82. data/lib/adlint/ld/util.rb +88 -0
  83. data/lib/adlint/ld.rb +37 -0
  84. data/lib/adlint/lexer.rb +293 -0
  85. data/lib/adlint/message.rb +368 -0
  86. data/lib/adlint/metric.rb +805 -0
  87. data/lib/adlint/monitor.rb +144 -0
  88. data/lib/adlint/phase.rb +90 -0
  89. data/lib/adlint/prelude.rb +314 -0
  90. data/lib/adlint/report.rb +617 -0
  91. data/lib/adlint/source.rb +155 -0
  92. data/lib/adlint/symbol.rb +127 -0
  93. data/lib/adlint/token.rb +215 -0
  94. data/lib/adlint/traits.rb +643 -0
  95. data/lib/adlint/util.rb +524 -0
  96. data/lib/adlint/version.rb +71 -0
  97. data/lib/adlint.rb +66 -0
  98. data/share/HEADER +45 -0
  99. data/share/demo/Makefile +110 -0
  100. data/share/demo/ambig_operator/ambig_operator.c +289 -0
  101. data/share/demo/arg_points_unset/arg_points_unset.c +37 -0
  102. data/share/demo/array_range/array_range.c +62 -0
  103. data/share/demo/bad_bitfields/bad_bitfields.c +74 -0
  104. data/share/demo/bad_brace/bad_brace.c +19 -0
  105. data/share/demo/bad_charset/abcde$.h +0 -0
  106. data/share/demo/bad_charset/bad_charset.c +22 -0
  107. data/share/demo/bad_comment/bad_comment.c +3 -0
  108. data/share/demo/bad_const/bad_const.c +19 -0
  109. data/share/demo/bad_conv/bad_conv.c +48 -0
  110. data/share/demo/bad_indent/bad_indent.c +50 -0
  111. data/share/demo/bad_init/bad_init.c +49 -0
  112. data/share/demo/bad_macro/bad_macro.c +97 -0
  113. data/share/demo/bitwise_expr/bitwise_expr.c +19 -0
  114. data/share/demo/call_by_value/call_by_value.c +26 -0
  115. data/share/demo/cross_ref/cross_ref.c +21 -0
  116. data/share/demo/dangling_else/dangling_else.c +20 -0
  117. data/share/demo/dead_code/dead_code.c +237 -0
  118. data/share/demo/deep_nest/deep_nest.c +57 -0
  119. data/share/demo/dense_switch/dense_switch.c +62 -0
  120. data/share/demo/direct_recur/direct_recur.c +15 -0
  121. data/share/demo/div_by_zero/div_by_zero.c +35 -0
  122. data/share/demo/dos_source/dos_source.c +7 -0
  123. data/share/demo/funptr_cast/funptr_cast.c +26 -0
  124. data/share/demo/goto_stmt/goto_stmt.c +19 -0
  125. data/share/demo/id_hiding/id_hiding.c +19 -0
  126. data/share/demo/ill_defined/ill_defined.c +13 -0
  127. data/share/demo/implicit_conv/implicit_conv.c +60 -0
  128. data/share/demo/implicit_int/implicit_int.c +14 -0
  129. data/share/demo/incomplete_type/incomplete_type.c +49 -0
  130. data/share/demo/indirect_recur/indirect_recur_1.c +14 -0
  131. data/share/demo/indirect_recur/indirect_recur_1.h +7 -0
  132. data/share/demo/indirect_recur/indirect_recur_2.c +12 -0
  133. data/share/demo/indirect_recur/indirect_recur_2.h +6 -0
  134. data/share/demo/indirect_recur/indirect_recur_3.c +6 -0
  135. data/share/demo/indirect_recur/indirect_recur_3.h +6 -0
  136. data/share/demo/indirect_recur/indirect_recur_4.c +25 -0
  137. data/share/demo/intro_demo/intro_demo.c +76 -0
  138. data/share/demo/intro_demo/intro_demo.h +12 -0
  139. data/share/demo/intro_demo/useless_header.h +5 -0
  140. data/share/demo/invalid_call/invalid_call.c +32 -0
  141. data/share/demo/kandr_fundef/kandr_fundef.c +10 -0
  142. data/share/demo/line_comment/line_comment.c +12 -0
  143. data/share/demo/local_decl/local_decl.c +9 -0
  144. data/share/demo/logical_trick/logical_trick.c +36 -0
  145. data/share/demo/long_sym/long_sym.c +5 -0
  146. data/share/demo/loop_var/loop_var.c +92 -0
  147. data/share/demo/malloc_or_die/malloc_or_die.c +43 -0
  148. data/share/demo/may_be_null/may_be_null.c +52 -0
  149. data/share/demo/may_be_null_arith/may_be_null_arith.c +15 -0
  150. data/share/demo/may_be_unset/may_be_unset.c +34 -0
  151. data/share/demo/mmapped_io/mmapped_io.c +23 -0
  152. data/share/demo/multi_break/multi_break.c +33 -0
  153. data/share/demo/multi_decl/multi_decl_1.c +17 -0
  154. data/share/demo/multi_decl/multi_decl_1.h +6 -0
  155. data/share/demo/multi_decl/multi_decl_2.c +13 -0
  156. data/share/demo/multi_decl/multi_decl_2.h +6 -0
  157. data/share/demo/multi_decl/multi_decl_3.c +22 -0
  158. data/share/demo/multi_def/multi_def_1.c +36 -0
  159. data/share/demo/multi_def/multi_def_1.h +6 -0
  160. data/share/demo/multi_def/multi_def_2.c +22 -0
  161. data/share/demo/multi_def/multi_def_2.h +6 -0
  162. data/share/demo/multi_def/multi_def_3.c +6 -0
  163. data/share/demo/multi_typedef/multi_typedef.c +11 -0
  164. data/share/demo/multi_typedef/multi_typedef_1.h +1 -0
  165. data/share/demo/multi_typedef/multi_typedef_2.h +1 -0
  166. data/share/demo/must_be_false/must_be_false.c +53 -0
  167. data/share/demo/must_be_null/must_be_null.c +13 -0
  168. data/share/demo/must_be_null_arith/must_be_null_arith.c +14 -0
  169. data/share/demo/must_be_true/must_be_true.c +21 -0
  170. data/share/demo/no_eof_nl/no_eof_nl.c +4 -0
  171. data/share/demo/no_void_arg/no_void_arg.c +14 -0
  172. data/share/demo/null_stmt/null_stmt.c +19 -0
  173. data/share/demo/octal_const/octal_const.c +20 -0
  174. data/share/demo/output_by_param/output_by_param.c +17 -0
  175. data/share/demo/overflow/overflow.c +74 -0
  176. data/share/demo/press_release/press_release.c +40 -0
  177. data/share/demo/retn_lvar_addr/retn_lvar_addr.c +47 -0
  178. data/share/demo/shift_expr/shift_expr.c +14 -0
  179. data/share/demo/should_be_typedef/should_be_typedef.c +51 -0
  180. data/share/demo/static_paths/static_paths.c +153 -0
  181. data/share/demo/static_vars/static_vars.c +39 -0
  182. data/share/demo/tag_hiding/tag_hiding.c +18 -0
  183. data/share/demo/tricky_incdec/tricky_incdec.c +12 -0
  184. data/share/demo/undefined_macro/undefined_macro.c +17 -0
  185. data/share/demo/uninit_vars/uninit_vars.c +28 -0
  186. data/share/demo/union_type/union_type.c +23 -0
  187. data/share/demo/unmatch_decl/unmatch_decl_1.c +12 -0
  188. data/share/demo/unmatch_decl/unmatch_decl_1.h +8 -0
  189. data/share/demo/unmatch_decl/unmatch_decl_2.c +10 -0
  190. data/share/demo/unmatch_decl/unmatch_decl_2.h +8 -0
  191. data/share/demo/unmatch_decl/unmatch_decl_3.c +7 -0
  192. data/share/demo/unmatch_paren_macro/unmatch_paren_macro.c +15 -0
  193. data/share/demo/unreachable/unreachable.c +34 -0
  194. data/share/demo/useless_exp_funs/useless_exp_funs_1.c +14 -0
  195. data/share/demo/useless_exp_funs/useless_exp_funs_1.h +1 -0
  196. data/share/demo/useless_exp_funs/useless_exp_funs_2.c +6 -0
  197. data/share/demo/useless_exp_vars/useless_export_1.c +8 -0
  198. data/share/demo/useless_exp_vars/useless_export_1.h +1 -0
  199. data/share/demo/useless_exp_vars/useless_export_2.c +7 -0
  200. data/share/demo/useless_expr/useless_expr.c +17 -0
  201. data/share/demo/useless_funs/useless_funs_1.c +21 -0
  202. data/share/demo/useless_funs/useless_funs_1.h +8 -0
  203. data/share/demo/useless_funs/useless_funs_2.c +6 -0
  204. data/share/demo/useless_header/useless_header.c +9 -0
  205. data/share/demo/useless_header/useless_header_1.h +12 -0
  206. data/share/demo/useless_header/useless_header_2.h +6 -0
  207. data/share/demo/useless_header/useless_header_3.h +9 -0
  208. data/share/demo/useless_header/useless_header_4.h +3 -0
  209. data/share/demo/useless_vars/useless_vars.c +17 -0
  210. data/share/demo/va_funcall/va_funcall.c +25 -0
  211. data/share/demo/various_fundef/various_fundef.c +36 -0
  212. data/share/demo/wchar_wstring/wchar_wstring.c +7 -0
  213. data/share/demo/wrap_around/wrap_around.c +38 -0
  214. data/share/doc/Makefile +16 -0
  215. data/share/doc/adlint_on_adqua.png +0 -0
  216. data/share/doc/adlint_on_eclipse_en.png +0 -0
  217. data/share/doc/adlint_on_eclipse_ja.png +0 -0
  218. data/share/doc/adlint_on_vim_en.png +0 -0
  219. data/share/doc/adlint_on_vim_ja.png +0 -0
  220. data/share/doc/developers_guide_ja.html +171 -0
  221. data/share/doc/developers_guide_ja.texi +87 -0
  222. data/share/doc/gen_mesg_sections.rb +39 -0
  223. data/share/doc/samples/GNUmakefile +162 -0
  224. data/share/doc/samples/adlint_traits.yml +238 -0
  225. data/share/doc/texinfo.css +22 -0
  226. data/share/doc/users_guide_en.html +39975 -0
  227. data/share/doc/users_guide_en.texi +32640 -0
  228. data/share/doc/users_guide_ja.html +40505 -0
  229. data/share/doc/users_guide_ja.texi +33189 -0
  230. data/share/logo/adlint-110.png +0 -0
  231. data/share/logo/adlint-524.png +0 -0
  232. data/share/logo/adlint.svg +4637 -0
  233. data/share/sample/README +6 -0
  234. data/share/sample/bison-2.5/adlint/GNUmakefile +170 -0
  235. data/share/sample/bison-2.5/adlint/adlint_traits.yml +225 -0
  236. data/share/sample/bison-2.5/adlint/lib/GNUmakefile +198 -0
  237. data/share/sample/bison-2.5/adlint/lib/adlint_cinit.h +228 -0
  238. data/share/sample/bison-2.5/adlint/lib/adlint_pinit.h +21 -0
  239. data/share/sample/bison-2.5/adlint/lib/adlint_traits.yml +238 -0
  240. data/share/sample/bison-2.5/adlint/src/GNUmakefile +166 -0
  241. data/share/sample/bison-2.5/adlint/src/adlint_cinit.h +228 -0
  242. data/share/sample/bison-2.5/adlint/src/adlint_pinit.h +21 -0
  243. data/share/sample/bison-2.5/adlint/src/adlint_traits.yml +239 -0
  244. data/share/sample/ctags-5.8/adlint/GNUmakefile +169 -0
  245. data/share/sample/ctags-5.8/adlint/adlint_cinit.h +219 -0
  246. data/share/sample/ctags-5.8/adlint/adlint_pinit.h +13 -0
  247. data/share/sample/ctags-5.8/adlint/adlint_traits.yml +225 -0
  248. data/share/sample/flex-2.5.35/adlint/GNUmakefile +140 -0
  249. data/share/sample/flex-2.5.35/adlint/adlint_cinit.h +219 -0
  250. data/share/sample/flex-2.5.35/adlint/adlint_pinit.h +14 -0
  251. data/share/sample/flex-2.5.35/adlint/adlint_traits.yml +225 -0
  252. data/share/sample/ruby-1.9.3-p0/adlint/GNUmakefile +314 -0
  253. data/share/sample/ruby-1.9.3-p0/adlint/adlint_traits.yml +225 -0
  254. data/share/sample/ruby-1.9.3-p0/adlint/core/GNUmakefile +204 -0
  255. data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_cinit.h +228 -0
  256. data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_pinit.h +28 -0
  257. data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_traits.yml +240 -0
  258. data/share/sample/ruby-1.9.3-p0/adlint/enc/GNUmakefile +163 -0
  259. data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_cinit.h +228 -0
  260. data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_pinit.h +24 -0
  261. data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_traits.yml +240 -0
  262. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/GNUmakefile +149 -0
  263. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_cinit.h +228 -0
  264. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_pinit.h +24 -0
  265. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_traits.yml +240 -0
  266. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/GNUmakefile +131 -0
  267. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_cinit.h +228 -0
  268. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_pinit.h +24 -0
  269. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_traits.yml +241 -0
  270. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/GNUmakefile +131 -0
  271. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_cinit.h +228 -0
  272. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_pinit.h +24 -0
  273. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_traits.yml +241 -0
  274. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/GNUmakefile +131 -0
  275. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_cinit.h +228 -0
  276. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_pinit.h +24 -0
  277. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_traits.yml +241 -0
  278. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/GNUmakefile +131 -0
  279. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_cinit.h +228 -0
  280. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_pinit.h +24 -0
  281. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_traits.yml +241 -0
  282. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/GNUmakefile +134 -0
  283. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_cinit.h +228 -0
  284. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_pinit.h +24 -0
  285. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_traits.yml +241 -0
  286. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/GNUmakefile +131 -0
  287. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_cinit.h +228 -0
  288. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_pinit.h +24 -0
  289. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_traits.yml +241 -0
  290. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/GNUmakefile +131 -0
  291. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_cinit.h +228 -0
  292. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_pinit.h +24 -0
  293. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_traits.yml +241 -0
  294. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/GNUmakefile +131 -0
  295. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_cinit.h +228 -0
  296. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_pinit.h +24 -0
  297. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_traits.yml +242 -0
  298. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/GNUmakefile +132 -0
  299. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_cinit.h +228 -0
  300. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_pinit.h +24 -0
  301. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_traits.yml +242 -0
  302. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/GNUmakefile +132 -0
  303. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_cinit.h +228 -0
  304. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_pinit.h +24 -0
  305. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_traits.yml +242 -0
  306. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/GNUmakefile +132 -0
  307. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_cinit.h +228 -0
  308. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_pinit.h +24 -0
  309. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_traits.yml +242 -0
  310. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/GNUmakefile +132 -0
  311. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_cinit.h +228 -0
  312. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_pinit.h +24 -0
  313. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_traits.yml +242 -0
  314. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/GNUmakefile +134 -0
  315. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_cinit.h +228 -0
  316. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_pinit.h +24 -0
  317. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_traits.yml +241 -0
  318. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/GNUmakefile +140 -0
  319. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_cinit.h +228 -0
  320. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_pinit.h +24 -0
  321. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_traits.yml +242 -0
  322. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/GNUmakefile +131 -0
  323. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_cinit.h +228 -0
  324. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_pinit.h +24 -0
  325. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_traits.yml +241 -0
  326. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/GNUmakefile +131 -0
  327. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_cinit.h +228 -0
  328. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_pinit.h +24 -0
  329. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_traits.yml +241 -0
  330. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/GNUmakefile +131 -0
  331. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_cinit.h +228 -0
  332. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_pinit.h +24 -0
  333. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_traits.yml +241 -0
  334. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/GNUmakefile +134 -0
  335. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_cinit.h +228 -0
  336. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_pinit.h +24 -0
  337. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_traits.yml +242 -0
  338. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/GNUmakefile +131 -0
  339. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_cinit.h +228 -0
  340. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_pinit.h +24 -0
  341. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_traits.yml +241 -0
  342. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/GNUmakefile +131 -0
  343. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_cinit.h +228 -0
  344. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_pinit.h +24 -0
  345. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_traits.yml +241 -0
  346. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/GNUmakefile +131 -0
  347. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_cinit.h +228 -0
  348. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_pinit.h +24 -0
  349. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_traits.yml +241 -0
  350. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/GNUmakefile +131 -0
  351. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_cinit.h +228 -0
  352. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_pinit.h +24 -0
  353. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_traits.yml +241 -0
  354. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/GNUmakefile +131 -0
  355. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_cinit.h +228 -0
  356. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_pinit.h +24 -0
  357. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_traits.yml +241 -0
  358. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/GNUmakefile +131 -0
  359. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_cinit.h +228 -0
  360. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_pinit.h +24 -0
  361. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_traits.yml +241 -0
  362. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/GNUmakefile +131 -0
  363. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_cinit.h +228 -0
  364. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_pinit.h +24 -0
  365. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_traits.yml +241 -0
  366. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/GNUmakefile +131 -0
  367. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_cinit.h +228 -0
  368. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_pinit.h +24 -0
  369. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_traits.yml +241 -0
  370. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/GNUmakefile +131 -0
  371. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_cinit.h +228 -0
  372. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_pinit.h +24 -0
  373. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_traits.yml +241 -0
  374. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/GNUmakefile +131 -0
  375. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_cinit.h +228 -0
  376. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_pinit.h +24 -0
  377. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_traits.yml +241 -0
  378. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/GNUmakefile +162 -0
  379. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_cinit.h +228 -0
  380. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_pinit.h +24 -0
  381. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_traits.yml +241 -0
  382. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/GNUmakefile +131 -0
  383. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_cinit.h +228 -0
  384. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_pinit.h +24 -0
  385. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_traits.yml +241 -0
  386. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/GNUmakefile +135 -0
  387. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_cinit.h +228 -0
  388. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_pinit.h +24 -0
  389. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_traits.yml +241 -0
  390. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/GNUmakefile +131 -0
  391. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_cinit.h +228 -0
  392. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_pinit.h +24 -0
  393. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_traits.yml +241 -0
  394. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/GNUmakefile +131 -0
  395. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_cinit.h +228 -0
  396. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_pinit.h +24 -0
  397. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_traits.yml +241 -0
  398. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/GNUmakefile +131 -0
  399. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_cinit.h +228 -0
  400. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_pinit.h +24 -0
  401. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_traits.yml +241 -0
  402. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/GNUmakefile +131 -0
  403. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_cinit.h +228 -0
  404. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_pinit.h +24 -0
  405. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_traits.yml +241 -0
  406. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/GNUmakefile +132 -0
  407. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_cinit.h +228 -0
  408. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_pinit.h +24 -0
  409. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_traits.yml +241 -0
  410. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/GNUmakefile +144 -0
  411. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_cinit.h +228 -0
  412. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_pinit.h +24 -0
  413. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_traits.yml +241 -0
  414. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/GNUmakefile +131 -0
  415. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_cinit.h +228 -0
  416. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_pinit.h +24 -0
  417. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_traits.yml +241 -0
  418. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/GNUmakefile +131 -0
  419. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_cinit.h +228 -0
  420. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_pinit.h +24 -0
  421. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_traits.yml +241 -0
  422. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/GNUmakefile +140 -0
  423. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_cinit.h +228 -0
  424. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_pinit.h +24 -0
  425. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_traits.yml +241 -0
  426. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/GNUmakefile +131 -0
  427. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_cinit.h +228 -0
  428. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_pinit.h +24 -0
  429. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_traits.yml +241 -0
  430. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/GNUmakefile +131 -0
  431. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_cinit.h +228 -0
  432. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_pinit.h +24 -0
  433. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_traits.yml +241 -0
  434. data/share/sample/screen-4.0.3/adlint/GNUmakefile +162 -0
  435. data/share/sample/screen-4.0.3/adlint/adlint_cinit.h +228 -0
  436. data/share/sample/screen-4.0.3/adlint/adlint_pinit.h +21 -0
  437. data/share/sample/screen-4.0.3/adlint/adlint_traits.yml +238 -0
  438. data/share/sample/vim-7.3/adlint/vim/GNUmakefile +185 -0
  439. data/share/sample/vim-7.3/adlint/vim/adlint_cinit.h +228 -0
  440. data/share/sample/vim-7.3/adlint/vim/adlint_pinit.h +25 -0
  441. data/share/sample/vim-7.3/adlint/vim/adlint_traits.yml +250 -0
  442. data/share/sample/vim-7.3/adlint/xxd/GNUmakefile +131 -0
  443. data/share/sample/vim-7.3/adlint/xxd/adlint_cinit.h +228 -0
  444. data/share/sample/vim-7.3/adlint/xxd/adlint_pinit.h +24 -0
  445. data/share/sample/vim-7.3/adlint/xxd/adlint_traits.yml +237 -0
  446. data/share/sample/zsh-4.3.15/adlint/GNUmakefile +146 -0
  447. data/share/sample/zsh-4.3.15/adlint/adlint_traits.yml +225 -0
  448. data/share/sample/zsh-4.3.15/adlint/builtins/GNUmakefile +132 -0
  449. data/share/sample/zsh-4.3.15/adlint/builtins/adlint_cinit.h +228 -0
  450. data/share/sample/zsh-4.3.15/adlint/builtins/adlint_pinit.h +24 -0
  451. data/share/sample/zsh-4.3.15/adlint/builtins/adlint_traits.yml +240 -0
  452. data/share/sample/zsh-4.3.15/adlint/core/GNUmakefile +153 -0
  453. data/share/sample/zsh-4.3.15/adlint/core/adlint_cinit.h +228 -0
  454. data/share/sample/zsh-4.3.15/adlint/core/adlint_pinit.h +23 -0
  455. data/share/sample/zsh-4.3.15/adlint/core/adlint_traits.yml +239 -0
  456. data/share/sample/zsh-4.3.15/adlint/modules/GNUmakefile +147 -0
  457. data/share/sample/zsh-4.3.15/adlint/modules/adlint_cinit.h +228 -0
  458. data/share/sample/zsh-4.3.15/adlint/modules/adlint_pinit.h +24 -0
  459. data/share/sample/zsh-4.3.15/adlint/modules/adlint_traits.yml +240 -0
  460. data/share/sample/zsh-4.3.15/adlint/zle/GNUmakefile +144 -0
  461. data/share/sample/zsh-4.3.15/adlint/zle/adlint_cinit.h +228 -0
  462. data/share/sample/zsh-4.3.15/adlint/zle/adlint_pinit.h +24 -0
  463. data/share/sample/zsh-4.3.15/adlint/zle/adlint_traits.yml +239 -0
  464. data/spec/MUST_WRITE_SPECS_WITH_RSPEC +0 -0
  465. metadata +532 -0
@@ -0,0 +1,765 @@
1
+ # Quality metric measurement classes for C language.
2
+ #
3
+ # Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
4
+ # Copyright:: Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
5
+ # License:: GPLv3+: GNU General Public License version 3 or later
6
+ #
7
+ # Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
8
+
9
+ #--
10
+ # ___ ____ __ ___ _________
11
+ # / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
12
+ # / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
13
+ # / __ |/ /_/ / /___/ / /| / / /
14
+ # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
15
+ #
16
+ # This file is part of AdLint.
17
+ #
18
+ # AdLint is free software: you can redistribute it and/or modify it under the
19
+ # terms of the GNU General Public License as published by the Free Software
20
+ # Foundation, either version 3 of the License, or (at your option) any later
21
+ # version.
22
+ #
23
+ # AdLint is distributed in the hope that it will be useful, but WITHOUT ANY
24
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
25
+ # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
26
+ #
27
+ # You should have received a copy of the GNU General Public License along with
28
+ # AdLint. If not, see <http://www.gnu.org/licenses/>.
29
+ #
30
+ #++
31
+
32
+ require "adlint/report"
33
+ require "adlint/metric"
34
+
35
+ module AdLint #:nodoc:
36
+ module C #:nodoc:
37
+
38
+ class FL_STMT < MetricMeasurement
39
+ def initialize(context)
40
+ super
41
+ @fpath = context[:sources].first.fpath
42
+ visitor = context[:c_visitor]
43
+ visitor.enter_error_statement += method(:count_statement)
44
+ visitor.enter_generic_labeled_statement += method(:count_statement)
45
+ visitor.enter_case_labeled_statement += method(:count_statement)
46
+ visitor.enter_default_labeled_statement += method(:count_statement)
47
+ visitor.enter_expression_statement += method(:count_statement)
48
+ visitor.enter_if_statement += method(:count_statement)
49
+ visitor.enter_if_else_statement += method(:count_statement)
50
+ visitor.enter_switch_statement += method(:count_statement)
51
+ visitor.enter_while_statement += method(:count_statement)
52
+ visitor.enter_do_statement += method(:count_statement)
53
+ visitor.enter_for_statement += method(:count_statement)
54
+ visitor.enter_c99_for_statement += method(:count_statement)
55
+ visitor.enter_goto_statement += method(:count_statement)
56
+ visitor.enter_continue_statement += method(:count_statement)
57
+ visitor.enter_break_statement += method(:count_statement)
58
+ visitor.enter_return_statement += method(:count_statement)
59
+ visitor.leave_translation_unit += method(:measure)
60
+ @statement_count = 0
61
+ end
62
+
63
+ private
64
+ def do_prepare(context) end
65
+ def do_execute(context) end
66
+
67
+ def count_statement(statement)
68
+ if @fpath == statement.location.fpath
69
+ @statement_count += 1
70
+ end
71
+ end
72
+
73
+ def measure(node)
74
+ FL_STMT(@fpath, @statement_count)
75
+ end
76
+ end
77
+
78
+ class FL_FUNC < MetricMeasurement
79
+ def initialize(context)
80
+ super
81
+ @fpath = context[:sources].first.fpath
82
+ visitor = context[:c_visitor]
83
+ visitor.enter_ansi_function_definition += method(:count_function)
84
+ visitor.enter_kandr_function_definition += method(:count_function)
85
+ visitor.leave_translation_unit += method(:measure)
86
+ @function_count = 0
87
+ end
88
+
89
+ private
90
+ def do_prepare(context) end
91
+ def do_execute(context) end
92
+
93
+ def count_function(function_definition)
94
+ if @fpath == function_definition.location.fpath
95
+ @function_count += 1
96
+ end
97
+ end
98
+
99
+ def measure(node)
100
+ FL_FUNC(@fpath, @function_count)
101
+ end
102
+ end
103
+
104
+ class FN_STMT < MetricMeasurement
105
+ def initialize(context)
106
+ super
107
+ @fpath = context[:sources].first.fpath
108
+ visitor = context[:c_visitor]
109
+ visitor.enter_ansi_function_definition += method(:enter_function)
110
+ visitor.leave_ansi_function_definition += method(:leave_function)
111
+ visitor.enter_kandr_function_definition += method(:enter_function)
112
+ visitor.leave_kandr_function_definition += method(:leave_function)
113
+ visitor.enter_error_statement += method(:count_statement)
114
+ visitor.enter_generic_labeled_statement += method(:count_statement)
115
+ visitor.enter_case_labeled_statement += method(:count_statement)
116
+ visitor.enter_default_labeled_statement += method(:count_statement)
117
+ visitor.enter_expression_statement += method(:count_statement)
118
+ visitor.enter_if_statement += method(:count_statement)
119
+ visitor.enter_if_else_statement += method(:count_statement)
120
+ visitor.enter_switch_statement += method(:count_statement)
121
+ visitor.enter_while_statement += method(:count_statement)
122
+ visitor.enter_do_statement += method(:count_statement)
123
+ visitor.enter_for_statement += method(:count_statement)
124
+ visitor.enter_c99_for_statement += method(:count_statement)
125
+ visitor.enter_goto_statement += method(:count_statement)
126
+ visitor.enter_continue_statement += method(:count_statement)
127
+ visitor.enter_break_statement += method(:count_statement)
128
+ visitor.enter_return_statement += method(:count_statement)
129
+ @current_function = nil
130
+ @statement_count = 0
131
+ end
132
+
133
+ private
134
+ def do_prepare(context) end
135
+ def do_execute(context) end
136
+
137
+ def enter_function(function_definition)
138
+ if @fpath == function_definition.location.fpath
139
+ @current_function = function_definition
140
+ @statement_count = 0
141
+ end
142
+ end
143
+
144
+ def leave_function(function_definition)
145
+ return unless @current_function
146
+
147
+ FN_STMT(FunctionIdentifier.new(@current_function.identifier.value,
148
+ @current_function.signature),
149
+ @current_function.location, @statement_count)
150
+
151
+ @current_function = nil
152
+ @statement_count = 0
153
+ end
154
+
155
+ def count_statement(statement)
156
+ if @current_function
157
+ @statement_count += 1
158
+ end
159
+ end
160
+ end
161
+
162
+ class FN_UNRC < MetricMeasurement
163
+ def initialize(context)
164
+ super
165
+ @fpath = context[:sources].first.fpath
166
+ visitor = context[:c_visitor]
167
+ visitor.enter_ansi_function_definition += method(:enter_function)
168
+ visitor.leave_ansi_function_definition += method(:leave_function)
169
+ visitor.enter_kandr_function_definition += method(:enter_function)
170
+ visitor.leave_kandr_function_definition += method(:leave_function)
171
+ visitor.enter_error_statement += method(:count_statement)
172
+ visitor.enter_generic_labeled_statement += method(:count_statement)
173
+ visitor.enter_case_labeled_statement += method(:count_statement)
174
+ visitor.enter_default_labeled_statement += method(:count_statement)
175
+ visitor.enter_expression_statement += method(:count_statement)
176
+ visitor.enter_if_statement += method(:count_statement)
177
+ visitor.enter_if_else_statement += method(:count_statement)
178
+ visitor.enter_switch_statement += method(:count_statement)
179
+ visitor.enter_while_statement += method(:count_statement)
180
+ visitor.enter_do_statement += method(:count_statement)
181
+ visitor.enter_for_statement += method(:count_statement)
182
+ visitor.enter_c99_for_statement += method(:count_statement)
183
+ visitor.enter_goto_statement += method(:count_statement)
184
+ visitor.enter_continue_statement += method(:count_statement)
185
+ visitor.enter_break_statement += method(:count_statement)
186
+ visitor.enter_return_statement += method(:count_statement)
187
+ @current_function = nil
188
+ @unreached_statement_count = 0
189
+ end
190
+
191
+ private
192
+ def do_prepare(context) end
193
+ def do_execute(context) end
194
+
195
+ def enter_function(function_definition)
196
+ if @fpath == function_definition.location.fpath
197
+ @current_function = function_definition
198
+ @unreached_statement_count = 0
199
+ end
200
+ end
201
+
202
+ def leave_function(function_definition)
203
+ return unless @current_function
204
+
205
+ FN_UNRC(FunctionIdentifier.new(@current_function.identifier.value,
206
+ @current_function.signature.to_s),
207
+ @current_function.location, @unreached_statement_count)
208
+
209
+ @current_function = nil
210
+ @unreached_statement_count = 0
211
+ end
212
+
213
+ def count_statement(statement)
214
+ return unless @current_function
215
+
216
+ unless statement.executed?
217
+ @unreached_statement_count += 1
218
+ end
219
+ end
220
+ end
221
+
222
+ class FN_LINE < MetricMeasurement
223
+ def initialize(context)
224
+ super
225
+ @fpath = context[:sources].first.fpath
226
+ visitor = context[:c_visitor]
227
+ visitor.enter_ansi_function_definition += method(:measure)
228
+ visitor.enter_kandr_function_definition += method(:measure)
229
+ end
230
+
231
+ private
232
+ def do_prepare(context) end
233
+ def do_execute(context) end
234
+
235
+ def measure(function_definition)
236
+ if @fpath == function_definition.location.fpath
237
+ FN_LINE(FunctionIdentifier.new(function_definition.identifier.value,
238
+ function_definition.signature.to_s),
239
+ function_definition.location, function_definition.lines)
240
+ end
241
+ end
242
+ end
243
+
244
+ class FN_PARA < MetricMeasurement
245
+ def initialize(context)
246
+ super
247
+ @fpath = context[:sources].first.fpath
248
+ visitor = context[:c_visitor]
249
+ visitor.enter_ansi_function_definition += method(:measure_ansi_func)
250
+ visitor.enter_kandr_function_definition += method(:measure_kandr_func)
251
+ end
252
+
253
+ private
254
+ def do_prepare(context) end
255
+ def do_execute(context) end
256
+
257
+ def measure_ansi_func(function_definition)
258
+ if @fpath == function_definition.location.fpath
259
+ # TODO: Determine how many parameters if function has va_list.
260
+ if function_definition.parameter_type_list
261
+ parameters = function_definition.parameter_definitions
262
+ FN_PARA(FunctionIdentifier.new(function_definition.identifier.value,
263
+ function_definition.signature.to_s),
264
+ function_definition.location,
265
+ parameters.count { |param| !param.type.void? })
266
+ else
267
+ # TODO: Determine how many parameters if signature is abbreviated.
268
+ FN_PARA(FunctionIdentifier.new(function_definition.identifier.value,
269
+ function_definition.signature.to_s),
270
+ function_definition.location, 0)
271
+ end
272
+ end
273
+ end
274
+
275
+ def measure_kandr_func(function_definition)
276
+ if @fpath == function_definition.location.fpath
277
+ FN_PARA(FunctionIdentifier.new(function_definition.identifier.value,
278
+ function_definition.signature.to_s),
279
+ function_definition.location,
280
+ function_definition.identifier_list.size)
281
+ end
282
+ end
283
+ end
284
+
285
+ class FN_UNUV < MetricMeasurement
286
+ def initialize(context)
287
+ super
288
+ @fpath = context[:sources].first.fpath
289
+ interp = context[:c_interpreter]
290
+ interp.on_function_started += method(:enter_function)
291
+ interp.on_function_ended += method(:leave_function)
292
+ interp.on_variable_defined += method(:define_variable)
293
+ interp.on_parameter_defined += method(:define_variable)
294
+ interp.on_variable_value_referred += method(:read_variable)
295
+ interp.on_variable_value_updated += method(:write_variable)
296
+ @current_function = nil
297
+ @variables = nil
298
+ end
299
+
300
+ private
301
+ def do_prepare(context) end
302
+ def do_execute(context) end
303
+
304
+ def enter_function(function_definition)
305
+ if @fpath == function_definition.location.fpath
306
+ @current_function = function_definition
307
+ @variables = {}
308
+ end
309
+ end
310
+
311
+ def leave_function(function_definition)
312
+ return unless @current_function
313
+
314
+ useless_count = @variables.each_value.reduce(0) { |count, read_count|
315
+ read_count == 0 ? count + 1 : count
316
+ }
317
+
318
+ FN_UNUV(FunctionIdentifier.new(@current_function.identifier.value,
319
+ @current_function.signature.to_s),
320
+ @current_function.location, useless_count)
321
+
322
+ @current_function = nil
323
+ @variables = nil
324
+ end
325
+
326
+ def define_variable(definition, variable)
327
+ if @current_function
328
+ @variables[variable.name] = 0
329
+ end
330
+ end
331
+
332
+ def read_variable(expression, variable)
333
+ return unless @current_function
334
+
335
+ if variable.named? && @variables[variable.name]
336
+ @variables[variable.name] += 1
337
+ end
338
+ end
339
+
340
+ def write_variable(expression, variable)
341
+ return unless @current_function
342
+
343
+ if variable.named? && @variables[variable.name]
344
+ @variables[variable.name] = 0
345
+ end
346
+ end
347
+ end
348
+
349
+ class FN_CSUB < MetricMeasurement
350
+ def initialize(context)
351
+ super
352
+ @fpath = context[:sources].first.fpath
353
+ visitor = context[:c_visitor]
354
+ visitor.enter_ansi_function_definition += method(:enter_function)
355
+ visitor.leave_ansi_function_definition += method(:leave_function)
356
+ visitor.enter_kandr_function_definition += method(:enter_function)
357
+ visitor.leave_kandr_function_definition += method(:leave_function)
358
+ visitor.enter_function_call_expression += method(:count_function_call)
359
+ @current_function = nil
360
+ @function_call_count = 0
361
+ end
362
+
363
+ private
364
+ def do_prepare(context) end
365
+ def do_execute(context) end
366
+
367
+ def enter_function(function_definition)
368
+ if @fpath == function_definition.location.fpath
369
+ @current_function = function_definition
370
+ @function_call_count = 0
371
+ end
372
+ end
373
+
374
+ def leave_function(function_definition)
375
+ return unless @current_function
376
+
377
+ FN_CSUB(FunctionIdentifier.new(@current_function.identifier.value,
378
+ @current_function.signature.to_s),
379
+ @current_function.location, @function_call_count)
380
+
381
+ @current_function = nil
382
+ @function_call_count = 0
383
+ end
384
+
385
+ def count_function_call(node)
386
+ if @current_function
387
+ @function_call_count += 1
388
+ end
389
+ end
390
+ end
391
+
392
+ class FN_GOTO < MetricMeasurement
393
+ def initialize(context)
394
+ super
395
+ @fpath = context[:sources].first.fpath
396
+ visitor = context[:c_visitor]
397
+ visitor.enter_ansi_function_definition += method(:enter_function)
398
+ visitor.leave_ansi_function_definition += method(:leave_function)
399
+ visitor.enter_kandr_function_definition += method(:enter_function)
400
+ visitor.leave_kandr_function_definition += method(:leave_function)
401
+ visitor.enter_goto_statement += method(:count_goto)
402
+ @current_function = nil
403
+ @goto_count = 0
404
+ end
405
+
406
+ private
407
+ def do_prepare(context) end
408
+ def do_execute(context) end
409
+
410
+ def enter_function(function_definition)
411
+ if @fpath == function_definition.location.fpath
412
+ @current_function = function_definition
413
+ @goto_count = 0
414
+ end
415
+ end
416
+
417
+ def leave_function(function_definition)
418
+ return unless @current_function
419
+
420
+ FN_GOTO(FunctionIdentifier.new(@current_function.identifier.value,
421
+ @current_function.signature.to_s),
422
+ @current_function.location, @goto_count)
423
+
424
+ @current_function = nil
425
+ @goto_count = 0
426
+ end
427
+
428
+ def count_goto(node)
429
+ if @current_function
430
+ @goto_count += 1
431
+ end
432
+ end
433
+ end
434
+
435
+ class FN_RETN < MetricMeasurement
436
+ def initialize(context)
437
+ super
438
+ @fpath = context[:sources].first.fpath
439
+ visitor = context[:c_visitor]
440
+ visitor.enter_ansi_function_definition += method(:enter_function)
441
+ visitor.leave_ansi_function_definition += method(:leave_function)
442
+ visitor.enter_kandr_function_definition += method(:enter_function)
443
+ visitor.leave_kandr_function_definition += method(:leave_function)
444
+ visitor.enter_error_statement += method(:enter_statement)
445
+ visitor.enter_generic_labeled_statement += method(:enter_statement)
446
+ visitor.enter_case_labeled_statement += method(:enter_statement)
447
+ visitor.enter_default_labeled_statement += method(:enter_statement)
448
+ visitor.enter_expression_statement += method(:enter_statement)
449
+ visitor.enter_if_statement += method(:enter_statement)
450
+ visitor.enter_if_else_statement += method(:enter_statement)
451
+ visitor.enter_switch_statement += method(:enter_statement)
452
+ visitor.enter_while_statement += method(:enter_statement)
453
+ visitor.enter_do_statement += method(:enter_statement)
454
+ visitor.enter_for_statement += method(:enter_statement)
455
+ visitor.enter_c99_for_statement += method(:enter_statement)
456
+ visitor.enter_goto_statement += method(:enter_statement)
457
+ visitor.enter_continue_statement += method(:enter_statement)
458
+ visitor.enter_break_statement += method(:enter_statement)
459
+ visitor.enter_return_statement += method(:count_return)
460
+ @current_function = nil
461
+ @return_count = 0
462
+ @last_statement = nil
463
+ end
464
+
465
+ private
466
+ def do_prepare(context) end
467
+ def do_execute(context) end
468
+
469
+ def enter_function(function_definition)
470
+ if @fpath == function_definition.location.fpath
471
+ @current_function = function_definition
472
+ @return_count = 0
473
+ @last_statement = nil
474
+ end
475
+ end
476
+
477
+ def leave_function(function_definition)
478
+ return unless @current_function
479
+
480
+ if @current_function.type.return_type.void? &&
481
+ !(@last_statement.kind_of?(ReturnStatement))
482
+ FN_RETN(FunctionIdentifier.new(@current_function.identifier.value,
483
+ @current_function.signature.to_s),
484
+ @current_function.location, @return_count + 1)
485
+ else
486
+ FN_RETN(FunctionIdentifier.new(@current_function.identifier.value,
487
+ @current_function.signature.to_s),
488
+ @current_function.location, @return_count)
489
+ end
490
+
491
+ @current_function = nil
492
+ @return_count = 0
493
+ @last_statement = nil
494
+ end
495
+
496
+ def enter_statement(node)
497
+ return unless @current_function
498
+
499
+ if node.executed?
500
+ @last_statement = node
501
+ end
502
+ end
503
+
504
+ def count_return(node)
505
+ if @current_function
506
+ @return_count += 1
507
+ @last_statement = node
508
+ end
509
+ end
510
+ end
511
+
512
+ class FN_UELS < MetricMeasurement
513
+ def initialize(context)
514
+ super
515
+ @fpath = context[:sources].first.fpath
516
+ visitor = context[:c_visitor]
517
+ visitor.enter_ansi_function_definition += method(:enter_function)
518
+ visitor.leave_ansi_function_definition += method(:leave_function)
519
+ visitor.enter_kandr_function_definition += method(:enter_function)
520
+ visitor.leave_kandr_function_definition += method(:leave_function)
521
+ visitor.enter_if_statement += method(:count_if_statement)
522
+ @current_function = nil
523
+ @if_statement_count = 0
524
+ end
525
+
526
+ private
527
+ def do_prepare(context) end
528
+ def do_execute(context) end
529
+
530
+ def enter_function(function_definition)
531
+ if @fpath == function_definition.location.fpath
532
+ @current_function = function_definition
533
+ @if_statement_count = 0
534
+ end
535
+ end
536
+
537
+ def leave_function(function_definition)
538
+ return unless @current_function
539
+
540
+ FN_UELS(FunctionIdentifier.new(@current_function.identifier.value,
541
+ @current_function.signature.to_s),
542
+ @current_function.location, @if_statement_count)
543
+
544
+ @current_function = nil
545
+ @if_statement_count = 0
546
+ end
547
+
548
+ def count_if_statement(node)
549
+ if @current_function
550
+ @if_statement_count += 1
551
+ end
552
+ end
553
+ end
554
+
555
+ class FN_NEST < MetricMeasurement
556
+ def initialize(context)
557
+ super
558
+ @fpath = context[:sources].first.fpath
559
+ visitor = context[:c_visitor]
560
+ visitor.enter_ansi_function_definition += method(:enter_function)
561
+ visitor.leave_ansi_function_definition += method(:leave_function)
562
+ visitor.enter_kandr_function_definition += method(:enter_function)
563
+ visitor.leave_kandr_function_definition += method(:leave_function)
564
+ visitor.enter_compound_statement += method(:enter_block)
565
+ visitor.leave_compound_statement += method(:leave_block)
566
+ visitor.enter_if_statement += method(:check_statement)
567
+ visitor.enter_if_else_statement += method(:check_statement)
568
+ visitor.enter_while_statement += method(:check_statement)
569
+ visitor.enter_do_statement += method(:check_statement)
570
+ visitor.enter_for_statement += method(:check_statement)
571
+ visitor.enter_c99_for_statement += method(:check_statement)
572
+ @current_function = nil
573
+ end
574
+
575
+ private
576
+ def do_prepare(context) end
577
+ def do_execute(context) end
578
+
579
+ def enter_function(function_definition)
580
+ if @fpath == function_definition.location.fpath
581
+ @current_function = function_definition
582
+ # NOTE: Nest level of the top of the function is 0.
583
+ # Function definition must have a compound-statement as the
584
+ # function body.
585
+ @max_nest_level = @current_nest_level = -1
586
+ end
587
+ end
588
+
589
+ def leave_function(function_definition)
590
+ return unless @current_function
591
+
592
+ FN_NEST(FunctionIdentifier.new(@current_function.identifier.value,
593
+ @current_function.signature.to_s),
594
+ @current_function.location, @max_nest_level)
595
+
596
+ @current_function = nil
597
+ end
598
+
599
+ def enter_block(compound_statement)
600
+ if @current_function
601
+ @current_nest_level += 1
602
+ @max_nest_level = [@max_nest_level, @current_nest_level].max
603
+ end
604
+ end
605
+
606
+ def leave_block(compound_statement)
607
+ if @current_function
608
+ @current_nest_level -= 1
609
+ end
610
+ end
611
+
612
+ def check_statement(statement)
613
+ return unless @current_function
614
+
615
+ case statement
616
+ when IfStatement
617
+ sub_statement = statement.statement
618
+ when IfElseStatement
619
+ if statement.then_statement.kind_of?(CompoundStatement)
620
+ sub_statement = statement.else_statement
621
+ else
622
+ sub_statement = statement.then_statement
623
+ end
624
+ when WhileStatement, DoStatement
625
+ sub_statement = statement.statement
626
+ when ForStatement, C99ForStatement
627
+ sub_statement = statement.body_statement
628
+ end
629
+
630
+ case sub_statement
631
+ when CompoundStatement, IfStatement, IfElseStatement
632
+ else
633
+ @current_nest_level += 1
634
+ @max_nest_level = [@max_nest_level, @current_nest_level].max
635
+ end
636
+ end
637
+ end
638
+
639
+ class FN_PATH < MetricMeasurement
640
+ def initialize(context)
641
+ super
642
+ @fpath = context[:sources].first.fpath
643
+ interp = context[:c_interpreter]
644
+ interp.on_function_started += method(:enter_function)
645
+ interp.on_function_ended += method(:leave_function)
646
+ interp.on_branch_started += method(:enter_branch)
647
+ interp.on_branch_ended += method(:leave_branch)
648
+ @current_function = nil
649
+ end
650
+
651
+ private
652
+ def do_prepare(context) end
653
+ def do_execute(context) end
654
+
655
+ def enter_function(function_definition)
656
+ if @fpath == function_definition.location.fpath
657
+ @current_function = function_definition
658
+
659
+ # NOTE: Number of paths in the current function.
660
+ @paths_in_function = 1
661
+ # NOTE: Stack of the number of paths to enter the current branch group.
662
+ @paths_to_enter_branch_group = [@paths_in_function]
663
+ # NOTE: Stack of the number of paths in the current branch.
664
+ @paths_in_branch = [@paths_in_function]
665
+ # NOTE: Stack of the number of paths in the current branch group.
666
+ @paths_in_branch_group = [@paths_in_function]
667
+ end
668
+ end
669
+
670
+ def leave_function(function_definition)
671
+ return unless @current_function
672
+
673
+ FN_PATH(FunctionIdentifier.new(@current_function.identifier.value,
674
+ @current_function.signature.to_s),
675
+ @current_function.location, @paths_in_function)
676
+
677
+ @current_function = nil
678
+ end
679
+
680
+ def enter_branch(branch)
681
+ return unless @current_function
682
+
683
+ # NOTE: Entering into new branch group.
684
+ if branch.first?
685
+ @paths_in_function -= @paths_in_branch.last
686
+ @paths_to_enter_branch_group.push(@paths_in_branch.last)
687
+ @paths_in_branch_group.push(0)
688
+ end
689
+
690
+ # NOTE: Entering into new branch.
691
+ @paths_in_branch.push(@paths_to_enter_branch_group.last)
692
+ @paths_in_function += @paths_to_enter_branch_group.last
693
+ end
694
+
695
+ def leave_branch(branch)
696
+ return unless @current_function
697
+
698
+ paths_in_this_branch = @paths_in_branch.pop
699
+
700
+ # NOTE: Leaving from the current branch whose paths are not terminated.
701
+ unless branch.break_with_return?
702
+ @paths_in_branch_group[-1] += paths_in_this_branch
703
+ end
704
+
705
+ # NOTE: Leaving from the current branch group.
706
+ if branch.final?
707
+ paths_to_enter_this_branch_group = @paths_to_enter_branch_group.pop
708
+ paths_in_this_branch_group = @paths_in_branch_group.pop
709
+
710
+ @paths_in_branch[-1] = paths_in_this_branch_group
711
+
712
+ # NOTE: The current branch group is an incomplete branch group.
713
+ unless branch.group.complete?
714
+ @paths_in_function += paths_to_enter_this_branch_group
715
+ @paths_in_branch[-1] += paths_to_enter_this_branch_group
716
+ end
717
+ end
718
+ end
719
+ end
720
+
721
+ class FN_CYCM < MetricMeasurement
722
+ def initialize(context)
723
+ super
724
+ @fpath = context[:sources].first.fpath
725
+ visitor = context[:c_visitor]
726
+ visitor.enter_ansi_function_definition += method(:enter_function)
727
+ visitor.leave_ansi_function_definition += method(:leave_function)
728
+ visitor.enter_kandr_function_definition += method(:enter_function)
729
+ visitor.leave_kandr_function_definition += method(:leave_function)
730
+ visitor.enter_if_statement += method(:enter_selection)
731
+ visitor.enter_if_else_statement += method(:enter_selection)
732
+ visitor.enter_case_labeled_statement += method(:enter_selection)
733
+ @current_function = nil
734
+ @complexity = 0
735
+ end
736
+
737
+ private
738
+ def do_prepare(context) end
739
+ def do_execute(context) end
740
+
741
+ def enter_function(function_definition)
742
+ if @fpath == function_definition.location.fpath
743
+ @current_function = function_definition
744
+ @complexity = 0
745
+ end
746
+ end
747
+
748
+ def leave_function(function_definition)
749
+ return unless @current_function
750
+
751
+ FN_CYCM(FunctionIdentifier.new(@current_function.identifier.value,
752
+ @current_function.signature.to_s),
753
+ @current_function.location, @complexity + 1)
754
+
755
+ @current_function = nil
756
+ @total_branch_count = 0
757
+ end
758
+
759
+ def enter_selection(if_statement)
760
+ @complexity += 1 if @current_function
761
+ end
762
+ end
763
+
764
+ end
765
+ end