flay 2.11.0 → 2.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +22 -0
- data/Rakefile +1 -1
- data/lib/flay.rb +26 -37
- data/lib/flay_erb.rb +2 -25
- data/test/test_flay.rb +5 -8
- data.tar.gz.sig +0 -0
- metadata +31 -24
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae1c2d1ab38f3aa6a03b5d110f00f5548d661de7380373ae9d61265f682b6976
|
4
|
+
data.tar.gz: bf0dd5d5f85d35c4eb953e634071c5499e622c17ca11e9fa4089d2a7bc9f3964
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81c6471ba30b5d57ff3d1698d4920d3b94fa3161e4f36d2ce8ca22c42ab8476bb02a23a9884261e742c2d3e1efa8380c4f3995bd2c216634de695338848f79ef
|
7
|
+
data.tar.gz: 8daaba1c53636b86d1682606750bfd07b27590c34eb19799f267d6c76a0dd8dfff53ecbe14e3211a3b094751e25df44ffb3de4bf518d0970272edd53ad6f97df
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
=== 2.13.0 / 2022-04-09
|
2
|
+
|
3
|
+
* 1 minor enhancement:
|
4
|
+
|
5
|
+
* Switched from erubis to erubi for erb processing. (clive-devops)
|
6
|
+
|
7
|
+
* 1 bug fix:
|
8
|
+
|
9
|
+
* Minor cleanup and top-level error handling changes.
|
10
|
+
|
11
|
+
=== 2.12.1 / 2019-10-08
|
12
|
+
|
13
|
+
* 1 bug fix:
|
14
|
+
|
15
|
+
* Fixed some sexp access under STRICT_SEXP=1.
|
16
|
+
|
17
|
+
=== 2.12.0 / 2018-04-29
|
18
|
+
|
19
|
+
* 1 minor enhancement:
|
20
|
+
|
21
|
+
* Switched node filtering to happen before processing to avoid subtrees getting processed. Thanks to codeclimate.com for funding this effort!
|
22
|
+
|
1
23
|
=== 2.11.0 / 2018-04-05
|
2
24
|
|
3
25
|
* 2 minor enhancements:
|
data/Rakefile
CHANGED
data/lib/flay.rb
CHANGED
@@ -1,23 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby -w
|
2
2
|
|
3
3
|
require "optparse"
|
4
|
-
require "rubygems"
|
5
4
|
require "sexp_processor"
|
6
5
|
require "ruby_parser"
|
7
6
|
require "path_expander"
|
8
7
|
require "timeout"
|
9
8
|
require "zlib"
|
10
9
|
|
11
|
-
class File
|
12
|
-
RUBY19 = "<3".respond_to? :encoding unless defined? RUBY19 # :nodoc:
|
13
|
-
|
14
|
-
class << self
|
15
|
-
alias :binread :read unless RUBY19
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
10
|
class Flay
|
20
|
-
VERSION = "2.
|
11
|
+
VERSION = "2.13.0" # :nodoc:
|
21
12
|
|
22
13
|
class Item < Struct.new(:structural_hash, :name, :bonus, :mass, :locations)
|
23
14
|
alias identical? bonus
|
@@ -159,8 +150,8 @@ class Flay
|
|
159
150
|
end
|
160
151
|
end
|
161
152
|
@@plugins
|
162
|
-
rescue
|
163
|
-
#
|
153
|
+
rescue => e
|
154
|
+
warn "Error loading plugins: #{e}" if option[:verbose]
|
164
155
|
end
|
165
156
|
|
166
157
|
# :stopdoc:
|
@@ -228,10 +219,11 @@ class Flay
|
|
228
219
|
update_masses
|
229
220
|
|
230
221
|
sorted = masses.sort_by { |h,m|
|
222
|
+
exp = hashes[h].first
|
231
223
|
[-m,
|
232
|
-
|
233
|
-
|
234
|
-
|
224
|
+
exp.file,
|
225
|
+
exp.line,
|
226
|
+
exp.sexp_type.to_s]
|
235
227
|
}
|
236
228
|
|
237
229
|
sorted.map { |hash, mass|
|
@@ -249,7 +241,7 @@ class Flay
|
|
249
241
|
Location[x.file, x.line, extra]
|
250
242
|
}
|
251
243
|
|
252
|
-
Item[hash, node.
|
244
|
+
Item[hash, node.sexp_type, bonus, mass, locs]
|
253
245
|
}.compact
|
254
246
|
end
|
255
247
|
|
@@ -280,14 +272,26 @@ class Flay
|
|
280
272
|
end
|
281
273
|
end
|
282
274
|
|
275
|
+
##
|
276
|
+
# Before processing, filter any sexp's that match against filters
|
277
|
+
# specified in +option[:filters]+. This changes the sexp itself.
|
278
|
+
|
279
|
+
def filter_sexp exp
|
280
|
+
exp.delete_if { |sexp|
|
281
|
+
if Sexp === sexp then
|
282
|
+
del = option[:filters].any? { |pattern| pattern.satisfy? sexp }
|
283
|
+
del or (filter_sexp(sexp); false)
|
284
|
+
end
|
285
|
+
}
|
286
|
+
end
|
287
|
+
|
283
288
|
##
|
284
289
|
# Process a sexp +pt+.
|
285
290
|
|
286
291
|
def process_sexp pt
|
287
|
-
pt.deep_each do |node|
|
292
|
+
filter_sexp(pt).deep_each do |node|
|
288
293
|
next :skip if node.none? { |sub| Sexp === sub }
|
289
294
|
next :skip if node.mass < self.mass_threshold
|
290
|
-
next :skip if option[:filters].any? { |pattern| pattern.satisfy? node }
|
291
295
|
|
292
296
|
self.hashes[node.structural_hash] << node
|
293
297
|
|
@@ -330,22 +334,6 @@ class Flay
|
|
330
334
|
end
|
331
335
|
end
|
332
336
|
|
333
|
-
##
|
334
|
-
# Given an array of sexp patterns (see sexp_processor), delete any
|
335
|
-
# buckets whose members match any of the patterns.
|
336
|
-
|
337
|
-
def filter *patterns
|
338
|
-
return if patterns.empty?
|
339
|
-
|
340
|
-
self.hashes.delete_if { |_, sexps|
|
341
|
-
sexps.any? { |sexp|
|
342
|
-
patterns.any? { |pattern|
|
343
|
-
pattern =~ sexp
|
344
|
-
}
|
345
|
-
}
|
346
|
-
}
|
347
|
-
end
|
348
|
-
|
349
337
|
##
|
350
338
|
# Prunes nodes that aren't relevant to analysis or are already
|
351
339
|
# covered by another node. Also deletes nodes based on the
|
@@ -361,8 +349,6 @@ class Flay
|
|
361
349
|
else
|
362
350
|
prune_conservatively
|
363
351
|
end
|
364
|
-
|
365
|
-
self.filter(*option[:filters])
|
366
352
|
end
|
367
353
|
|
368
354
|
##
|
@@ -585,7 +571,10 @@ class Sexp
|
|
585
571
|
s
|
586
572
|
end
|
587
573
|
|
574
|
+
alias :[] :[] # needed for STRICT_SEXP
|
575
|
+
|
588
576
|
def [] a # :nodoc:
|
577
|
+
# TODO: figure out a way to make this STRICT_SEXP happy
|
589
578
|
s = super
|
590
579
|
if Sexp === s then
|
591
580
|
s.file = self.file
|
@@ -642,7 +631,7 @@ class Sexp # straight from flay-persistent
|
|
642
631
|
def pure_ruby_hash # :nodoc: see above
|
643
632
|
hash = 0
|
644
633
|
|
645
|
-
n = NODE_NAMES[
|
634
|
+
n = NODE_NAMES[sexp_type]
|
646
635
|
|
647
636
|
raise "Bad lookup: #{first} in #{sexp.inspect}" unless n
|
648
637
|
|
data/lib/flay_erb.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
|
3
|
-
require "rubygems"
|
4
1
|
require "flay"
|
5
|
-
require "
|
2
|
+
require "erubi"
|
6
3
|
|
7
4
|
class Flay
|
8
5
|
|
@@ -13,7 +10,7 @@ class Flay
|
|
13
10
|
def process_erb file
|
14
11
|
erb = File.read file
|
15
12
|
|
16
|
-
ruby =
|
13
|
+
ruby = Erubi::Engine.new(erb).src
|
17
14
|
begin
|
18
15
|
RubyParser.new.process(ruby, file)
|
19
16
|
rescue => e
|
@@ -21,24 +18,4 @@ class Flay
|
|
21
18
|
raise e
|
22
19
|
end
|
23
20
|
end
|
24
|
-
|
25
|
-
class Erubis < ::Erubis::Eruby # :nodoc:
|
26
|
-
BLOCK_EXPR = /\s+(do|\{)(\s*\|[^|]*\|)?\s*\Z/
|
27
|
-
|
28
|
-
def add_expr_literal(src, code)
|
29
|
-
if code =~ BLOCK_EXPR
|
30
|
-
src << '@output_buffer.append= ' << code
|
31
|
-
else
|
32
|
-
src << '@output_buffer.append=(' << code << ');'
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def add_expr_escaped(src, code)
|
37
|
-
if code =~ BLOCK_EXPR
|
38
|
-
src << "@output_buffer.safe_append= " << code
|
39
|
-
else
|
40
|
-
src << "@output_buffer.safe_append=(" << code << ");"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
21
|
end
|
data/test/test_flay.rb
CHANGED
@@ -65,7 +65,7 @@ class TestSexp < Minitest::Test
|
|
65
65
|
assert_equal expected, x.sort.uniq
|
66
66
|
end
|
67
67
|
|
68
|
-
DOG_AND_CAT =
|
68
|
+
DOG_AND_CAT = RubyParser.new.process <<-RUBY
|
69
69
|
##
|
70
70
|
# I am a dog.
|
71
71
|
|
@@ -88,7 +88,7 @@ class TestSexp < Minitest::Test
|
|
88
88
|
end
|
89
89
|
RUBY
|
90
90
|
|
91
|
-
ROUND =
|
91
|
+
ROUND = RubyParser.new.process <<-RUBY
|
92
92
|
def x(n)
|
93
93
|
if n % 2 == 0
|
94
94
|
return n
|
@@ -196,7 +196,7 @@ class TestSexp < Minitest::Test
|
|
196
196
|
|
197
197
|
flay.process_sexp ROUND.deep_clone
|
198
198
|
|
199
|
-
actual = flay.hashes.values.map { |sexps| sexps.map
|
199
|
+
actual = flay.hashes.values.map { |sexps| sexps.map(&:sexp_type) }
|
200
200
|
|
201
201
|
assert_equal expected, actual.sort_by { |a| a.inspect }
|
202
202
|
end
|
@@ -450,13 +450,12 @@ class TestSexp < Minitest::Test
|
|
450
450
|
exp_foo = s(:begin,
|
451
451
|
s(:begin,
|
452
452
|
s(:filter_me,
|
453
|
-
s(:a, s(:b)))))
|
453
|
+
s(:a, s(:b, s(:c, s(:d)))))))
|
454
454
|
|
455
455
|
exp_bar = s(:begin,
|
456
456
|
s(:begin,
|
457
457
|
s(:filter_me,
|
458
|
-
s(:a, s(:b))
|
459
|
-
s(:c))))
|
458
|
+
s(:a, s(:b, s(:c, s(:d)))))))
|
460
459
|
|
461
460
|
filter = Sexp::Matcher.parse("(filter_me ___)")
|
462
461
|
options = Flay.default_options.merge(mass: 0, filters: [filter])
|
@@ -467,8 +466,6 @@ class TestSexp < Minitest::Test
|
|
467
466
|
|
468
467
|
refute_nodes :filter_me
|
469
468
|
|
470
|
-
flay.prune
|
471
|
-
|
472
469
|
assert_empty flay.hashes
|
473
470
|
end
|
474
471
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
13
|
+
MIIDPjCCAiagAwIBAgIBBjANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
|
14
14
|
ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
|
15
|
-
|
15
|
+
GRYDY29tMB4XDTIxMTIyMzIzMTkwNFoXDTIyMTIyMzIzMTkwNFowRTETMBEGA1UE
|
16
16
|
AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
|
17
17
|
JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
|
18
18
|
b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
|
@@ -21,15 +21,15 @@ cert_chain:
|
|
21
21
|
GiadM9GHRaDiaxuX0cIUBj19T01mVE2iymf9I6bEsiayK/n6QujtyCbTWsAS9Rqt
|
22
22
|
qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
|
23
23
|
gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
|
24
|
-
HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB
|
25
|
+
AQCKB5jfsuSnKb+t/Wrh3UpdkmX7TrEsjVmERC0pPqzQ5GQJgmEXDD7oMgaKXaAq
|
26
|
+
x2m+KSZDrqk7c8uho5OX6YMqg4KdxehfSLqqTZGoeV78qwf/jpPQZKTf+W9gUSJh
|
27
|
+
zsWpo4K50MP+QtdSbKXZwjAafpQ8hK0MnnZ/aeCsW9ov5vdXpYbf3dpg6ADXRGE7
|
28
|
+
lQY2y1tJ5/chqu6h7dQmnm2ABUqx9O+JcN9hbCYoA5i/EeubUEtFIh2w3SpO6YfB
|
29
|
+
JFmxn4h9YO/pVdB962BdBNNDia0kgIjI3ENnkLq0dKpYU3+F3KhEuTksLO0L6X/V
|
30
|
+
YsuyUzsMz6GQA4khyaMgKNSD
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
32
|
+
date: 2022-04-09 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: sexp_processor
|
@@ -60,19 +60,19 @@ dependencies:
|
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '3.0'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
63
|
+
name: erubi
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: '1.10'
|
69
69
|
type: :runtime
|
70
70
|
prerelease: false
|
71
71
|
version_requirements: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: '1.10'
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
77
|
name: path_expander
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
@@ -119,30 +119,36 @@ dependencies:
|
|
119
119
|
name: rdoc
|
120
120
|
requirement: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '4.0'
|
125
|
+
- - "<"
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '7'
|
125
128
|
type: :development
|
126
129
|
prerelease: false
|
127
130
|
version_requirements: !ruby/object:Gem::Requirement
|
128
131
|
requirements:
|
129
|
-
- - "
|
132
|
+
- - ">="
|
130
133
|
- !ruby/object:Gem::Version
|
131
134
|
version: '4.0'
|
135
|
+
- - "<"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '7'
|
132
138
|
- !ruby/object:Gem::Dependency
|
133
139
|
name: hoe
|
134
140
|
requirement: !ruby/object:Gem::Requirement
|
135
141
|
requirements:
|
136
142
|
- - "~>"
|
137
143
|
- !ruby/object:Gem::Version
|
138
|
-
version: '3.
|
144
|
+
version: '3.23'
|
139
145
|
type: :development
|
140
146
|
prerelease: false
|
141
147
|
version_requirements: !ruby/object:Gem::Requirement
|
142
148
|
requirements:
|
143
149
|
- - "~>"
|
144
150
|
- !ruby/object:Gem::Version
|
145
|
-
version: '3.
|
151
|
+
version: '3.23'
|
146
152
|
description: |-
|
147
153
|
Flay analyzes code for structural similarities. Differences in literal
|
148
154
|
values, variable, class, method names, whitespace, programming style,
|
@@ -170,8 +176,10 @@ files:
|
|
170
176
|
homepage: http://ruby.sadi.st/
|
171
177
|
licenses:
|
172
178
|
- MIT
|
173
|
-
metadata:
|
174
|
-
|
179
|
+
metadata:
|
180
|
+
homepage_uri: http://ruby.sadi.st/
|
181
|
+
source_code_uri: https://github.com/seattlerb/flay
|
182
|
+
post_install_message:
|
175
183
|
rdoc_options:
|
176
184
|
- "--main"
|
177
185
|
- README.rdoc
|
@@ -188,9 +196,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
196
|
- !ruby/object:Gem::Version
|
189
197
|
version: '0'
|
190
198
|
requirements: []
|
191
|
-
|
192
|
-
|
193
|
-
signing_key:
|
199
|
+
rubygems_version: 3.3.3
|
200
|
+
signing_key:
|
194
201
|
specification_version: 4
|
195
202
|
summary: Flay analyzes code for structural similarities
|
196
203
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|