flay 2.12.0 → 2.13.2
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/History.rdoc +28 -0
- data/Rakefile +1 -1
- data/lib/flay.rb +12 -17
- data/lib/flay_erb.rb +58 -15
- data/lib/flay_task.rb +1 -1
- data/test/test_flay.rb +3 -3
- data.tar.gz.sig +0 -0
- metadata +31 -24
- metadata.gz.sig +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de2d236dadc0340897219bba93297f0075b425a8ed67bf942ec858652622c188
|
4
|
+
data.tar.gz: 0647f0f3e5f11b90ebd3487c0b8a0fcd90ebfc0251596525f7c06623ce8ab045
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0083c27a6b5861262235ae4199cdf85a60c2851d939927fafad7a77714ae660a5a38b783403273dea51b59579438eab41bb95239a48e73587ea2cfb84746b99f'
|
7
|
+
data.tar.gz: 8c7d1e26acc0f02751930d56de8f8972a849b750dcefbea11cfdd873ad1bc7f2f9338bfe1d6e1d487fcd00ed7f7dc6e4b557555fa430777b3e7ceda7c4b70da6
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
@@ -1,3 +1,31 @@
|
|
1
|
+
=== 2.13.2 / 2024-02-05
|
2
|
+
|
3
|
+
* 1 bug fix:
|
4
|
+
|
5
|
+
* Pass dirs to Flay.run in FlayTask. (adam12)
|
6
|
+
|
7
|
+
=== 2.13.1 / 2023-07-20
|
8
|
+
|
9
|
+
* 1 minor enhancement:
|
10
|
+
|
11
|
+
* Brought in action_view erubi hacks to enable block calls w/ <%= forms.
|
12
|
+
|
13
|
+
=== 2.13.0 / 2022-04-09
|
14
|
+
|
15
|
+
* 1 minor enhancement:
|
16
|
+
|
17
|
+
* Switched from erubis to erubi for erb processing. (clive-devops)
|
18
|
+
|
19
|
+
* 1 bug fix:
|
20
|
+
|
21
|
+
* Minor cleanup and top-level error handling changes.
|
22
|
+
|
23
|
+
=== 2.12.1 / 2019-10-08
|
24
|
+
|
25
|
+
* 1 bug fix:
|
26
|
+
|
27
|
+
* Fixed some sexp access under STRICT_SEXP=1.
|
28
|
+
|
1
29
|
=== 2.12.0 / 2018-04-29
|
2
30
|
|
3
31
|
* 1 minor enhancement:
|
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.2" # :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
|
|
@@ -579,7 +571,10 @@ class Sexp
|
|
579
571
|
s
|
580
572
|
end
|
581
573
|
|
574
|
+
alias :[] :[] # needed for STRICT_SEXP
|
575
|
+
|
582
576
|
def [] a # :nodoc:
|
577
|
+
# TODO: figure out a way to make this STRICT_SEXP happy
|
583
578
|
s = super
|
584
579
|
if Sexp === s then
|
585
580
|
s.file = self.file
|
@@ -636,7 +631,7 @@ class Sexp # straight from flay-persistent
|
|
636
631
|
def pure_ruby_hash # :nodoc: see above
|
637
632
|
hash = 0
|
638
633
|
|
639
|
-
n = NODE_NAMES[
|
634
|
+
n = NODE_NAMES[sexp_type]
|
640
635
|
|
641
636
|
raise "Bad lookup: #{first} in #{sexp.inspect}" unless n
|
642
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,8 @@ class Flay
|
|
13
10
|
def process_erb file
|
14
11
|
erb = File.read file
|
15
12
|
|
16
|
-
ruby =
|
13
|
+
ruby = Erubi.new(erb).src
|
14
|
+
|
17
15
|
begin
|
18
16
|
RubyParser.new.process(ruby, file)
|
19
17
|
rescue => e
|
@@ -22,22 +20,67 @@ class Flay
|
|
22
20
|
end
|
23
21
|
end
|
24
22
|
|
25
|
-
|
26
|
-
|
23
|
+
# stolen (and munged) from lib/action_view/template/handlers/erb/erubi.rb
|
24
|
+
# this is also in the debride-erb gem, update both!
|
25
|
+
class Erubi < ::Erubi::Engine
|
26
|
+
# :nodoc: all
|
27
|
+
def initialize(input, properties = {})
|
28
|
+
@newline_pending = 0
|
29
|
+
|
30
|
+
properties[:postamble] = "_buf.to_s"
|
31
|
+
properties[:bufvar] = "_buf"
|
32
|
+
properties[:freeze_template_literals] = false
|
33
|
+
|
34
|
+
super
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_text(text)
|
38
|
+
return if text.empty?
|
27
39
|
|
28
|
-
|
29
|
-
|
30
|
-
src << '@output_buffer.append= ' << code
|
40
|
+
if text == "\n"
|
41
|
+
@newline_pending += 1
|
31
42
|
else
|
32
|
-
src <<
|
43
|
+
src << "_buf.safe_append='"
|
44
|
+
src << "\n" * @newline_pending if @newline_pending > 0
|
45
|
+
src << text.gsub(/['\\]/, '\\\\\&')
|
46
|
+
src << "';"
|
47
|
+
|
48
|
+
@newline_pending = 0
|
33
49
|
end
|
34
50
|
end
|
35
51
|
|
36
|
-
|
37
|
-
|
38
|
-
|
52
|
+
BLOCK_EXPR = /\s*((\s+|\))do|\{)(\s*\|[^|]*\|)?\s*\Z/
|
53
|
+
|
54
|
+
def add_expression(indicator, code)
|
55
|
+
flush_newline_if_pending(src)
|
56
|
+
|
57
|
+
if (indicator == "==") || @escape
|
58
|
+
src << "_buf.safe_expr_append="
|
39
59
|
else
|
40
|
-
src << "
|
60
|
+
src << "_buf.append="
|
61
|
+
end
|
62
|
+
|
63
|
+
if BLOCK_EXPR.match?(code)
|
64
|
+
src << " " << code
|
65
|
+
else
|
66
|
+
src << "(" << code << ");"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def add_code(code)
|
71
|
+
flush_newline_if_pending(src)
|
72
|
+
super
|
73
|
+
end
|
74
|
+
|
75
|
+
def add_postamble(_)
|
76
|
+
flush_newline_if_pending(src)
|
77
|
+
super
|
78
|
+
end
|
79
|
+
|
80
|
+
def flush_newline_if_pending(src)
|
81
|
+
if @newline_pending > 0
|
82
|
+
src << "_buf.safe_append='#{"\n" * @newline_pending}';"
|
83
|
+
@newline_pending = 0
|
41
84
|
end
|
42
85
|
end
|
43
86
|
end
|
data/lib/flay_task.rb
CHANGED
@@ -45,7 +45,7 @@ class FlayTask < Rake::TaskLib
|
|
45
45
|
desc "Analyze for code duplication in: #{dirs.join(", ")}"
|
46
46
|
task name do
|
47
47
|
require "flay"
|
48
|
-
flay = Flay.run
|
48
|
+
flay = Flay.run(dirs)
|
49
49
|
flay.report if verbose
|
50
50
|
|
51
51
|
raise "Flay total too high! #{flay.total} > #{threshold}" if
|
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
|
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.2
|
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
|
+
MIIDPjCCAiagAwIBAgIBCDANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
|
14
14
|
ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
|
15
|
-
|
15
|
+
GRYDY29tMB4XDTI0MDEwMjIxMjEyM1oXDTI1MDEwMTIxMjEyM1owRTETMBEGA1UE
|
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
|
+
AQCygvpmncmkiSs9r/Kceo4bBPDszhTv6iBi4LwMReqnFrpNLMOWJw7xi8x+3eL2
|
26
|
+
XS09ZPNOt2zm70KmFouBMgOysnDY4k2dE8uF6B8JbZOO8QfalW+CoNBliefOTcn2
|
27
|
+
bg5IOP7UoGM5lC174/cbDJrJnRG9bzig5FAP0mvsgA8zgTRXQzIUAZEo92D5K7p4
|
28
|
+
B4/O998ho6BSOgYBI9Yk1ttdCtti6Y+8N9+fZESsjtWMykA+WXWeGUScHqiU+gH8
|
29
|
+
S7043fq9EbQdBr2AXdj92+CDwuTfHI6/Hj5FVBDULufrJaan4xUgL70Hvc6pTTeW
|
30
|
+
deKfBjgVAq7EYHu1AczzlUly
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
32
|
+
date: 2024-02-05 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: '
|
144
|
+
version: '4.2'
|
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: '
|
151
|
+
version: '4.2'
|
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.5.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
@@ -1,3 +1,3 @@
|
|
1
|
-
�
|
2
|
-
|
3
|
-
|
1
|
+
�������2X��1��Y�L:�@�G�;��f�����Fc \fܟ������.O�4��
|
2
|
+
$�{09�Bf�3f,p�K�a��tb42���DSa��
|
3
|
+
a::�,/���Y�㟘o'Z�>�i�0���wjF��V������%,��$��e�I镸A�u��'8�yd�$!���?2tšS+VR���m�1�l���5Jd�olV�%�����ޙ-�&�������7��(q]ϾV�-y�G�Z���pw
|