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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3477e1943a1382b0b51cbce9a5e4f5b60c34adc2f38e1e4b713b05f6b7476160
4
- data.tar.gz: 042ef82c48aec49077113d53cbe425e6157fd61b36e7118af18dc7369561e77e
3
+ metadata.gz: de2d236dadc0340897219bba93297f0075b425a8ed67bf942ec858652622c188
4
+ data.tar.gz: 0647f0f3e5f11b90ebd3487c0b8a0fcd90ebfc0251596525f7c06623ce8ab045
5
5
  SHA512:
6
- metadata.gz: c05914fd7779c957f60e6e8f32d04a4069d427cf6ecb57b7be97fd53cd9d07969c0076bad6978077f09e47d73a5d7c76c5795233f846a20bc22aef2abbb41dad
7
- data.tar.gz: bdcc376f6c7651d1fe4d7ace6349a945a221fc89152bba731719ec4083996b98d98358e6b2506fa58ca6d919dd07d99433f3c6942e0639062909f4e1d55e44e6
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
@@ -21,7 +21,7 @@ Hoe.spec "flay" do
21
21
 
22
22
  dependency "sexp_processor", "~> 4.0"
23
23
  dependency "ruby_parser", "~> 3.0"
24
- dependency "erubis", "~> 2.7.0"
24
+ dependency "erubi", "~> 1.10"
25
25
  dependency "path_expander", "~> 1.0"
26
26
 
27
27
  dependency "minitest", "~> 5.8.0", :dev
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.12.0" # :nodoc:
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
- # ignore
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
- hashes[h].first.file,
233
- hashes[h].first.line,
234
- hashes[h].first.first.to_s]
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.first, bonus, mass, locs]
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[first]
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 "erubis"
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 = Erubis.new(erb).src
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
- class Erubis < ::Erubis::Eruby # :nodoc:
26
- BLOCK_EXPR = /\s+(do|\{)(\s*\|[^|]*\|)?\s*\Z/
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
- def add_expr_literal(src, code)
29
- if code =~ BLOCK_EXPR
30
- src << '@output_buffer.append= ' << code
40
+ if text == "\n"
41
+ @newline_pending += 1
31
42
  else
32
- src << '@output_buffer.append=(' << code << ');'
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
- def add_expr_escaped(src, code)
37
- if code =~ BLOCK_EXPR
38
- src << "@output_buffer.safe_append= " << code
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 << "@output_buffer.safe_append=(" << code << ");"
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 = Ruby18Parser.new.process <<-RUBY
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 = Ruby18Parser.new.process <<-RUBY
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 { |sexp| sexp.first } }
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.12.0
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
- MIIDPjCCAiagAwIBAgIBAjANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu
13
+ MIIDPjCCAiagAwIBAgIBCDANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
14
14
  ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
15
- GRYDY29tMB4XDTE3MTEyMTIxMTExMFoXDTE4MTEyMTIxMTExMFowRTETMBEGA1UE
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/hMA0GCSqGSIb3DQEBBQUAA4IB
25
- AQAfAXSQpsW7YSxd1csRtA/M4Zt0AMXFMd76GJ8Lgtg8G0+VFbdChRyDuDb0kPlW
26
- h9QQX/YABfCW8vxmssbMGrP+VGBAn7BbdTcfTlgCWrvMX1uL5aRL74nA4urKXqdW
27
- a0nP70K4958P3GffBdtE3KGkU5xstFnXGajxuBRnL66E15KU0BNehVxdG258bdPu
28
- EKN6MqBPftFiev3tuwqDV11r2GquDpniYcT+Mi8/PgeAgVT/afBeVgbB3KaZeTRR
29
- AhXhF6Wi2GTMezlj5jlI5XV7WsJUSwTp/YiVvcmT74ZaCRvexm6EnNhkrvJJ1Xeu
30
- V+HB+LYYhXWitInO/eXxDrFB
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: 2018-04-30 00:00:00.000000000 Z
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: erubis
63
+ name: erubi
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 2.7.0
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: 2.7.0
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.16'
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: '3.16'
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
- post_install_message:
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
- rubyforge_project:
192
- rubygems_version: 2.7.3
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
- ���x�����v����#�\����]�}gh�%l�]��/���Z+����R�{'gm�&jx����n���� G${�~�9�����a4�&�R��Rpf]bp�mSC�IQ��k�(-~~<\�Z� _�^(��� �ט`�!e����"�M�jRW�ry��{e�����wRg%�&cn$�b����
3
- ��V��l���� e��_�ӽ��B=C�ܸ��HH�� |d�넷���߉_��d
1
+ �������2X��1��Y�L:�@�G�;��f�����Fc \fܟ������.O4��
2
+ $�{09Bf3f,p�Ka��tb42���DSa��
3
+ a::�,/���Y�㟘o'Z�>�i�0���wjF��V������%,��$��e�I镸A�u��'8�yd�$!���?2tšS+VR���m�1�l���5JdolV�%�����ޙ-�&�������7��(q]ϾV�-y�GZ���pw