flay 2.8.1 → 2.9.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/History.txt +8 -2
- data/lib/flay.rb +52 -2
- data/test/test_flay.rb +29 -17
- metadata +44 -43
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28083167bd112a4147a69347db6f5c042a84239d
|
4
|
+
data.tar.gz: 4accae6b53cba132a340a5a73b7a6f6af6432e59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 799ea470eb54add44f91ae4ac3d6675d8669b8a6a2168505a14ab3951b01ec85576bdcdb7b843edf67584bf7c0b866c3da7bfced294190265873a76cadce4fc8
|
7
|
+
data.tar.gz: 796f1127245836476b4d5214883cae08cbcb6e895bea2ed86cabdd4840657de85935ecd260cd503e98bf96f44facccb30666edb06d39702524a90057cf083f8d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
=== 2.9.0 / 2017-04-13
|
2
|
+
|
3
|
+
* 1 minor enhancement:
|
4
|
+
|
5
|
+
* Added Sexp#pure_ruby_hash from flay-persistent and switched structural_hash to it. Faster than ruby's #hash and stable.
|
6
|
+
|
1
7
|
=== 2.8.1 / 2016-08-24
|
2
8
|
|
3
9
|
* 1 bug fix:
|
@@ -13,7 +19,7 @@
|
|
13
19
|
* 2 bug fixes:
|
14
20
|
|
15
21
|
* Added dev deps and bundler plugin to make flavorjones happy. (flavorjones)
|
16
|
-
*
|
22
|
+
* Explicitly require rake/tasklib in flay_task.rb. (jasonkarns)
|
17
23
|
|
18
24
|
=== 2.7.0 / 2016-01-21
|
19
25
|
|
@@ -84,7 +90,7 @@ is. In this case, it severely falls short. I'd jump to 4.0 if I could.
|
|
84
90
|
* Added Sexp#+.
|
85
91
|
* Added Sexp#code_index to specify where *code starts in some sexps.
|
86
92
|
* Added Sexp#has_code?.
|
87
|
-
* Added Sexp#
|
93
|
+
* Added Sexp#initialize_copy to propagate file/line/modified info.
|
88
94
|
* Added Sexp#modified, #modified=, and #modified?.
|
89
95
|
* Added Sexp#split_at(n). (Something I've wanted in Array for ages).
|
90
96
|
* Added Sexp#split_code.
|
data/lib/flay.rb
CHANGED
@@ -16,7 +16,7 @@ class File
|
|
16
16
|
end
|
17
17
|
|
18
18
|
class Flay
|
19
|
-
VERSION = "2.
|
19
|
+
VERSION = "2.9.0" # :nodoc:
|
20
20
|
|
21
21
|
class Item < Struct.new(:structural_hash, :name, :bonus, :mass, :locations)
|
22
22
|
alias identical? bonus
|
@@ -538,7 +538,7 @@ class Sexp
|
|
538
538
|
# modify the sexp afterwards and expect it to be correct.
|
539
539
|
|
540
540
|
def structural_hash
|
541
|
-
@structural_hash ||=
|
541
|
+
@structural_hash ||= pure_ruby_hash
|
542
542
|
end
|
543
543
|
|
544
544
|
##
|
@@ -610,6 +610,56 @@ class Sexp
|
|
610
610
|
end
|
611
611
|
end
|
612
612
|
|
613
|
+
class Sexp # straight from flay-persistent
|
614
|
+
names = %w(alias and arglist args array attrasgn attrset back_ref
|
615
|
+
begin block block_pass break call case cdecl class colon2
|
616
|
+
colon3 const cvar cvasgn cvdecl defined defn defs dot2
|
617
|
+
dot3 dregx dregx_once dstr dsym dxstr ensure evstr false
|
618
|
+
flip2 flip3 for gasgn gvar hash iasgn if iter ivar lasgn
|
619
|
+
lit lvar masgn match match2 match3 module next nil not
|
620
|
+
nth_ref op_asgn op_asgn1 op_asgn2 op_asgn_and op_asgn_or or
|
621
|
+
postexe redo resbody rescue retry return sclass self
|
622
|
+
splat str super svalue to_ary true undef until valias
|
623
|
+
when while xstr yield zsuper kwarg kwsplat safe_call)
|
624
|
+
|
625
|
+
##
|
626
|
+
# All ruby_parser nodes in an index hash. Used by jenkins algorithm.
|
627
|
+
|
628
|
+
NODE_NAMES = Hash[names.each_with_index.map {|n, i| [n.to_sym, i] }]
|
629
|
+
|
630
|
+
NODE_NAMES.default_proc = lambda { |h, k|
|
631
|
+
$stderr.puts "ERROR: couldn't find node type #{k} in Sexp::NODE_NAMES."
|
632
|
+
h[k] = NODE_NAMES.size
|
633
|
+
}
|
634
|
+
|
635
|
+
MAX_INT32 = 2 ** 32 - 1 # :nodoc:
|
636
|
+
|
637
|
+
def pure_ruby_hash # :nodoc: see above
|
638
|
+
hash = 0
|
639
|
+
|
640
|
+
n = NODE_NAMES[first]
|
641
|
+
|
642
|
+
raise "Bad lookup: #{first} in #{sexp.inspect}" unless n
|
643
|
+
|
644
|
+
hash += n & MAX_INT32
|
645
|
+
hash += hash << 10 & MAX_INT32
|
646
|
+
hash ^= hash >> 6 & MAX_INT32
|
647
|
+
|
648
|
+
each do |o|
|
649
|
+
next unless Sexp === o
|
650
|
+
hash = hash + o.pure_ruby_hash & MAX_INT32
|
651
|
+
hash = (hash + (hash << 10)) & MAX_INT32
|
652
|
+
hash = (hash ^ (hash >> 6)) & MAX_INT32
|
653
|
+
end
|
654
|
+
|
655
|
+
hash = (hash + (hash << 3)) & MAX_INT32
|
656
|
+
hash = (hash ^ (hash >> 11)) & MAX_INT32
|
657
|
+
hash = (hash + (hash << 15)) & MAX_INT32
|
658
|
+
|
659
|
+
hash
|
660
|
+
end
|
661
|
+
end
|
662
|
+
|
613
663
|
class Array # :nodoc:
|
614
664
|
|
615
665
|
##
|
data/test/test_flay.rb
CHANGED
@@ -7,6 +7,9 @@ require "tmpdir"
|
|
7
7
|
$: << "../../sexp_processor/dev/lib"
|
8
8
|
|
9
9
|
class TestSexp < Minitest::Test
|
10
|
+
OPTS = Flay.parse_options %w[--mass=1 -v]
|
11
|
+
DEF_OPTS = {:diff=>false, :mass=>16, :summary=>false, :verbose=>false, :number=>true, :timeout=>10, :liberal=>false, :fuzzy=>false, :only=>nil}
|
12
|
+
|
10
13
|
def setup
|
11
14
|
# a(1) { |c| d }
|
12
15
|
@s = s(:iter,
|
@@ -16,10 +19,7 @@ class TestSexp < Minitest::Test
|
|
16
19
|
end
|
17
20
|
|
18
21
|
def test_structural_hash
|
19
|
-
hash =
|
20
|
-
s(:call, s(:arglist, s(:lit))),
|
21
|
-
s(:lasgn),
|
22
|
-
s(:call, s(:arglist))).hash
|
22
|
+
hash = 3336573932
|
23
23
|
|
24
24
|
assert_equal hash, @s.deep_clone.structural_hash
|
25
25
|
assert_equal hash, @s.structural_hash
|
@@ -46,13 +46,13 @@ class TestSexp < Minitest::Test
|
|
46
46
|
s(:call, s(:arglist)))
|
47
47
|
|
48
48
|
expected = [
|
49
|
-
s[1]
|
50
|
-
s[1][1]
|
51
|
-
s[1][1][1]
|
52
|
-
s[2]
|
53
|
-
s[3]
|
54
|
-
s[3][1]
|
55
|
-
].sort
|
49
|
+
s[1],
|
50
|
+
s[1][1],
|
51
|
+
s[1][1][1],
|
52
|
+
s[2],
|
53
|
+
s[3],
|
54
|
+
s[3][1],
|
55
|
+
].map(&:structural_hash).sort
|
56
56
|
|
57
57
|
assert_equal expected, @s.all_structural_subhashes.sort.uniq
|
58
58
|
|
@@ -98,7 +98,18 @@ class TestSexp < Minitest::Test
|
|
98
98
|
end
|
99
99
|
RUBY
|
100
100
|
|
101
|
+
def register_node_types
|
102
|
+
# Register these node types to remove warnings in test
|
103
|
+
capture_io do
|
104
|
+
[:a, :b, :c, :d, :e].each do |s|
|
105
|
+
Sexp::NODE_NAMES[s]
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
101
110
|
def test_prune
|
111
|
+
register_node_types
|
112
|
+
|
102
113
|
contained = s(:a, s(:b,s(:c)), s(:d,s(:e)))
|
103
114
|
container = s(:d, contained)
|
104
115
|
|
@@ -135,6 +146,8 @@ class TestSexp < Minitest::Test
|
|
135
146
|
end
|
136
147
|
|
137
148
|
def test_prune_liberal
|
149
|
+
register_node_types
|
150
|
+
|
138
151
|
contained = s(:a, s(:b,s(:c)), s(:d,s(:e)))
|
139
152
|
container = s(:d, contained)
|
140
153
|
|
@@ -209,7 +222,7 @@ class TestSexp < Minitest::Test
|
|
209
222
|
end
|
210
223
|
|
211
224
|
def test_report
|
212
|
-
flay = Flay.new
|
225
|
+
flay = Flay.new OPTS
|
213
226
|
|
214
227
|
flay.process_sexp DOG_AND_CAT.deep_clone
|
215
228
|
flay.analyze
|
@@ -232,7 +245,7 @@ class TestSexp < Minitest::Test
|
|
232
245
|
|
233
246
|
def test_report_io
|
234
247
|
out = StringIO.new
|
235
|
-
flay = Flay.new
|
248
|
+
flay = Flay.new OPTS
|
236
249
|
|
237
250
|
flay.process_sexp DOG_AND_CAT.deep_clone
|
238
251
|
flay.analyze
|
@@ -250,7 +263,7 @@ class TestSexp < Minitest::Test
|
|
250
263
|
end
|
251
264
|
|
252
265
|
def test_report_diff
|
253
|
-
flay = Flay.new
|
266
|
+
flay = Flay.new OPTS.merge(:diff => true)
|
254
267
|
|
255
268
|
flay.process_sexp DOG_AND_CAT.deep_clone
|
256
269
|
flay.analyze
|
@@ -287,7 +300,7 @@ class TestSexp < Minitest::Test
|
|
287
300
|
end
|
288
301
|
|
289
302
|
def test_report_diff_plugin_converter
|
290
|
-
flay = Flay.new
|
303
|
+
flay = Flay.new OPTS.merge(:diff => true)
|
291
304
|
|
292
305
|
flay.process_sexp DOG_AND_CAT.deep_clone
|
293
306
|
flay.analyze
|
@@ -416,8 +429,7 @@ class TestSexp < Minitest::Test
|
|
416
429
|
dog_and_cat = ["##\n# I am a dog.\n\ndef x\n return \"Hello\"\nend",
|
417
430
|
"##\n# I\n#\n# am\n# a\n# cat.\n\ndef y\n return \"Hello\"\nend"]
|
418
431
|
|
419
|
-
|
420
|
-
flay = Flay.new opts
|
432
|
+
flay = Flay.new DEF_OPTS
|
421
433
|
|
422
434
|
exp = <<-EOM.gsub(/\d+/, "N").gsub(/^ {6}/, "").chomp
|
423
435
|
##
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -10,9 +10,9 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
13
|
+
MIIDijCCAnKgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu
|
14
14
|
ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
|
15
|
-
|
15
|
+
GRYDY29tMB4XDTE2MDkyNjAxNTczNVoXDTE3MDkyNjAxNTczNVowRTETMBEGA1UE
|
16
16
|
AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
|
17
17
|
JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
|
18
18
|
b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
|
@@ -20,129 +20,130 @@ cert_chain:
|
|
20
20
|
oOvjtt5P8+GSK9zLzxQP0gVLS/D0FmoE44XuDr3iQkVS2ujU5zZL84mMNqNB1znh
|
21
21
|
GiadM9GHRaDiaxuX0cIUBj19T01mVE2iymf9I6bEsiayK/n6QujtyCbTWsAS9Rqt
|
22
22
|
qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
|
23
|
-
gBEfoTEGr7Zii72cx+
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
gBEfoTEGr7Zii72cx+sCAwEAAaOBhDCBgTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIE
|
24
|
+
sDAdBgNVHQ4EFgQUR8V72Z3+v+2P9abCnL4wjx32T+EwIwYDVR0RBBwwGoEYcnlh
|
25
|
+
bmQtcnVieUB6ZW5zcGlkZXIuY29tMCMGA1UdEgQcMBqBGHJ5YW5kLXJ1YnlAemVu
|
26
|
+
c3BpZGVyLmNvbTANBgkqhkiG9w0BAQUFAAOCAQEAIGzgp0aZ2W9+v96ujmBcQHoC
|
27
|
+
buy0iU68MVj2VlxMyfr1KPZIh1OyhU4UO4zrkREcH8ML70v9cYHNvOd9oynRHnvC
|
28
|
+
l2tj/fD3YJ0AEkJxGrYwRWQmvMfC4bJ02bC1+rVOUIXXKp3+cUmiN4sTniof8VFo
|
29
|
+
bo/YYP4c7erpERa+9hrqygg6WQbJlk2YRlH3JXPFjmu869i2dcbR5ZLOAeEy+axH
|
30
|
+
E4oJcnPkJAr0rw504JGtlZtONZQblwmRJOIdXzolaE3NRGUzGVOUSptZppAKiavY
|
31
|
+
fO6tdKQc/5RfA8oQEkg8hrxA5PQSz4TOFJGLpFvIapEk6tMruQ0bHgkhr9auXg==
|
31
32
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
33
|
+
date: 2017-04-14 00:00:00.000000000 Z
|
33
34
|
dependencies:
|
34
35
|
- !ruby/object:Gem::Dependency
|
35
36
|
name: sexp_processor
|
36
37
|
requirement: !ruby/object:Gem::Requirement
|
37
38
|
requirements:
|
38
|
-
- - ~>
|
39
|
+
- - "~>"
|
39
40
|
- !ruby/object:Gem::Version
|
40
41
|
version: '4.0'
|
41
42
|
type: :runtime
|
42
43
|
prerelease: false
|
43
44
|
version_requirements: !ruby/object:Gem::Requirement
|
44
45
|
requirements:
|
45
|
-
- - ~>
|
46
|
+
- - "~>"
|
46
47
|
- !ruby/object:Gem::Version
|
47
48
|
version: '4.0'
|
48
49
|
- !ruby/object:Gem::Dependency
|
49
50
|
name: ruby_parser
|
50
51
|
requirement: !ruby/object:Gem::Requirement
|
51
52
|
requirements:
|
52
|
-
- - ~>
|
53
|
+
- - "~>"
|
53
54
|
- !ruby/object:Gem::Version
|
54
55
|
version: '3.0'
|
55
56
|
type: :runtime
|
56
57
|
prerelease: false
|
57
58
|
version_requirements: !ruby/object:Gem::Requirement
|
58
59
|
requirements:
|
59
|
-
- - ~>
|
60
|
+
- - "~>"
|
60
61
|
- !ruby/object:Gem::Version
|
61
62
|
version: '3.0'
|
62
63
|
- !ruby/object:Gem::Dependency
|
63
64
|
name: erubis
|
64
65
|
requirement: !ruby/object:Gem::Requirement
|
65
66
|
requirements:
|
66
|
-
- - ~>
|
67
|
+
- - "~>"
|
67
68
|
- !ruby/object:Gem::Version
|
68
69
|
version: 2.7.0
|
69
70
|
type: :runtime
|
70
71
|
prerelease: false
|
71
72
|
version_requirements: !ruby/object:Gem::Requirement
|
72
73
|
requirements:
|
73
|
-
- - ~>
|
74
|
+
- - "~>"
|
74
75
|
- !ruby/object:Gem::Version
|
75
76
|
version: 2.7.0
|
76
77
|
- !ruby/object:Gem::Dependency
|
77
78
|
name: path_expander
|
78
79
|
requirement: !ruby/object:Gem::Requirement
|
79
80
|
requirements:
|
80
|
-
- - ~>
|
81
|
+
- - "~>"
|
81
82
|
- !ruby/object:Gem::Version
|
82
83
|
version: '1.0'
|
83
84
|
type: :runtime
|
84
85
|
prerelease: false
|
85
86
|
version_requirements: !ruby/object:Gem::Requirement
|
86
87
|
requirements:
|
87
|
-
- - ~>
|
88
|
+
- - "~>"
|
88
89
|
- !ruby/object:Gem::Version
|
89
90
|
version: '1.0'
|
90
91
|
- !ruby/object:Gem::Dependency
|
91
|
-
name:
|
92
|
+
name: minitest
|
92
93
|
requirement: !ruby/object:Gem::Requirement
|
93
94
|
requirements:
|
94
|
-
- - ~>
|
95
|
+
- - "~>"
|
95
96
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
97
|
+
version: 5.8.0
|
97
98
|
type: :development
|
98
99
|
prerelease: false
|
99
100
|
version_requirements: !ruby/object:Gem::Requirement
|
100
101
|
requirements:
|
101
|
-
- - ~>
|
102
|
+
- - "~>"
|
102
103
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
104
|
+
version: 5.8.0
|
104
105
|
- !ruby/object:Gem::Dependency
|
105
|
-
name:
|
106
|
+
name: ruby2ruby
|
106
107
|
requirement: !ruby/object:Gem::Requirement
|
107
108
|
requirements:
|
108
|
-
- - ~>
|
109
|
+
- - "~>"
|
109
110
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
111
|
+
version: 2.2.0
|
111
112
|
type: :development
|
112
113
|
prerelease: false
|
113
114
|
version_requirements: !ruby/object:Gem::Requirement
|
114
115
|
requirements:
|
115
|
-
- - ~>
|
116
|
+
- - "~>"
|
116
117
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
118
|
+
version: 2.2.0
|
118
119
|
- !ruby/object:Gem::Dependency
|
119
|
-
name:
|
120
|
+
name: rdoc
|
120
121
|
requirement: !ruby/object:Gem::Requirement
|
121
122
|
requirements:
|
122
|
-
- - ~>
|
123
|
+
- - "~>"
|
123
124
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
125
|
+
version: '4.0'
|
125
126
|
type: :development
|
126
127
|
prerelease: false
|
127
128
|
version_requirements: !ruby/object:Gem::Requirement
|
128
129
|
requirements:
|
129
|
-
- - ~>
|
130
|
+
- - "~>"
|
130
131
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
132
|
+
version: '4.0'
|
132
133
|
- !ruby/object:Gem::Dependency
|
133
134
|
name: hoe
|
134
135
|
requirement: !ruby/object:Gem::Requirement
|
135
136
|
requirements:
|
136
|
-
- - ~>
|
137
|
+
- - "~>"
|
137
138
|
- !ruby/object:Gem::Version
|
138
|
-
version: '3.
|
139
|
+
version: '3.16'
|
139
140
|
type: :development
|
140
141
|
prerelease: false
|
141
142
|
version_requirements: !ruby/object:Gem::Requirement
|
142
143
|
requirements:
|
143
|
-
- - ~>
|
144
|
+
- - "~>"
|
144
145
|
- !ruby/object:Gem::Version
|
145
|
-
version: '3.
|
146
|
+
version: '3.16'
|
146
147
|
description: |-
|
147
148
|
Flay analyzes code for structural similarities. Differences in literal
|
148
149
|
values, variable, class, method names, whitespace, programming style,
|
@@ -173,23 +174,23 @@ licenses:
|
|
173
174
|
metadata: {}
|
174
175
|
post_install_message:
|
175
176
|
rdoc_options:
|
176
|
-
- --main
|
177
|
+
- "--main"
|
177
178
|
- README.txt
|
178
179
|
require_paths:
|
179
180
|
- lib
|
180
181
|
required_ruby_version: !ruby/object:Gem::Requirement
|
181
182
|
requirements:
|
182
|
-
- -
|
183
|
+
- - ">="
|
183
184
|
- !ruby/object:Gem::Version
|
184
185
|
version: '0'
|
185
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
187
|
requirements:
|
187
|
-
- -
|
188
|
+
- - ">="
|
188
189
|
- !ruby/object:Gem::Version
|
189
190
|
version: '0'
|
190
191
|
requirements: []
|
191
192
|
rubyforge_project:
|
192
|
-
rubygems_version: 2.
|
193
|
+
rubygems_version: 2.6.8
|
193
194
|
signing_key:
|
194
195
|
specification_version: 4
|
195
196
|
summary: Flay analyzes code for structural similarities
|
metadata.gz.sig
CHANGED
Binary file
|