flay 2.13.3 → 2.14.1

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: f398ea8e7f796a1871faedb32dbee7d7377d30abcc91edd075f2015a6be95c74
4
- data.tar.gz: cdb49c908285be2c5c40118a33e7d0227e4a32a4b31736b374aaf31a43e58ac6
3
+ metadata.gz: 1f275c561e9ea5560f62973a4dbc4be004a2b00fa3fc8e219e05c5e1a5bb15c2
4
+ data.tar.gz: 60ab58da19978d367f25415b658fbe50c137934aee7933bcd3e77bb47f75c085
5
5
  SHA512:
6
- metadata.gz: 9c7f5b54202e563702d21ee8006d24124dd7810bb3518ae307a1eba17966a042864af2c0b772df9deab11517a8a6268159e5503d6fe70845722ef3544b7b84a9
7
- data.tar.gz: 301d1e56ecfd1c12e8d41e826e56c44899598712aec55daac4ba55f74df547e5421250c3ea8dace955edaeacacd0a513c4a3e888f83aa47fddcfe340fb49c9b2
6
+ metadata.gz: 3aef7416ffb1852e68ee9b4da66935bdbe1726171b71ea52982e14c752446cdcb52b409856f742f875a954800585199e36dec1e675ed88aed794bca9e2c1ccee
7
+ data.tar.gz: 330b6986a40592d54a9d318850cbd3ce334578820be31bec868b9e3e4e9112213e495eaca518f4e5c5632a9c0aa91b01ab60d8f97c4a472e1b3f44ff0e1378c7
checksums.yaml.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,18 @@
1
+ === 2.14.1 / 2025-12-20
2
+
3
+ * 3 bug fixes:
4
+
5
+ * Bumped dependency to prism to get some upstreamed fixes.
6
+ * Loosened the minitest dependency to include MT6.
7
+ * Removed local copy of the upstreamed fixes.
8
+
9
+ === 2.14.0 / 2025-12-11
10
+
11
+ * 2 minor enhancements:
12
+
13
+ * Bumped path_expander to 2.0.0.
14
+ * Switched to prism for ruby parsing. Use --legacy for RubyParser.
15
+
1
16
  === 2.13.3 / 2024-05-21
2
17
 
3
18
  * 2 bug fixes:
data/Rakefile CHANGED
@@ -4,7 +4,6 @@ require "rubygems"
4
4
  require "hoe"
5
5
 
6
6
  Hoe::add_include_dirs("../../sexp_processor/dev/lib",
7
- "../../ruby_parser/dev/lib",
8
7
  "../../ruby2ruby/dev/lib",
9
8
  "../../ZenTest/dev/lib",
10
9
  "../../path_expander/dev/lib",
@@ -20,11 +19,11 @@ Hoe.spec "flay" do
20
19
  license "MIT"
21
20
 
22
21
  dependency "sexp_processor", "~> 4.0"
23
- dependency "ruby_parser", "~> 3.0"
22
+ dependency "prism", "~> 1.7"
24
23
  dependency "erubi", "~> 1.10"
25
- dependency "path_expander", "~> 1.0"
24
+ dependency "path_expander", "~> 2.0"
26
25
 
27
- dependency "minitest", "~> 5.8.0", :dev
26
+ dependency "minitest", "> 5.8", :dev
28
27
  dependency "ruby2ruby", "~> 2.2.0", :dev
29
28
 
30
29
  self.flay_threshold = 250
data/lib/flay.rb CHANGED
@@ -2,13 +2,16 @@
2
2
 
3
3
  require "optparse"
4
4
  require "sexp_processor"
5
- require "ruby_parser"
6
5
  require "path_expander"
7
6
  require "timeout"
8
7
  require "zlib"
8
+ require "prism"
9
+ require "prism/translation/ruby_parser"
10
+
11
+ NotRubyParser = Class.new Prism::Translation::RubyParser # compatibility layer
9
12
 
10
13
  class Flay
11
- VERSION = "2.13.3" # :nodoc:
14
+ VERSION = "2.14.1" # :nodoc:
12
15
 
13
16
  class Item < Struct.new(:structural_hash, :name, :bonus, :mass, :locations)
14
17
  alias identical? bonus
@@ -45,6 +48,7 @@ class Flay
45
48
  :fuzzy => false,
46
49
  :only => nil,
47
50
  :filters => [],
51
+ :parser => NotRubyParser,
48
52
  }
49
53
  end
50
54
 
@@ -106,6 +110,11 @@ class Flay
106
110
  options[:timeout] = t.to_i
107
111
  end
108
112
 
113
+ opts.on("-t", "--legacy", "Use RubyParser to parse.") do
114
+ require "ruby_parser"
115
+ options[:parser] = RubyParser
116
+ end
117
+
109
118
  extensions = ["rb"] + Flay.load_plugins
110
119
 
111
120
  opts.separator ""
@@ -266,7 +275,8 @@ class Flay
266
275
 
267
276
  def process_rb file
268
277
  begin
269
- RubyParser.new.process(File.binread(file), file, option[:timeout])
278
+ parser = option[:parser].new
279
+ parser.process(File.binread(file), file, option[:timeout])
270
280
  rescue Timeout::Error
271
281
  warn "TIMEOUT parsing #{file}. Skipping."
272
282
  end
@@ -445,7 +455,7 @@ class Flay
445
455
  end
446
456
 
447
457
  def collapse_and_label ary # :nodoc:
448
- ary[0].zip(*ary[1..-1]).map { |lines|
458
+ ary.first.zip(*ary.drop(1)).map { |lines|
449
459
  if lines.uniq.size == 1 then
450
460
  " #{lines.first}"
451
461
  else
data/lib/flay_erb.rb CHANGED
@@ -13,7 +13,8 @@ class Flay
13
13
  ruby = Erubi.new(erb).src
14
14
 
15
15
  begin
16
- RubyParser.new.process(ruby, file)
16
+ parser = option[:parser].new
17
+ parser.process(ruby, file, option[:timeout])
17
18
  rescue => e
18
19
  warn ruby if option[:verbose]
19
20
  raise e
data/test/test_flay.rb CHANGED
@@ -4,11 +4,8 @@ require "minitest/autorun"
4
4
  require "flay"
5
5
  require "tmpdir"
6
6
 
7
- $: << "../../sexp_processor/dev/lib"
8
-
9
7
  class TestSexp < Minitest::Test
10
8
  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
9
 
13
10
  def setup
14
11
  # a(1) { |c| d }
@@ -65,7 +62,7 @@ class TestSexp < Minitest::Test
65
62
  assert_equal expected, x.sort.uniq
66
63
  end
67
64
 
68
- DOG_AND_CAT = RubyParser.new.process <<-RUBY
65
+ DOG_AND_CAT = NotRubyParser.new.process <<~RUBY
69
66
  ##
70
67
  # I am a dog.
71
68
 
@@ -88,7 +85,7 @@ class TestSexp < Minitest::Test
88
85
  end
89
86
  RUBY
90
87
 
91
- ROUND = RubyParser.new.process <<-RUBY
88
+ ROUND = NotRubyParser.new.process <<~RUBY
92
89
  def x(n)
93
90
  if n % 2 == 0
94
91
  return n
@@ -106,7 +103,7 @@ class TestSexp < Minitest::Test
106
103
  flay.process_sexp s(:outer,contained)
107
104
  2.times { flay.process_sexp s(:outer,container) }
108
105
 
109
- exp = eval <<-EOM # just to prevent emacs from reindenting it
106
+ exp = eval <<~EOM # just to prevent emacs from reindenting it
110
107
  [
111
108
  [ s(:a, s(:b, s(:c)), s(:d, s(:e))),
112
109
  s(:a, s(:b, s(:c)), s(:d, s(:e))),
@@ -142,7 +139,7 @@ class TestSexp < Minitest::Test
142
139
  flay.process_sexp s(:outer,contained)
143
140
  2.times { flay.process_sexp s(:outer,container) }
144
141
 
145
- exp = eval <<-EOM # just to prevent emacs from reindenting it
142
+ exp = eval <<~EOM # just to prevent emacs from reindenting it
146
143
  [
147
144
  [ s(:a, s(:b, s(:c)), s(:d, s(:e))),
148
145
  s(:a, s(:b, s(:c)), s(:d, s(:e))),
@@ -218,7 +215,7 @@ class TestSexp < Minitest::Test
218
215
  flay.report
219
216
  end
220
217
 
221
- exp = <<-END.gsub(/\d+/, "N").gsub(/^ {6}/, "")
218
+ exp = <<~END
222
219
  Total score (lower is better) = 16
223
220
 
224
221
  1) Similar code found in :class (mass = 16)
@@ -227,7 +224,7 @@ class TestSexp < Minitest::Test
227
224
  END
228
225
 
229
226
  assert_equal "", err
230
- assert_equal exp, out.gsub(/\d+/, "N")
227
+ assert_equal exp.gsub(/\d+/, "N"), out.gsub(/\d+/, "N")
231
228
  end
232
229
 
233
230
  def test_report_io
@@ -238,7 +235,7 @@ class TestSexp < Minitest::Test
238
235
  flay.analyze
239
236
  flay.report out
240
237
 
241
- exp = <<-END.gsub(/\d+/, "N").gsub(/^ {6}/, "")
238
+ exp = <<~END
242
239
  Total score (lower is better) = 16
243
240
 
244
241
  1) Similar code found in :class (mass = 16)
@@ -246,7 +243,7 @@ class TestSexp < Minitest::Test
246
243
  (string):6
247
244
  END
248
245
 
249
- assert_equal exp, out.string.gsub(/\d+/, "N")
246
+ assert_equal exp.gsub(/\d+/, "N"), out.string.gsub(/\d+/, "N")
250
247
  end
251
248
 
252
249
  def test_report_diff
@@ -259,7 +256,7 @@ class TestSexp < Minitest::Test
259
256
  flay.report
260
257
  end
261
258
 
262
- exp = <<-END.gsub(/\d+/, "N").gsub(/^ {6}/, "")
259
+ exp = <<~END.gsub(/_NL_/, "")
263
260
  Total score (lower is better) = 16
264
261
 
265
262
  1) Similar code found in :class (mass = 16)
@@ -272,7 +269,7 @@ class TestSexp < Minitest::Test
272
269
  B: # am
273
270
  B: # a
274
271
  B: # cat.
275
-
272
+ _NL_
276
273
  A: class Dog
277
274
  B: class Cat
278
275
  A: def x
@@ -283,7 +280,7 @@ class TestSexp < Minitest::Test
283
280
  END
284
281
 
285
282
  assert_equal "", err
286
- assert_equal exp, out.gsub(/\d+/, "N").gsub(/^ {3}$/, "")
283
+ assert_equal exp.gsub(/\d+/, "N"), out.gsub(/\d+/, "N")
287
284
  end
288
285
 
289
286
  def test_report_diff_plugin_converter
@@ -301,7 +298,7 @@ class TestSexp < Minitest::Test
301
298
 
302
299
  Flay.send(:remove_method, :sexp_to_)
303
300
 
304
- exp = <<-END.gsub(/\d+/, "N").gsub(/^ {6}/, "")
301
+ exp = <<~END
305
302
  Total score (lower is better) = 16
306
303
 
307
304
  1) Similar code found in :class (mass = 16)
@@ -313,7 +310,7 @@ class TestSexp < Minitest::Test
313
310
  END
314
311
 
315
312
  assert_equal "", err
316
- assert_equal exp, out.gsub(/\d+/, "N").gsub(/^ {3}$/, "")
313
+ assert_equal exp.gsub(/\d+/, "N"), out.gsub(/\d+/, "N")
317
314
  end
318
315
 
319
316
  def test_n_way_diff
@@ -322,7 +319,7 @@ class TestSexp < Minitest::Test
322
319
 
323
320
  flay = Flay.new
324
321
 
325
- exp = <<-EOM.gsub(/\d+/, "N").gsub(/^ {6}/, "").chomp
322
+ exp = <<~EOM.chomp
326
323
  ##
327
324
  A: # I am a dog.
328
325
  B: # I
@@ -349,7 +346,7 @@ class TestSexp < Minitest::Test
349
346
 
350
347
  flay = Flay.new
351
348
 
352
- exp = <<-EOM.gsub(/\d+/, "N").gsub(/^ {6}/, "").chomp
349
+ exp = <<~EOM.gsub(/\d+/, "N").chomp
353
350
  A: class Dog
354
351
  B: class Cat
355
352
  A: def x
@@ -359,7 +356,7 @@ class TestSexp < Minitest::Test
359
356
  end
360
357
  EOM
361
358
 
362
- assert_equal exp, flay.n_way_diff(*dog_and_cat).gsub(/^ {3}$/, "")
359
+ assert_equal exp, flay.n_way_diff(*dog_and_cat)
363
360
  end
364
361
 
365
362
  def test_split_and_group
@@ -393,10 +390,12 @@ class TestSexp < Minitest::Test
393
390
  def test_collapse_and_label
394
391
  flay = Flay.new
395
392
 
396
- a = %w(a b c).map { |s| s.group = "A"; s }
397
- b = %w(d b f).map { |s| s.group = "B"; s }
393
+ a = %w(a b c).map(&:dup).map { |s| s.group = "A"; s }
394
+ b = %w(d b f).map(&:dup).map { |s| s.group = "B"; s }
398
395
 
399
- exp = [["A: a", "B: d"], " b", ["A: c", "B: f"]]
396
+ exp = [["A: a", "B: d"],
397
+ " b",
398
+ ["A: c", "B: f"]]
400
399
 
401
400
  assert_equal exp, flay.collapse_and_label([a, b])
402
401
  end
@@ -404,8 +403,8 @@ class TestSexp < Minitest::Test
404
403
  def test_collapse_and_label_same
405
404
  flay = Flay.new
406
405
 
407
- a = %w(a b c).map { |s| s.group = "A"; s }
408
- b = %w(a b c).map { |s| s.group = "B"; s }
406
+ a = %w(a b c).map(&:dup).map { |s| s.group = "A"; s }
407
+ b = %w(a b c).map(&:dup).map { |s| s.group = "B"; s }
409
408
 
410
409
  exp = [" a", " b", " c"]
411
410
 
@@ -416,9 +415,9 @@ class TestSexp < Minitest::Test
416
415
  dog_and_cat = ["##\n# I am a dog.\n\ndef x\n return \"Hello\"\nend",
417
416
  "##\n# I\n#\n# am\n# a\n# cat.\n\ndef y\n return \"Hello\"\nend"]
418
417
 
419
- flay = Flay.new DEF_OPTS
418
+ flay = Flay.new Flay.default_options
420
419
 
421
- exp = <<-EOM.gsub(/\d+/, "N").gsub(/^ {6}/, "").chomp
420
+ exp = <<~EOM.gsub(/\d+/, "N").gsub(/_NL_/, "").chomp
422
421
  ##
423
422
  A: # I am a dog.
424
423
  B: # I
@@ -426,14 +425,14 @@ class TestSexp < Minitest::Test
426
425
  B: # am
427
426
  B: # a
428
427
  B: # cat.
429
-
428
+ _NL_
430
429
  A: def x
431
430
  B: def y
432
431
  return \"Hello\"
433
432
  end
434
433
  EOM
435
434
 
436
- assert_equal exp, flay.n_way_diff(*dog_and_cat).gsub(/^ {3}$/, "")
435
+ assert_equal exp, flay.n_way_diff(*dog_and_cat)
437
436
  end
438
437
 
439
438
  attr_accessor :flay
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,18 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flay
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.13.3
4
+ version: 2.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain:
11
10
  - |
12
11
  -----BEGIN CERTIFICATE-----
13
- MIIDPjCCAiagAwIBAgIBCDANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
12
+ MIIDPjCCAiagAwIBAgIBCTANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
14
13
  ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
15
- GRYDY29tMB4XDTI0MDEwMjIxMjEyM1oXDTI1MDEwMTIxMjEyM1owRTETMBEGA1UE
14
+ GRYDY29tMB4XDTI1MDEwNjIzMjcwMVoXDTI2MDEwNjIzMjcwMVowRTETMBEGA1UE
16
15
  AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
17
16
  JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
18
17
  b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
@@ -22,14 +21,14 @@ cert_chain:
22
21
  qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
23
22
  gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
24
23
  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
24
+ AQAC0WQJcPOWPFwkojhzweilRVjTJ19UiLhiBTw3C1wJO3LVdBkWDmnnhAmKuX4D
25
+ r7vjQvESlABGIPdutI1Yl7mrHQzTkfLfXvNN6MT0nLChPyIYauT6SZZxubwJrUfA
26
+ 7R0c2CJTIboZ0XaGpLsXqHEF1c29H7TV1QvVuqKAN2mCjh4N82QVn+ZKtys28AwT
27
+ 6GfQX2fqLoi4KSc7xIzHKaNzqxeOICmJofk9w5VZ2rRN6yes8jvFYwz9HR41wdj8
28
+ bwfinv7Yp5fA6AysuZLhCykyfDuZVRrUp0Vb68YCKsLjJly/Theak+euNTxvHsB+
29
+ al9oSgPPHICMEX65qvLywitx
31
30
  -----END CERTIFICATE-----
32
- date: 2024-05-22 00:00:00.000000000 Z
31
+ date: 1980-01-02 00:00:00.000000000 Z
33
32
  dependencies:
34
33
  - !ruby/object:Gem::Dependency
35
34
  name: sexp_processor
@@ -46,19 +45,19 @@ dependencies:
46
45
  - !ruby/object:Gem::Version
47
46
  version: '4.0'
48
47
  - !ruby/object:Gem::Dependency
49
- name: ruby_parser
48
+ name: prism
50
49
  requirement: !ruby/object:Gem::Requirement
51
50
  requirements:
52
51
  - - "~>"
53
52
  - !ruby/object:Gem::Version
54
- version: '3.0'
53
+ version: '1.7'
55
54
  type: :runtime
56
55
  prerelease: false
57
56
  version_requirements: !ruby/object:Gem::Requirement
58
57
  requirements:
59
58
  - - "~>"
60
59
  - !ruby/object:Gem::Version
61
- version: '3.0'
60
+ version: '1.7'
62
61
  - !ruby/object:Gem::Dependency
63
62
  name: erubi
64
63
  requirement: !ruby/object:Gem::Requirement
@@ -79,28 +78,28 @@ dependencies:
79
78
  requirements:
80
79
  - - "~>"
81
80
  - !ruby/object:Gem::Version
82
- version: '1.0'
81
+ version: '2.0'
83
82
  type: :runtime
84
83
  prerelease: false
85
84
  version_requirements: !ruby/object:Gem::Requirement
86
85
  requirements:
87
86
  - - "~>"
88
87
  - !ruby/object:Gem::Version
89
- version: '1.0'
88
+ version: '2.0'
90
89
  - !ruby/object:Gem::Dependency
91
90
  name: minitest
92
91
  requirement: !ruby/object:Gem::Requirement
93
92
  requirements:
94
- - - "~>"
93
+ - - ">"
95
94
  - !ruby/object:Gem::Version
96
- version: 5.8.0
95
+ version: '5.8'
97
96
  type: :development
98
97
  prerelease: false
99
98
  version_requirements: !ruby/object:Gem::Requirement
100
99
  requirements:
101
- - - "~>"
100
+ - - ">"
102
101
  - !ruby/object:Gem::Version
103
- version: 5.8.0
102
+ version: '5.8'
104
103
  - !ruby/object:Gem::Dependency
105
104
  name: ruby2ruby
106
105
  requirement: !ruby/object:Gem::Requirement
@@ -141,14 +140,14 @@ dependencies:
141
140
  requirements:
142
141
  - - "~>"
143
142
  - !ruby/object:Gem::Version
144
- version: '4.2'
143
+ version: '4.3'
145
144
  type: :development
146
145
  prerelease: false
147
146
  version_requirements: !ruby/object:Gem::Requirement
148
147
  requirements:
149
148
  - - "~>"
150
149
  - !ruby/object:Gem::Version
151
- version: '4.2'
150
+ version: '4.3'
152
151
  description: |-
153
152
  Flay analyzes code for structural similarities. Differences in literal
154
153
  values, variable, class, method names, whitespace, programming style,
@@ -179,7 +178,6 @@ licenses:
179
178
  metadata:
180
179
  homepage_uri: http://ruby.sadi.st/
181
180
  source_code_uri: https://github.com/seattlerb/flay
182
- post_install_message:
183
181
  rdoc_options:
184
182
  - "--main"
185
183
  - README.rdoc
@@ -196,8 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
194
  - !ruby/object:Gem::Version
197
195
  version: '0'
198
196
  requirements: []
199
- rubygems_version: 3.5.3
200
- signing_key:
197
+ rubygems_version: 3.7.2
201
198
  specification_version: 4
202
199
  summary: Flay analyzes code for structural similarities
203
200
  test_files: []
metadata.gz.sig CHANGED
Binary file