adlint 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +27 -0
- data/COPYING +674 -0
- data/ChangeLog +820 -0
- data/INSTALL +78 -0
- data/MANIFEST +464 -0
- data/NEWS +38 -0
- data/README +74 -0
- data/Rakefile +167 -0
- data/TODO +29 -0
- data/bin/adlint +141 -0
- data/bin/adlint_chk +129 -0
- data/bin/adlint_cma +122 -0
- data/bin/adlint_sma +129 -0
- data/bin/adlintize +286 -0
- data/etc/conf.d/fallback/cinit.erb +11 -0
- data/etc/conf.d/fallback/traits.erb +216 -0
- data/etc/conf.d/i686-cygwin/cinit-gcc_4.3.4.erb +149 -0
- data/etc/conf.d/i686-cygwin/traits-gcc_4.3.4.erb +227 -0
- data/etc/conf.d/i686-devkit/cinit-gcc_4.5.2.erb +224 -0
- data/etc/conf.d/i686-devkit/traits-gcc_4.5.2.erb +226 -0
- data/etc/conf.d/i686-linux/cinit-gcc_4.5.1.erb +219 -0
- data/etc/conf.d/i686-linux/traits-gcc_4.5.1.erb +224 -0
- data/etc/conf.d/i686-mingw/cinit-gcc_4.6.1.erb +234 -0
- data/etc/conf.d/i686-mingw/traits-gcc_4.6.1.erb +226 -0
- data/etc/conf.d/noarch/GNUmakefile.erb +119 -0
- data/etc/conf.d/noarch/adlint_all_bat.erb +9 -0
- data/etc/conf.d/noarch/adlint_all_sh.erb +10 -0
- data/etc/conf.d/noarch/pinit.erb +11 -0
- data/etc/mesg.d/en_US/messages.yml +784 -0
- data/etc/mesg.d/ja_JP/messages.yml +784 -0
- data/lib/adlint/analyzer.rb +294 -0
- data/lib/adlint/c/branch.rb +251 -0
- data/lib/adlint/c/builtin.rb +92 -0
- data/lib/adlint/c/code.rb +490 -0
- data/lib/adlint/c/const.rb +465 -0
- data/lib/adlint/c/conv.rb +212 -0
- data/lib/adlint/c/ctrlexpr.rb +949 -0
- data/lib/adlint/c/domain.rb +7499 -0
- data/lib/adlint/c/environ.rb +133 -0
- data/lib/adlint/c/expr.rb +1725 -0
- data/lib/adlint/c/format.rb +3209 -0
- data/lib/adlint/c/interp.rb +1740 -0
- data/lib/adlint/c/lexer.rb +241 -0
- data/lib/adlint/c/mediator.rb +313 -0
- data/lib/adlint/c/message.rb +13597 -0
- data/lib/adlint/c/metric.rb +765 -0
- data/lib/adlint/c/object.rb +1018 -0
- data/lib/adlint/c/parser.rb +3800 -0
- data/lib/adlint/c/parser.y +2054 -0
- data/lib/adlint/c/phase.rb +712 -0
- data/lib/adlint/c/resolver.rb +270 -0
- data/lib/adlint/c/scanner.rb +248 -0
- data/lib/adlint/c/scope.rb +74 -0
- data/lib/adlint/c/syntax.rb +4279 -0
- data/lib/adlint/c/type.rb +7506 -0
- data/lib/adlint/c/util.rb +91 -0
- data/lib/adlint/c/value.rb +2310 -0
- data/lib/adlint/c.rb +56 -0
- data/lib/adlint/code.rb +500 -0
- data/lib/adlint/cpp/code.rb +189 -0
- data/lib/adlint/cpp/constexpr.rb +721 -0
- data/lib/adlint/cpp/constexpr.y +389 -0
- data/lib/adlint/cpp/eval.rb +1012 -0
- data/lib/adlint/cpp/lexer.rb +860 -0
- data/lib/adlint/cpp/macro.rb +637 -0
- data/lib/adlint/cpp/message.rb +992 -0
- data/lib/adlint/cpp/phase.rb +176 -0
- data/lib/adlint/cpp/scanner.rb +93 -0
- data/lib/adlint/cpp/source.rb +169 -0
- data/lib/adlint/cpp/subst.rb +300 -0
- data/lib/adlint/cpp/syntax.rb +1412 -0
- data/lib/adlint/cpp/util.rb +97 -0
- data/lib/adlint/cpp.rb +43 -0
- data/lib/adlint/driver.rb +147 -0
- data/lib/adlint/error.rb +179 -0
- data/lib/adlint/lang.rb +97 -0
- data/lib/adlint/ld/message.rb +259 -0
- data/lib/adlint/ld/metric.rb +57 -0
- data/lib/adlint/ld/object.rb +542 -0
- data/lib/adlint/ld/phase.rb +193 -0
- data/lib/adlint/ld/typedef.rb +109 -0
- data/lib/adlint/ld/util.rb +88 -0
- data/lib/adlint/ld.rb +37 -0
- data/lib/adlint/lexer.rb +293 -0
- data/lib/adlint/message.rb +368 -0
- data/lib/adlint/metric.rb +805 -0
- data/lib/adlint/monitor.rb +144 -0
- data/lib/adlint/phase.rb +90 -0
- data/lib/adlint/prelude.rb +314 -0
- data/lib/adlint/report.rb +617 -0
- data/lib/adlint/source.rb +155 -0
- data/lib/adlint/symbol.rb +127 -0
- data/lib/adlint/token.rb +215 -0
- data/lib/adlint/traits.rb +643 -0
- data/lib/adlint/util.rb +524 -0
- data/lib/adlint/version.rb +71 -0
- data/lib/adlint.rb +66 -0
- data/share/HEADER +45 -0
- data/share/demo/Makefile +110 -0
- data/share/demo/ambig_operator/ambig_operator.c +289 -0
- data/share/demo/arg_points_unset/arg_points_unset.c +37 -0
- data/share/demo/array_range/array_range.c +62 -0
- data/share/demo/bad_bitfields/bad_bitfields.c +74 -0
- data/share/demo/bad_brace/bad_brace.c +19 -0
- data/share/demo/bad_charset/abcde$.h +0 -0
- data/share/demo/bad_charset/bad_charset.c +22 -0
- data/share/demo/bad_comment/bad_comment.c +3 -0
- data/share/demo/bad_const/bad_const.c +19 -0
- data/share/demo/bad_conv/bad_conv.c +48 -0
- data/share/demo/bad_indent/bad_indent.c +50 -0
- data/share/demo/bad_init/bad_init.c +49 -0
- data/share/demo/bad_macro/bad_macro.c +97 -0
- data/share/demo/bitwise_expr/bitwise_expr.c +19 -0
- data/share/demo/call_by_value/call_by_value.c +26 -0
- data/share/demo/cross_ref/cross_ref.c +21 -0
- data/share/demo/dangling_else/dangling_else.c +20 -0
- data/share/demo/dead_code/dead_code.c +237 -0
- data/share/demo/deep_nest/deep_nest.c +57 -0
- data/share/demo/dense_switch/dense_switch.c +62 -0
- data/share/demo/direct_recur/direct_recur.c +15 -0
- data/share/demo/div_by_zero/div_by_zero.c +35 -0
- data/share/demo/dos_source/dos_source.c +7 -0
- data/share/demo/funptr_cast/funptr_cast.c +26 -0
- data/share/demo/goto_stmt/goto_stmt.c +19 -0
- data/share/demo/id_hiding/id_hiding.c +19 -0
- data/share/demo/ill_defined/ill_defined.c +13 -0
- data/share/demo/implicit_conv/implicit_conv.c +60 -0
- data/share/demo/implicit_int/implicit_int.c +14 -0
- data/share/demo/incomplete_type/incomplete_type.c +49 -0
- data/share/demo/indirect_recur/indirect_recur_1.c +14 -0
- data/share/demo/indirect_recur/indirect_recur_1.h +7 -0
- data/share/demo/indirect_recur/indirect_recur_2.c +12 -0
- data/share/demo/indirect_recur/indirect_recur_2.h +6 -0
- data/share/demo/indirect_recur/indirect_recur_3.c +6 -0
- data/share/demo/indirect_recur/indirect_recur_3.h +6 -0
- data/share/demo/indirect_recur/indirect_recur_4.c +25 -0
- data/share/demo/intro_demo/intro_demo.c +76 -0
- data/share/demo/intro_demo/intro_demo.h +12 -0
- data/share/demo/intro_demo/useless_header.h +5 -0
- data/share/demo/invalid_call/invalid_call.c +32 -0
- data/share/demo/kandr_fundef/kandr_fundef.c +10 -0
- data/share/demo/line_comment/line_comment.c +12 -0
- data/share/demo/local_decl/local_decl.c +9 -0
- data/share/demo/logical_trick/logical_trick.c +36 -0
- data/share/demo/long_sym/long_sym.c +5 -0
- data/share/demo/loop_var/loop_var.c +92 -0
- data/share/demo/malloc_or_die/malloc_or_die.c +43 -0
- data/share/demo/may_be_null/may_be_null.c +52 -0
- data/share/demo/may_be_null_arith/may_be_null_arith.c +15 -0
- data/share/demo/may_be_unset/may_be_unset.c +34 -0
- data/share/demo/mmapped_io/mmapped_io.c +23 -0
- data/share/demo/multi_break/multi_break.c +33 -0
- data/share/demo/multi_decl/multi_decl_1.c +17 -0
- data/share/demo/multi_decl/multi_decl_1.h +6 -0
- data/share/demo/multi_decl/multi_decl_2.c +13 -0
- data/share/demo/multi_decl/multi_decl_2.h +6 -0
- data/share/demo/multi_decl/multi_decl_3.c +22 -0
- data/share/demo/multi_def/multi_def_1.c +36 -0
- data/share/demo/multi_def/multi_def_1.h +6 -0
- data/share/demo/multi_def/multi_def_2.c +22 -0
- data/share/demo/multi_def/multi_def_2.h +6 -0
- data/share/demo/multi_def/multi_def_3.c +6 -0
- data/share/demo/multi_typedef/multi_typedef.c +11 -0
- data/share/demo/multi_typedef/multi_typedef_1.h +1 -0
- data/share/demo/multi_typedef/multi_typedef_2.h +1 -0
- data/share/demo/must_be_false/must_be_false.c +53 -0
- data/share/demo/must_be_null/must_be_null.c +13 -0
- data/share/demo/must_be_null_arith/must_be_null_arith.c +14 -0
- data/share/demo/must_be_true/must_be_true.c +21 -0
- data/share/demo/no_eof_nl/no_eof_nl.c +4 -0
- data/share/demo/no_void_arg/no_void_arg.c +14 -0
- data/share/demo/null_stmt/null_stmt.c +19 -0
- data/share/demo/octal_const/octal_const.c +20 -0
- data/share/demo/output_by_param/output_by_param.c +17 -0
- data/share/demo/overflow/overflow.c +74 -0
- data/share/demo/press_release/press_release.c +40 -0
- data/share/demo/retn_lvar_addr/retn_lvar_addr.c +47 -0
- data/share/demo/shift_expr/shift_expr.c +14 -0
- data/share/demo/should_be_typedef/should_be_typedef.c +51 -0
- data/share/demo/static_paths/static_paths.c +153 -0
- data/share/demo/static_vars/static_vars.c +39 -0
- data/share/demo/tag_hiding/tag_hiding.c +18 -0
- data/share/demo/tricky_incdec/tricky_incdec.c +12 -0
- data/share/demo/undefined_macro/undefined_macro.c +17 -0
- data/share/demo/uninit_vars/uninit_vars.c +28 -0
- data/share/demo/union_type/union_type.c +23 -0
- data/share/demo/unmatch_decl/unmatch_decl_1.c +12 -0
- data/share/demo/unmatch_decl/unmatch_decl_1.h +8 -0
- data/share/demo/unmatch_decl/unmatch_decl_2.c +10 -0
- data/share/demo/unmatch_decl/unmatch_decl_2.h +8 -0
- data/share/demo/unmatch_decl/unmatch_decl_3.c +7 -0
- data/share/demo/unmatch_paren_macro/unmatch_paren_macro.c +15 -0
- data/share/demo/unreachable/unreachable.c +34 -0
- data/share/demo/useless_exp_funs/useless_exp_funs_1.c +14 -0
- data/share/demo/useless_exp_funs/useless_exp_funs_1.h +1 -0
- data/share/demo/useless_exp_funs/useless_exp_funs_2.c +6 -0
- data/share/demo/useless_exp_vars/useless_export_1.c +8 -0
- data/share/demo/useless_exp_vars/useless_export_1.h +1 -0
- data/share/demo/useless_exp_vars/useless_export_2.c +7 -0
- data/share/demo/useless_expr/useless_expr.c +17 -0
- data/share/demo/useless_funs/useless_funs_1.c +21 -0
- data/share/demo/useless_funs/useless_funs_1.h +8 -0
- data/share/demo/useless_funs/useless_funs_2.c +6 -0
- data/share/demo/useless_header/useless_header.c +9 -0
- data/share/demo/useless_header/useless_header_1.h +12 -0
- data/share/demo/useless_header/useless_header_2.h +6 -0
- data/share/demo/useless_header/useless_header_3.h +9 -0
- data/share/demo/useless_header/useless_header_4.h +3 -0
- data/share/demo/useless_vars/useless_vars.c +17 -0
- data/share/demo/va_funcall/va_funcall.c +25 -0
- data/share/demo/various_fundef/various_fundef.c +36 -0
- data/share/demo/wchar_wstring/wchar_wstring.c +7 -0
- data/share/demo/wrap_around/wrap_around.c +38 -0
- data/share/doc/Makefile +16 -0
- data/share/doc/adlint_on_adqua.png +0 -0
- data/share/doc/adlint_on_eclipse_en.png +0 -0
- data/share/doc/adlint_on_eclipse_ja.png +0 -0
- data/share/doc/adlint_on_vim_en.png +0 -0
- data/share/doc/adlint_on_vim_ja.png +0 -0
- data/share/doc/developers_guide_ja.html +171 -0
- data/share/doc/developers_guide_ja.texi +87 -0
- data/share/doc/gen_mesg_sections.rb +39 -0
- data/share/doc/samples/GNUmakefile +162 -0
- data/share/doc/samples/adlint_traits.yml +238 -0
- data/share/doc/texinfo.css +22 -0
- data/share/doc/users_guide_en.html +39975 -0
- data/share/doc/users_guide_en.texi +32640 -0
- data/share/doc/users_guide_ja.html +40505 -0
- data/share/doc/users_guide_ja.texi +33189 -0
- data/share/logo/adlint-110.png +0 -0
- data/share/logo/adlint-524.png +0 -0
- data/share/logo/adlint.svg +4637 -0
- data/share/sample/README +6 -0
- data/share/sample/bison-2.5/adlint/GNUmakefile +170 -0
- data/share/sample/bison-2.5/adlint/adlint_traits.yml +225 -0
- data/share/sample/bison-2.5/adlint/lib/GNUmakefile +198 -0
- data/share/sample/bison-2.5/adlint/lib/adlint_cinit.h +228 -0
- data/share/sample/bison-2.5/adlint/lib/adlint_pinit.h +21 -0
- data/share/sample/bison-2.5/adlint/lib/adlint_traits.yml +238 -0
- data/share/sample/bison-2.5/adlint/src/GNUmakefile +166 -0
- data/share/sample/bison-2.5/adlint/src/adlint_cinit.h +228 -0
- data/share/sample/bison-2.5/adlint/src/adlint_pinit.h +21 -0
- data/share/sample/bison-2.5/adlint/src/adlint_traits.yml +239 -0
- data/share/sample/ctags-5.8/adlint/GNUmakefile +169 -0
- data/share/sample/ctags-5.8/adlint/adlint_cinit.h +219 -0
- data/share/sample/ctags-5.8/adlint/adlint_pinit.h +13 -0
- data/share/sample/ctags-5.8/adlint/adlint_traits.yml +225 -0
- data/share/sample/flex-2.5.35/adlint/GNUmakefile +140 -0
- data/share/sample/flex-2.5.35/adlint/adlint_cinit.h +219 -0
- data/share/sample/flex-2.5.35/adlint/adlint_pinit.h +14 -0
- data/share/sample/flex-2.5.35/adlint/adlint_traits.yml +225 -0
- data/share/sample/ruby-1.9.3-p0/adlint/GNUmakefile +314 -0
- data/share/sample/ruby-1.9.3-p0/adlint/adlint_traits.yml +225 -0
- data/share/sample/ruby-1.9.3-p0/adlint/core/GNUmakefile +204 -0
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_pinit.h +28 -0
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_traits.yml +240 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc/GNUmakefile +163 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_traits.yml +240 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/GNUmakefile +149 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_traits.yml +240 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/GNUmakefile +134 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/GNUmakefile +132 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/GNUmakefile +132 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/GNUmakefile +132 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/GNUmakefile +132 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/GNUmakefile +134 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/GNUmakefile +140 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/GNUmakefile +134 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/GNUmakefile +162 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/GNUmakefile +135 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/GNUmakefile +132 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/GNUmakefile +144 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/GNUmakefile +140 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_traits.yml +241 -0
- data/share/sample/screen-4.0.3/adlint/GNUmakefile +162 -0
- data/share/sample/screen-4.0.3/adlint/adlint_cinit.h +228 -0
- data/share/sample/screen-4.0.3/adlint/adlint_pinit.h +21 -0
- data/share/sample/screen-4.0.3/adlint/adlint_traits.yml +238 -0
- data/share/sample/vim-7.3/adlint/vim/GNUmakefile +185 -0
- data/share/sample/vim-7.3/adlint/vim/adlint_cinit.h +228 -0
- data/share/sample/vim-7.3/adlint/vim/adlint_pinit.h +25 -0
- data/share/sample/vim-7.3/adlint/vim/adlint_traits.yml +250 -0
- data/share/sample/vim-7.3/adlint/xxd/GNUmakefile +131 -0
- data/share/sample/vim-7.3/adlint/xxd/adlint_cinit.h +228 -0
- data/share/sample/vim-7.3/adlint/xxd/adlint_pinit.h +24 -0
- data/share/sample/vim-7.3/adlint/xxd/adlint_traits.yml +237 -0
- data/share/sample/zsh-4.3.15/adlint/GNUmakefile +146 -0
- data/share/sample/zsh-4.3.15/adlint/adlint_traits.yml +225 -0
- data/share/sample/zsh-4.3.15/adlint/builtins/GNUmakefile +132 -0
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_cinit.h +228 -0
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_pinit.h +24 -0
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_traits.yml +240 -0
- data/share/sample/zsh-4.3.15/adlint/core/GNUmakefile +153 -0
- data/share/sample/zsh-4.3.15/adlint/core/adlint_cinit.h +228 -0
- data/share/sample/zsh-4.3.15/adlint/core/adlint_pinit.h +23 -0
- data/share/sample/zsh-4.3.15/adlint/core/adlint_traits.yml +239 -0
- data/share/sample/zsh-4.3.15/adlint/modules/GNUmakefile +147 -0
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_cinit.h +228 -0
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_pinit.h +24 -0
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_traits.yml +240 -0
- data/share/sample/zsh-4.3.15/adlint/zle/GNUmakefile +144 -0
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_cinit.h +228 -0
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_pinit.h +24 -0
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_traits.yml +239 -0
- data/spec/MUST_WRITE_SPECS_WITH_RSPEC +0 -0
- metadata +532 -0
data/lib/adlint/util.rb
ADDED
@@ -0,0 +1,524 @@
|
|
1
|
+
# Miscellaneous utilities.
|
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
|
+
module AdLint #:nodoc:
|
33
|
+
|
34
|
+
module Validation
|
35
|
+
def ensure_validity_of(*args)
|
36
|
+
@validators ||= []
|
37
|
+
attr_names = _attr_names_in(args)
|
38
|
+
attr_names.each do |attr_name|
|
39
|
+
@validators.push(ObjectValidator.new(attr_name))
|
40
|
+
end
|
41
|
+
self
|
42
|
+
end
|
43
|
+
|
44
|
+
def ensure_presence_of(*args)
|
45
|
+
@validators ||= []
|
46
|
+
attr_names = _attr_names_in(args)
|
47
|
+
attr_names.each do |attr_name|
|
48
|
+
@validators.push(PresenceValidator.new(attr_name))
|
49
|
+
end
|
50
|
+
self
|
51
|
+
end
|
52
|
+
|
53
|
+
def ensure_numericality_of(*args)
|
54
|
+
@validators ||= []
|
55
|
+
attr_names, options = _attr_names_in(args), _options_in(args)
|
56
|
+
only_integer = options[:only_integer] ? true : false
|
57
|
+
min_value = options[:min]
|
58
|
+
max_value = options[:max]
|
59
|
+
attr_names.each do |attr_name|
|
60
|
+
@validators.push(NumericalityValidator.new(attr_name, only_integer,
|
61
|
+
min_value, max_value))
|
62
|
+
end
|
63
|
+
self
|
64
|
+
end
|
65
|
+
|
66
|
+
def ensure_file_presence_of(*args)
|
67
|
+
@validators ||= []
|
68
|
+
attr_names, options = _attr_names_in(args), _options_in(args)
|
69
|
+
allow_nil = options[:allow_nil]
|
70
|
+
attr_names.each do |attr_name|
|
71
|
+
@validators.push(FilePresenceValidator.new(attr_name, allow_nil))
|
72
|
+
end
|
73
|
+
self
|
74
|
+
end
|
75
|
+
|
76
|
+
def ensure_dirs_presence_of(*args)
|
77
|
+
@validators ||= []
|
78
|
+
attr_names = _attr_names_in(args)
|
79
|
+
attr_names.each do |attr_name|
|
80
|
+
@validators.push(DirsPresenceValidator.new(attr_name))
|
81
|
+
end
|
82
|
+
self
|
83
|
+
end
|
84
|
+
|
85
|
+
def ensure_inclusion_of(*args)
|
86
|
+
@validators ||= []
|
87
|
+
attr_names, options = _attr_names_in(args), _options_in(args)
|
88
|
+
values = options[:values] || []
|
89
|
+
attr_names.each do |attr_name|
|
90
|
+
@validators.push(InclusionValidator.new(attr_name, values))
|
91
|
+
end
|
92
|
+
self
|
93
|
+
end
|
94
|
+
|
95
|
+
def ensure_true_or_false_of(*args)
|
96
|
+
@validators ||= []
|
97
|
+
attr_names = _attr_names_in(args)
|
98
|
+
attr_names.each do |attr_name|
|
99
|
+
@validators.push(TrueOrFalseValidator.new(attr_name))
|
100
|
+
end
|
101
|
+
self
|
102
|
+
end
|
103
|
+
|
104
|
+
def ensure_with(*args)
|
105
|
+
@validators ||= []
|
106
|
+
attr_names, options = _attr_names_in(args), _options_in(args)
|
107
|
+
message = options[:message] || "is not valid."
|
108
|
+
validator = options[:validator] || lambda { |value| value }
|
109
|
+
attr_names.each do |attr_name|
|
110
|
+
@validators.push(CustomValidator.new(attr_name, message, validator))
|
111
|
+
end
|
112
|
+
self
|
113
|
+
end
|
114
|
+
|
115
|
+
attr_reader :validators
|
116
|
+
|
117
|
+
def name
|
118
|
+
subclass_responsibility
|
119
|
+
end
|
120
|
+
|
121
|
+
def valid?
|
122
|
+
if self.class.validators
|
123
|
+
self.class.validators.map { |validator| validator.execute(self) }.all?
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def errors
|
128
|
+
if self.class.validators
|
129
|
+
self.class.validators.map { |validator| validator.errors }.flatten
|
130
|
+
else
|
131
|
+
[]
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.included(class_or_module)
|
136
|
+
class_or_module.extend(self)
|
137
|
+
end
|
138
|
+
|
139
|
+
private
|
140
|
+
def _attr_names_in(args)
|
141
|
+
args.select { |obj| obj.kind_of?(Symbol) }
|
142
|
+
end
|
143
|
+
|
144
|
+
def _options_in(args)
|
145
|
+
args.find { |obj| obj.kind_of?(Hash) } || {}
|
146
|
+
end
|
147
|
+
|
148
|
+
class Validator
|
149
|
+
def initialize(attr_name)
|
150
|
+
@attr_name = attr_name
|
151
|
+
@errors = []
|
152
|
+
end
|
153
|
+
|
154
|
+
attr_reader :errors
|
155
|
+
|
156
|
+
def execute(attr_owner)
|
157
|
+
subclass_responsibility
|
158
|
+
end
|
159
|
+
|
160
|
+
private
|
161
|
+
def target_value(attr_owner)
|
162
|
+
attr_owner.instance_variable_get("@#{@attr_name}")
|
163
|
+
end
|
164
|
+
end
|
165
|
+
private_constant :Validator
|
166
|
+
|
167
|
+
class ObjectValidator < Validator
|
168
|
+
def execute(attr_owner)
|
169
|
+
if object = target_value(attr_owner)
|
170
|
+
return true if object.valid?
|
171
|
+
@errors.concat(object.errors)
|
172
|
+
end
|
173
|
+
false
|
174
|
+
end
|
175
|
+
end
|
176
|
+
private_constant :ObjectValidator
|
177
|
+
|
178
|
+
class PresenceValidator < Validator
|
179
|
+
def execute(attr_owner)
|
180
|
+
if target_value(attr_owner).nil?
|
181
|
+
@errors.push("`#{attr_owner.name}:#{@attr_name}' is not specified.")
|
182
|
+
return false
|
183
|
+
end
|
184
|
+
true
|
185
|
+
end
|
186
|
+
end
|
187
|
+
private_constant :PresenceValidator
|
188
|
+
|
189
|
+
class NumericalityValidator < PresenceValidator
|
190
|
+
def initialize(attr_name, only_integer, min_value, max_value)
|
191
|
+
super(attr_name)
|
192
|
+
@only_integer = only_integer
|
193
|
+
@min_value = min_value
|
194
|
+
@max_value = max_value
|
195
|
+
end
|
196
|
+
|
197
|
+
def execute(attr_owner)
|
198
|
+
return false unless super
|
199
|
+
value = target_value(attr_owner)
|
200
|
+
|
201
|
+
case value
|
202
|
+
when Numeric
|
203
|
+
if @only_integer && !value.integer?
|
204
|
+
@errors.push("`#{attr_owner.name}:#{@attr_name}' " +
|
205
|
+
"is not an integer.")
|
206
|
+
return false
|
207
|
+
end
|
208
|
+
if @min_value && value < @min_value
|
209
|
+
@errors.push("`#{attr_owner.name}:#{@attr_name}' " +
|
210
|
+
"is not greater than or equal to #{@min_value}.")
|
211
|
+
return false
|
212
|
+
end
|
213
|
+
if @max_value && @max_value < value
|
214
|
+
@errors.push("`#{attr_owner.name}:#{@attr_name}' " +
|
215
|
+
"is not less than or equal to #{@max_value}.")
|
216
|
+
return false
|
217
|
+
end
|
218
|
+
else
|
219
|
+
@errors.push("`#{attr_owner.name}:#{@attr_name}' " +
|
220
|
+
"is not a numerical value.")
|
221
|
+
return false
|
222
|
+
end
|
223
|
+
|
224
|
+
true
|
225
|
+
end
|
226
|
+
end
|
227
|
+
private_constant :NumericalityValidator
|
228
|
+
|
229
|
+
class FilePresenceValidator < Validator
|
230
|
+
def initialize(attr_name, allow_nil)
|
231
|
+
super(attr_name)
|
232
|
+
@allow_nil = allow_nil
|
233
|
+
end
|
234
|
+
|
235
|
+
def execute(attr_owner)
|
236
|
+
value = target_value(attr_owner)
|
237
|
+
|
238
|
+
unless value
|
239
|
+
return true if @allow_nil
|
240
|
+
@errors.push("`#{attr_owner.name}:#{@attr_name}' is not specified.")
|
241
|
+
return false
|
242
|
+
end
|
243
|
+
|
244
|
+
unless File.exist?(value) && File.file?(value)
|
245
|
+
@errors.push("`#{attr_owner.name}:#{@attr_name}' " +
|
246
|
+
"is non-existent pathname (#{value.to_s}).")
|
247
|
+
return false
|
248
|
+
end
|
249
|
+
true
|
250
|
+
end
|
251
|
+
end
|
252
|
+
private_constant :FilePresenceValidator
|
253
|
+
|
254
|
+
class DirsPresenceValidator < Validator
|
255
|
+
def execute(attr_owner)
|
256
|
+
value = target_value(attr_owner)
|
257
|
+
|
258
|
+
bad_paths = value.reject { |pathname|
|
259
|
+
File.exist?(pathname) && File.directory?(pathname)
|
260
|
+
}
|
261
|
+
|
262
|
+
unless bad_paths.empty?
|
263
|
+
bad_paths.each do |pathname|
|
264
|
+
@errors.push("`#{attr_owner.name}:#{@attr_name}' " +
|
265
|
+
"contains non-existent pathname (#{pathname.to_s}).")
|
266
|
+
end
|
267
|
+
return false
|
268
|
+
end
|
269
|
+
true
|
270
|
+
end
|
271
|
+
end
|
272
|
+
private_constant :DirsPresenceValidator
|
273
|
+
|
274
|
+
class InclusionValidator < PresenceValidator
|
275
|
+
def initialize(attr_name, values)
|
276
|
+
super(attr_name)
|
277
|
+
@values = values
|
278
|
+
end
|
279
|
+
|
280
|
+
def execute(attr_owner)
|
281
|
+
return false unless super
|
282
|
+
value = target_value(attr_owner)
|
283
|
+
|
284
|
+
unless @values.include?(value)
|
285
|
+
@errors.push("`#{attr_owner.name}:#{@attr_name}' " +
|
286
|
+
"is not one of #{@values.join(", ")}.")
|
287
|
+
return false
|
288
|
+
end
|
289
|
+
true
|
290
|
+
end
|
291
|
+
end
|
292
|
+
private_constant :InclusionValidator
|
293
|
+
|
294
|
+
class TrueOrFalseValidator < PresenceValidator
|
295
|
+
def execute(attr_owner)
|
296
|
+
return false unless super
|
297
|
+
case target_value(attr_owner)
|
298
|
+
when TrueClass, FalseClass
|
299
|
+
true
|
300
|
+
else
|
301
|
+
@errors.push("`#{attr_owner.name}:#{@attr_name}' " +
|
302
|
+
"is not a boolean value.")
|
303
|
+
false
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
private_constant :TrueOrFalseValidator
|
308
|
+
|
309
|
+
class CustomValidator < Validator
|
310
|
+
def initialize(attr_name, message, validator)
|
311
|
+
super(attr_name)
|
312
|
+
@message = message
|
313
|
+
@validator = validator
|
314
|
+
end
|
315
|
+
|
316
|
+
def execute(attr_owner)
|
317
|
+
unless @validator[target_value(attr_owner)]
|
318
|
+
@errors.push("`#{attr_owner.name}:#{@attr_name}' " + @message)
|
319
|
+
return false
|
320
|
+
end
|
321
|
+
true
|
322
|
+
end
|
323
|
+
end
|
324
|
+
private_constant :CustomValidator
|
325
|
+
end
|
326
|
+
|
327
|
+
module Visitable
|
328
|
+
def accept(visitor)
|
329
|
+
visitor.__send__(visitor_method_name, self)
|
330
|
+
end
|
331
|
+
|
332
|
+
private
|
333
|
+
def visitor_method_name
|
334
|
+
unless defined?(@visitor_method_name)
|
335
|
+
node_name = self.class.name.sub(/\A.*::/, "")
|
336
|
+
node_name = node_name.gsub(/([A-Z][a-z])/, "_\\1")
|
337
|
+
node_name = node_name.sub(/\A_/, "").tr("A-Z", "a-z")
|
338
|
+
@visitor_method_name = "visit_#{node_name}".intern
|
339
|
+
end
|
340
|
+
@visitor_method_name
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
class CsvRecord
|
345
|
+
def initialize(array)
|
346
|
+
@array = array
|
347
|
+
end
|
348
|
+
|
349
|
+
def field_at(index)
|
350
|
+
@array.fetch(index)
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
354
|
+
module Memoizable
|
355
|
+
def memoize(name, *key_indices)
|
356
|
+
orig_name = "_orig_#{name}"
|
357
|
+
class_eval <<-EOS
|
358
|
+
alias_method("#{orig_name}", "#{name}")
|
359
|
+
private("#{orig_name}")
|
360
|
+
EOS
|
361
|
+
if key_indices.empty?
|
362
|
+
if instance_method("#{name}").arity == 0
|
363
|
+
define_cache_manipulator(name)
|
364
|
+
class_eval(<<-EOS, "util.rb", 71)
|
365
|
+
define_method("#{name}") do |*args|
|
366
|
+
@_#{name}_cache ||= nil
|
367
|
+
@_#{name}_cache_forbidden ||= false
|
368
|
+
if result = @_#{name}_cache
|
369
|
+
@_#{name}_cache_forbidden = false
|
370
|
+
else
|
371
|
+
result = #{orig_name}(*args)
|
372
|
+
if @_#{name}_cache_forbidden
|
373
|
+
@_#{name}_cache_forbidden = false
|
374
|
+
else
|
375
|
+
@_#{name}_cache = result
|
376
|
+
end
|
377
|
+
end
|
378
|
+
result
|
379
|
+
end
|
380
|
+
EOS
|
381
|
+
else
|
382
|
+
define_cache_manipulator(name, key_indices)
|
383
|
+
class_eval(<<-EOS, "util.rb", 90)
|
384
|
+
define_method("#{name}") do |*args|
|
385
|
+
@_#{name}_cache ||= {}
|
386
|
+
@_#{name}_cache_forbidden ||= false
|
387
|
+
if result = @_#{name}_cache[args]
|
388
|
+
@_#{name}_cache_forbidden = false
|
389
|
+
else
|
390
|
+
result = #{orig_name}(*args)
|
391
|
+
if @_#{name}_cache_forbidden
|
392
|
+
@_#{name}_cache_forbidden = false
|
393
|
+
else
|
394
|
+
@_#{name}_cache[args] = result
|
395
|
+
end
|
396
|
+
end
|
397
|
+
result
|
398
|
+
end
|
399
|
+
EOS
|
400
|
+
end
|
401
|
+
else
|
402
|
+
define_cache_manipulator(name, key_indices)
|
403
|
+
class_eval(<<-EOS, "util.rb", 110)
|
404
|
+
define_method("#{name}") do |*args|
|
405
|
+
@_#{name}_cache ||= {}
|
406
|
+
@_#{name}_cache_forbidden ||= false
|
407
|
+
key = args.values_at(#{key_indices.join(',')})
|
408
|
+
if result = @_#{name}_cache[key]
|
409
|
+
@_#{name}_cache_forbidden = false
|
410
|
+
else
|
411
|
+
result = #{orig_name}(*args)
|
412
|
+
if @_#{name}_cache_forbidden
|
413
|
+
@_#{name}_cache_forbidden = false
|
414
|
+
else
|
415
|
+
@_#{name}_cache[key] = result
|
416
|
+
end
|
417
|
+
end
|
418
|
+
result
|
419
|
+
end
|
420
|
+
EOS
|
421
|
+
end
|
422
|
+
end
|
423
|
+
|
424
|
+
private
|
425
|
+
def define_cache_manipulator(name, key_indices = nil)
|
426
|
+
class_eval(<<-EOS, "util.rb", 133)
|
427
|
+
define_method("forbid_#{name}_memoizing_once") do |*args|
|
428
|
+
@_#{name}_cache_forbidden = true
|
429
|
+
end
|
430
|
+
EOS
|
431
|
+
case
|
432
|
+
when key_indices && key_indices.empty?
|
433
|
+
class_eval(<<-EOS, "util.rb", 140)
|
434
|
+
define_method("forget_#{name}_memo") do |*args|
|
435
|
+
@_#{name}_cache.delete(args) if defined?(@_#{name}_cache)
|
436
|
+
end
|
437
|
+
define_method("clear_#{name}_memo") do |*args|
|
438
|
+
@_#{name}_cache.clear if defined?(@_#{name}_cache)
|
439
|
+
end
|
440
|
+
EOS
|
441
|
+
when key_indices
|
442
|
+
class_eval(<<-EOS, "util.rb", 149)
|
443
|
+
define_method("forget_#{name}_memo") do |*args|
|
444
|
+
if defined?(@_#{name}_cache)
|
445
|
+
@_#{name}_cache.delete(args.values_at(#{key_indices.join(',')}))
|
446
|
+
end
|
447
|
+
end
|
448
|
+
define_method("clear_#{name}_memo") do |*args|
|
449
|
+
@_#{name}_cache.clear if defined?(@_#{name}_cache)
|
450
|
+
end
|
451
|
+
EOS
|
452
|
+
else
|
453
|
+
class_eval(<<-EOS, "util.rb", 160)
|
454
|
+
define_method("forget_#{name}_memo") do |*args|
|
455
|
+
@_#{name}_cache = nil
|
456
|
+
end
|
457
|
+
define_method("clear_#{name}_memo") do |*args|
|
458
|
+
@_#{name}_cache = nil
|
459
|
+
end
|
460
|
+
EOS
|
461
|
+
end
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
465
|
+
class Plugin
|
466
|
+
def initialize(methods = [])
|
467
|
+
@methods = methods
|
468
|
+
end
|
469
|
+
|
470
|
+
def +(method)
|
471
|
+
Plugin.new(@methods + [method])
|
472
|
+
end
|
473
|
+
|
474
|
+
def invoke(*args)
|
475
|
+
@methods.each { |method| method.call(*args) }
|
476
|
+
end
|
477
|
+
end
|
478
|
+
|
479
|
+
module Pluggable
|
480
|
+
def def_plugin(event)
|
481
|
+
class_eval(<<-EOS, "util.rb", 188)
|
482
|
+
define_method("#{event}") do |*args|
|
483
|
+
@#{event}_plugin ||= Plugin.new
|
484
|
+
end
|
485
|
+
define_method("#{event}=") do |*args|
|
486
|
+
@#{event}_plugin = args.first
|
487
|
+
end
|
488
|
+
EOS
|
489
|
+
end
|
490
|
+
end
|
491
|
+
|
492
|
+
end
|
493
|
+
|
494
|
+
if $0 == __FILE__
|
495
|
+
require_relative "prelude.rb"
|
496
|
+
|
497
|
+
class Foo
|
498
|
+
def initialize
|
499
|
+
p "foo"
|
500
|
+
end
|
501
|
+
|
502
|
+
extend AdLint::Pluggable
|
503
|
+
|
504
|
+
def_plugin :on_initialization
|
505
|
+
|
506
|
+
def run
|
507
|
+
on_initialization.invoke(1, 2)
|
508
|
+
end
|
509
|
+
end
|
510
|
+
|
511
|
+
def bar(a1, a2)
|
512
|
+
p a1, a2
|
513
|
+
end
|
514
|
+
|
515
|
+
def baz(a1, a2)
|
516
|
+
p "baz"
|
517
|
+
end
|
518
|
+
|
519
|
+
foo = Foo.lazy_new
|
520
|
+
p "foo?"
|
521
|
+
foo.on_initialization += method(:bar)
|
522
|
+
foo.on_initialization += method(:baz)
|
523
|
+
foo.run
|
524
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# Version information.
|
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
|
+
module AdLint #:nodoc:
|
33
|
+
|
34
|
+
MAJOR_VERSION = 1
|
35
|
+
MINOR_VERSION = 0
|
36
|
+
PATCH_VERSION = 0
|
37
|
+
RELEASE_DATE = "2012-02-28"
|
38
|
+
|
39
|
+
SHORT_VERSION = "#{MAJOR_VERSION}.#{MINOR_VERSION}.#{PATCH_VERSION}"
|
40
|
+
|
41
|
+
VERSION = "#{SHORT_VERSION} (#{RELEASE_DATE})"
|
42
|
+
|
43
|
+
SCHEMA_VERSION_RE = /\A#{MAJOR_VERSION}\.#{MINOR_VERSION}\.\d+\z/
|
44
|
+
|
45
|
+
COPYRIGHT = <<EOS
|
46
|
+
___ ____ __ ___ _________
|
47
|
+
/ | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
|
48
|
+
/ /| | / / / / / / / |/ / / / AdLint - Advanced Lint
|
49
|
+
/ __ |/ /_/ / /___/ / /| / / /
|
50
|
+
/_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
|
51
|
+
|
52
|
+
AdLint is free software: you can redistribute it and/or modify it under the
|
53
|
+
terms of the GNU General Public License as published by the Free Software
|
54
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
55
|
+
version.
|
56
|
+
|
57
|
+
AdLint is distributed in the hope that it will be useful, but WITHOUT ANY
|
58
|
+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
59
|
+
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
60
|
+
|
61
|
+
You should have received a copy of the GNU General Public License along with
|
62
|
+
AdLint. If not, see <http://www.gnu.org/licenses/>.
|
63
|
+
|
64
|
+
EOS
|
65
|
+
|
66
|
+
AUTHOR = <<EOS
|
67
|
+
Written by Yutaka Yanoh and Code Quality Assessment Team of OGIS-RI Co.,Ltd.
|
68
|
+
|
69
|
+
EOS
|
70
|
+
|
71
|
+
end
|
data/lib/adlint.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# AdLint package loader.
|
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 "pp"
|
33
|
+
require "pathname"
|
34
|
+
require "fileutils"
|
35
|
+
require "set"
|
36
|
+
require "csv"
|
37
|
+
require "psych"
|
38
|
+
require "yaml"
|
39
|
+
require "strscan"
|
40
|
+
require "stringio"
|
41
|
+
require "singleton"
|
42
|
+
require "forwardable"
|
43
|
+
require "logger"
|
44
|
+
|
45
|
+
require "adlint/prelude"
|
46
|
+
require "adlint/analyzer"
|
47
|
+
require "adlint/code"
|
48
|
+
require "adlint/traits"
|
49
|
+
require "adlint/driver"
|
50
|
+
require "adlint/error"
|
51
|
+
require "adlint/lang"
|
52
|
+
require "adlint/lexer"
|
53
|
+
require "adlint/message"
|
54
|
+
require "adlint/metric"
|
55
|
+
require "adlint/monitor"
|
56
|
+
require "adlint/phase"
|
57
|
+
require "adlint/report"
|
58
|
+
require "adlint/source"
|
59
|
+
require "adlint/symbol"
|
60
|
+
require "adlint/token"
|
61
|
+
require "adlint/util"
|
62
|
+
require "adlint/version"
|
63
|
+
|
64
|
+
require "adlint/cpp"
|
65
|
+
require "adlint/c"
|
66
|
+
require "adlint/ld"
|
data/share/HEADER
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#--
|
2
|
+
# ___ ____ __ ___ _________
|
3
|
+
# / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
|
4
|
+
# / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
|
5
|
+
# / __ |/ /_/ / /___/ / /| / / /
|
6
|
+
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
|
7
|
+
#
|
8
|
+
# This file is part of AdLint.
|
9
|
+
#
|
10
|
+
# AdLint is free software: you can redistribute it and/or modify it under the
|
11
|
+
# terms of the GNU General Public License as published by the Free Software
|
12
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
13
|
+
# version.
|
14
|
+
#
|
15
|
+
# AdLint is distributed in the hope that it will be useful, but WITHOUT ANY
|
16
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
17
|
+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License along with
|
20
|
+
# AdLint. If not, see <http://www.gnu.org/licenses/>.
|
21
|
+
#
|
22
|
+
#++
|
23
|
+
|
24
|
+
--
|
25
|
+
___ ____ __ ___ _________
|
26
|
+
/ | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
|
27
|
+
/ /| | / / / / / / / |/ / / / AdLint - Advanced Lint
|
28
|
+
/ __ |/ /_/ / /___/ / /| / / /
|
29
|
+
/_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
|
30
|
+
|
31
|
+
This file is part of AdLint.
|
32
|
+
|
33
|
+
AdLint is free software: you can redistribute it and/or modify it under the
|
34
|
+
terms of the GNU General Public License as published by the Free Software
|
35
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
36
|
+
version.
|
37
|
+
|
38
|
+
AdLint is distributed in the hope that it will be useful, but WITHOUT ANY
|
39
|
+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
40
|
+
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
41
|
+
|
42
|
+
You should have received a copy of the GNU General Public License along with
|
43
|
+
AdLint. If not, see <http://www.gnu.org/licenses/>.
|
44
|
+
|
45
|
+
++
|