adlint 1.10.0 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/ChangeLog +197 -4
  2. data/MANIFEST +17 -0
  3. data/NEWS +23 -4
  4. data/etc/mesg.d/en_US/messages.yml +14 -1
  5. data/etc/mesg.d/ja_JP/messages.yml +14 -1
  6. data/features/message_detection/W0093.feature +87 -0
  7. data/features/message_detection/W0687.feature +25 -0
  8. data/features/message_detection/W0688.feature +63 -0
  9. data/features/message_detection/W0689.feature +46 -0
  10. data/features/message_detection/W0690.feature +35 -0
  11. data/features/message_detection/W0698.feature +3 -2
  12. data/features/message_detection/W0703.feature +1 -0
  13. data/features/message_detection/W0723.feature +34 -0
  14. data/features/message_detection/W0732.feature +158 -0
  15. data/features/message_detection/W0733.feature +158 -0
  16. data/features/message_detection/W0734.feature +322 -0
  17. data/features/message_detection/W0735.feature +322 -0
  18. data/features/message_detection/W1052.feature +66 -0
  19. data/features/message_detection/W9001.feature +33 -0
  20. data/features/message_detection/W9003.feature +131 -0
  21. data/lib/adlint/c/ctrlexpr.rb +51 -50
  22. data/lib/adlint/c/domain.rb +237 -223
  23. data/lib/adlint/c/expr.rb +6 -8
  24. data/lib/adlint/c/interp.rb +8 -11
  25. data/lib/adlint/c/message.rb +20 -0
  26. data/lib/adlint/c/message_shima.rb +63 -0
  27. data/lib/adlint/c/object.rb +5 -4
  28. data/lib/adlint/c/operator.rb +99 -0
  29. data/lib/adlint/c/parser.rb +2 -2
  30. data/lib/adlint/c/parser.y +2 -2
  31. data/lib/adlint/c/phase.rb +6 -1
  32. data/lib/adlint/c/syntax.rb +442 -30
  33. data/lib/adlint/c/type.rb +449 -363
  34. data/lib/adlint/c/value.rb +96 -25
  35. data/lib/adlint/c.rb +1 -0
  36. data/lib/adlint/prelude.rb +16 -18
  37. data/lib/adlint/version.rb +2 -2
  38. data/share/doc/developers_guide_ja.html +11 -5
  39. data/share/doc/developers_guide_ja.texi +9 -3
  40. data/share/doc/users_guide_en.html +697 -131
  41. data/share/doc/users_guide_en.texi +491 -41
  42. data/share/doc/users_guide_ja.html +709 -139
  43. data/share/doc/users_guide_ja.texi +499 -45
  44. data/spec/adlint/c/ctrlexpr_spec.rb +168 -0
  45. data/spec/adlint/c/domain_spec.rb +835 -0
  46. data/spec/adlint/c/operator_spec.rb +406 -0
  47. data/spec/adlint/c/syntax_spec.rb +717 -0
  48. data/spec/adlint/c/type_spec.rb +55 -30
  49. metadata +19 -2
@@ -30,6 +30,7 @@
30
30
  #++
31
31
 
32
32
  require "adlint/c/domain"
33
+ require "adlint/c/operator"
33
34
 
34
35
  module AdLint #:nodoc:
35
36
  module C #:nodoc:
@@ -79,6 +80,14 @@ module C #:nodoc:
79
80
  subclass_responsibility
80
81
  end
81
82
 
83
+ def definite?
84
+ subclass_responsibility
85
+ end
86
+
87
+ def contain?(value)
88
+ subclass_responsibility
89
+ end
90
+
82
91
  def multiple?
83
92
  subclass_responsibility
84
93
  end
@@ -87,11 +96,11 @@ module C #:nodoc:
87
96
  subclass_responsibility
88
97
  end
89
98
 
90
- def narrow_domain!(operator_symbol, operand_value)
99
+ def narrow_domain!(operator, operand_value)
91
100
  subclass_responsibility
92
101
  end
93
102
 
94
- def widen_domain!(operator_symbol, operand_value)
103
+ def widen_domain!(operator, operand_value)
95
104
  subclass_responsibility
96
105
  end
97
106
 
@@ -370,6 +379,19 @@ module C #:nodoc:
370
379
  !@domain.empty?
371
380
  end
372
381
 
382
+ def definite?
383
+ @domain.kind_of?(EqualToValueDomain)
384
+ end
385
+
386
+ def contain?(value)
387
+ case single_value = value.to_single_value
388
+ when ScalarValue
389
+ @domain.contain?(single_value.domain)
390
+ else
391
+ false
392
+ end
393
+ end
394
+
373
395
  def undefined?
374
396
  @domain.undefined?
375
397
  end
@@ -387,22 +409,22 @@ module C #:nodoc:
387
409
  end
388
410
  end
389
411
 
390
- def narrow_domain!(operator_symbol, operand_value)
412
+ def narrow_domain!(operator, operand_value)
391
413
  case operand_single_value = operand_value.to_single_value
392
414
  when ScalarValue
393
415
  orig_domain = @domain
394
- @domain = @domain.narrow(operator_symbol, operand_single_value.domain)
416
+ @domain = @domain.narrow(operator, operand_single_value.domain)
395
417
  !@domain.equal?(orig_domain)
396
418
  else
397
419
  raise TypeError, "cannot narrow scalar value domain with non-scalar."
398
420
  end
399
421
  end
400
422
 
401
- def widen_domain!(operator_symbol, operand_value)
423
+ def widen_domain!(operator, operand_value)
402
424
  case operand_single_value = operand_value.to_single_value
403
425
  when ScalarValue
404
426
  orig_domain = @domain
405
- @domain = @domain.widen(operator_symbol, operand_single_value.domain)
427
+ @domain = @domain.widen(operator, operand_single_value.domain)
406
428
  !@domain.equal?(orig_domain)
407
429
  else
408
430
  raise TypeError, "cannot widen scalar value domain with non-scalar."
@@ -605,7 +627,7 @@ module C #:nodoc:
605
627
  when ScalarValue
606
628
  comp_result = (self == single_value)
607
629
  single_value.invert_domain!
608
- single_value.narrow_domain!(:==, self)
630
+ single_value.narrow_domain!(Operator::EQ, self)
609
631
  comp_result.domain.intersect?(ScalarValue.of_true.domain) &&
610
632
  !comp_result.domain.contain?(ScalarValue.of_false.domain) &&
611
633
  !@domain.intersect?(single_value.domain)
@@ -752,6 +774,25 @@ module C #:nodoc:
752
774
  @values.empty? ? true : @values.all? { |value| value.exist? }
753
775
  end
754
776
 
777
+ def definite?
778
+ @values.empty? ? true : @values.all? { |value| value.definite? }
779
+ end
780
+
781
+ def contain?(value)
782
+ case single_value = value.to_single_value
783
+ when ArrayValue
784
+ if @values.size == single_value.values.size
785
+ @values.zip(single_value.values).all? do |lhs, rhs|
786
+ lhs.contain?(rhs)
787
+ end
788
+ else
789
+ false
790
+ end
791
+ else
792
+ false
793
+ end
794
+ end
795
+
755
796
  def undefined?
756
797
  @values.empty? ? false : @values.all? { |value| value.undefined? }
757
798
  end
@@ -771,12 +812,12 @@ module C #:nodoc:
771
812
  end
772
813
  end
773
814
 
774
- def narrow_domain!(operator_symbol, operand_value)
815
+ def narrow_domain!(operator, operand_value)
775
816
  case operand_single_value = operand_value.to_single_value
776
817
  when ArrayValue
777
818
  @values.zip(operand_single_value.values).map { |lhs, rhs|
778
819
  if rhs
779
- lhs.narrow_domain!(operator_symbol, rhs)
820
+ lhs.narrow_domain!(operator, rhs)
780
821
  else
781
822
  next
782
823
  end
@@ -786,12 +827,12 @@ module C #:nodoc:
786
827
  end
787
828
  end
788
829
 
789
- def widen_domain!(operator_symbol, operand_value)
830
+ def widen_domain!(operator, operand_value)
790
831
  case operand_single_value = operand_value.to_single_value
791
832
  when ArrayValue
792
833
  @values.zip(operand_single_value.values).map { |lhs, rhs|
793
834
  if rhs
794
- lhs.widen_domain!(operator_symbol, rhs)
835
+ lhs.widen_domain!(operator, rhs)
795
836
  else
796
837
  next
797
838
  end
@@ -1227,6 +1268,25 @@ module C #:nodoc:
1227
1268
  @values.empty? ? true : @values.all? { |value| value.exist? }
1228
1269
  end
1229
1270
 
1271
+ def definite?
1272
+ @values.empty? ? true : @values.all? { |value| value.definite? }
1273
+ end
1274
+
1275
+ def contain?(value)
1276
+ case single_value = value.to_single_value
1277
+ when CompositeValue
1278
+ if @values.size == single_value.values.size
1279
+ @values.zip(single_value.values).all? do |lhs, rhs|
1280
+ lhs.contain?(rhs)
1281
+ end
1282
+ else
1283
+ false
1284
+ end
1285
+ else
1286
+ false
1287
+ end
1288
+ end
1289
+
1230
1290
  def undefined?
1231
1291
  @values.empty? ? false : @values.all? { |value| value.undefined? }
1232
1292
  end
@@ -1246,12 +1306,12 @@ module C #:nodoc:
1246
1306
  end
1247
1307
  end
1248
1308
 
1249
- def narrow_domain!(operator_symbol, operand_value)
1309
+ def narrow_domain!(operator, operand_value)
1250
1310
  case operand_single_value = operand_value.to_single_value
1251
1311
  when CompositeValue
1252
1312
  @values.zip(operand_single_value.values).map { |lhs, rhs|
1253
1313
  if rhs
1254
- lhs.narrow_domain!(operator_symbol, rhs)
1314
+ lhs.narrow_domain!(operator, rhs)
1255
1315
  else
1256
1316
  next
1257
1317
  end
@@ -1262,12 +1322,12 @@ module C #:nodoc:
1262
1322
  end
1263
1323
  end
1264
1324
 
1265
- def widen_domain!(operator_symbol, operand_value)
1325
+ def widen_domain!(operator, operand_value)
1266
1326
  case operand_single_value = operand_value.to_single_value
1267
1327
  when CompositeValue
1268
1328
  @values.zip(operand_single_value.values).map { |lhs, rhs|
1269
1329
  if rhs
1270
- lhs.widen_domain!(operator_symbol, rhs)
1330
+ lhs.widen_domain!(operator, rhs)
1271
1331
  else
1272
1332
  next
1273
1333
  end
@@ -1671,6 +1731,17 @@ module C #:nodoc:
1671
1731
  effective_values.any? { |multi_value| multi_value.base_value.exist? }
1672
1732
  end
1673
1733
 
1734
+ def definite?
1735
+ effective_values.all? { |multi_value| multi_value.base_value.definite? }
1736
+ end
1737
+
1738
+ def contain?(value)
1739
+ single_value = value.to_single_value
1740
+ effective_values.all? do |multi_value|
1741
+ multi_value.base_value.contain?(single_value)
1742
+ end
1743
+ end
1744
+
1674
1745
  def multiple?
1675
1746
  true
1676
1747
  end
@@ -1682,27 +1753,25 @@ module C #:nodoc:
1682
1753
  end
1683
1754
  end
1684
1755
 
1685
- def narrow_domain!(operator_symbol, operand_value)
1756
+ def narrow_domain!(operator, operand_value)
1686
1757
  operand_single_value = operand_value.to_single_value
1687
1758
  effective_values.map { |multi_value|
1688
1759
  if ancestor = multi_value.ancestor
1689
- ancestor.base_value.narrow_domain!(operator_symbol.invert,
1760
+ ancestor.base_value.narrow_domain!(operator.for_complement,
1690
1761
  operand_single_value)
1691
1762
  end
1692
- multi_value.base_value.narrow_domain!(operator_symbol,
1693
- operand_single_value)
1763
+ multi_value.base_value.narrow_domain!(operator, operand_single_value)
1694
1764
  }.any?
1695
1765
  end
1696
1766
 
1697
- def widen_domain!(operator_symbol, operand_value)
1767
+ def widen_domain!(operator, operand_value)
1698
1768
  operand_single_value = operand_value.to_single_value
1699
1769
  effective_values.map { |multi_value|
1700
1770
  if ancestor = multi_value.ancestor
1701
- ancestor.base_value.narrow_domain!(operator_symbol.invert,
1771
+ ancestor.base_value.narrow_domain!(operator.for_complement,
1702
1772
  operand_single_value)
1703
1773
  end
1704
- multi_value.base_value.widen_domain!(operator_symbol,
1705
- operand_single_value)
1774
+ multi_value.base_value.widen_domain!(operator, operand_single_value)
1706
1775
  }.any?
1707
1776
  end
1708
1777
 
@@ -2047,13 +2116,13 @@ module C #:nodoc:
2047
2116
  invalidate_memo!
2048
2117
  end
2049
2118
 
2050
- def narrow_domain!(operator_symbol, operand_value)
2119
+ def narrow_domain!(operator, operand_value)
2051
2120
  @version_controller.fork_current_version
2052
2121
  super
2053
2122
  invalidate_memo!
2054
2123
  end
2055
2124
 
2056
- def widen_domain!(operator_symbol, operand_value)
2125
+ def widen_domain!(operator, operand_value)
2057
2126
  @version_controller.fork_current_version
2058
2127
  super
2059
2128
  invalidate_memo!
@@ -2326,6 +2395,8 @@ module C #:nodoc:
2326
2395
  def_delegator :@versioned_value, :composite?
2327
2396
  def_delegator :@versioned_value, :undefined?
2328
2397
  def_delegator :@versioned_value, :exist?
2398
+ def_delegator :@versioned_value, :definite?
2399
+ def_delegator :@versioned_value, :contain?
2329
2400
  def_delegator :@versioned_value, :multiple?
2330
2401
  def_delegator :@versioned_value, :enter_versioning_group
2331
2402
  def_delegator :@versioned_value, :leave_versioning_group
data/lib/adlint/c.rb CHANGED
@@ -47,6 +47,7 @@ require "adlint/c/message"
47
47
  require "adlint/c/message_shima"
48
48
  require "adlint/c/metric"
49
49
  require "adlint/c/object"
50
+ require "adlint/c/operator"
50
51
  require "adlint/c/option"
51
52
  require "adlint/c/parser"
52
53
  require "adlint/c/phase"
@@ -34,6 +34,12 @@ module Kernel
34
34
  def subclass_responsibility
35
35
  raise NotImplementedError, self.class.name
36
36
  end
37
+ module_function :subclass_responsibility
38
+
39
+ def __NOTREACHED__
40
+ raise "NOTREACHED"
41
+ end
42
+ module_function :__NOTREACHED__
37
43
 
38
44
  def print_elapsed_time(io)
39
45
  tms = Process.times
@@ -58,7 +64,7 @@ end
58
64
  class Module
59
65
  # NOTE: Module.private_constant is added in Ruby 1.9.3-p0.
60
66
  unless public_instance_methods.include?(:private_constant)
61
- def private_constant(*name) end
67
+ def private_constant(*) end
62
68
  end
63
69
  end
64
70
 
@@ -120,20 +126,6 @@ class Integer
120
126
  end
121
127
  end
122
128
 
123
- class Symbol
124
- INVERSION_TABLE = {
125
- :== => :!=, :!= => :==, :< => :>=, :> => :<=, :<= => :>, :>= => :<
126
- }
127
-
128
- def invert
129
- if result = INVERSION_TABLE[self]
130
- result
131
- else
132
- self
133
- end
134
- end
135
- end
136
-
137
129
  class Pathname
138
130
  def components
139
131
  self.each_filename.to_a
@@ -283,9 +275,15 @@ class SuffixArray < Array
283
275
  def create_substring_pairs(index, length)
284
276
  base_suffix = self[index][0]
285
277
 
286
- create_entry = base_suffix.lhs? ?
287
- lambda { |lhs, rhs, len| SubstringPair.new(lhs, rhs, len) } :
288
- lambda { |rhs, lhs, len| SubstringPair.new(lhs, rhs, len) }
278
+ if base_suffix.lhs?
279
+ create_entry = lambda { |lhs, rhs, len|
280
+ SubstringPair.new(lhs, rhs, len)
281
+ }
282
+ else
283
+ create_entry = lambda { |rhs, lhs, len|
284
+ SubstringPair.new(lhs, rhs, len)
285
+ }
286
+ end
289
287
 
290
288
  result = []
291
289
 
@@ -32,9 +32,9 @@
32
32
  module AdLint #:nodoc:
33
33
 
34
34
  MAJOR_VERSION = 1
35
- MINOR_VERSION = 10
35
+ MINOR_VERSION = 12
36
36
  PATCH_VERSION = 0
37
- RELEASE_DATE = "2012-06-06"
37
+ RELEASE_DATE = "2012-06-20"
38
38
 
39
39
  TRAITS_SCHEMA_VERSION = "1.0.0"
40
40
 
@@ -1,8 +1,8 @@
1
1
  <html lang="ja">
2
2
  <head>
3
- <title>AdLint 1.10.0 開発者ガイド</title>
3
+ <title>AdLint 1.12.0 開発者ガイド</title>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
- <meta name="description" content="AdLint 1.10.0 開発者ガイド">
5
+ <meta name="description" content="AdLint 1.12.0 開発者ガイド">
6
6
  <meta name="generator" content="makeinfo 4.13">
7
7
  <link title="Top" rel="top" href="#Top">
8
8
  <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
@@ -44,7 +44,7 @@ td { border: 1px solid black; }
44
44
  --></style>
45
45
  </head>
46
46
  <body>
47
- <h1 class="settitle">AdLint 1.10.0 開発者ガイド</h1>
47
+ <h1 class="settitle">AdLint 1.12.0 開発者ガイド</h1>
48
48
  <div class="contents">
49
49
  <h2>Table of Contents</h2>
50
50
  <ul>
@@ -95,11 +95,17 @@ along with AdLint. If not, see &lt;<a href="http://www.gnu.org/licenses/">http:
95
95
 
96
96
  <p><table summary=""><tr align="left"><th valign="top" width="10%">名称 </th><th valign="top" width="10%">バージョン </th><th valign="top" width="30%">用途
97
97
  <br></th></tr><tr align="left"><td valign="top" width="10%"><a href="http://www.ruby-lang.org/">Ruby</a>
98
- </td><td valign="top" width="10%"><code>1.9.3-p0</code>
98
+ </td><td valign="top" width="10%"><code>1.9.3-p194</code>
99
99
  </td><td valign="top" width="30%">ベースとなる実装言語
100
100
  <br></td></tr><tr align="left"><td valign="top" width="10%"><a href="http://rubyforge.org/projects/racc/">Racc</a>
101
- </td><td valign="top" width="10%"><code>1.4.7</code>
101
+ </td><td valign="top" width="10%"><code>1.4.8</code>
102
102
  </td><td valign="top" width="30%">構文解析器の生成
103
+ <br></td></tr><tr align="left"><td valign="top" width="10%"><a href="http://rspec.info/">RSpec</a>
104
+ </td><td valign="top" width="10%"><code>2.10.0</code>
105
+ </td><td valign="top" width="30%">単体仕様の記述と回帰テスト
106
+ <br></td></tr><tr align="left"><td valign="top" width="10%"><a href="http://cukes.info/">Cucumber</a>
107
+ </td><td valign="top" width="10%"><code>1.2.0</code>
108
+ </td><td valign="top" width="30%">機能仕様の記述と回帰テスト
103
109
  <br></td></tr></table>
104
110
 
105
111
  <h3 class="unnumberedsec">文書化環境</h3>
@@ -2,7 +2,7 @@
2
2
  @setfilename developers_guide_ja.info
3
3
  @documentlanguage ja
4
4
  @documentencoding utf-8
5
- @settitle AdLint 1.10.0 開発者ガイド
5
+ @settitle AdLint 1.12.0 開発者ガイド
6
6
 
7
7
  @copying
8
8
  Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
@@ -41,11 +41,17 @@ along with AdLint. If not, see <@uref{http://www.gnu.org/licenses/}>.
41
41
  @multitable @columnfractions .1 .1 .3
42
42
  @headitem 名称 @tab バージョン @tab 用途
43
43
  @item @uref{http://www.ruby-lang.org/, Ruby}
44
- @tab @code{1.9.3-p0}
44
+ @tab @code{1.9.3-p194}
45
45
  @tab ベースとなる実装言語
46
46
  @item @uref{http://rubyforge.org/projects/racc/, Racc}
47
- @tab @code{1.4.7}
47
+ @tab @code{1.4.8}
48
48
  @tab 構文解析器の生成
49
+ @item @uref{http://rspec.info/, RSpec}
50
+ @tab @code{2.10.0}
51
+ @tab 単体仕様の記述と回帰テスト
52
+ @item @uref{http://cukes.info/, Cucumber}
53
+ @tab @code{1.2.0}
54
+ @tab 機能仕様の記述と回帰テスト
49
55
  @end multitable
50
56
 
51
57
  @unnumberedsec 文書化環境