flay 2.14.2 → 2.14.4

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: bc9ce0202d55742699dc59bcc8793683a7efc68a7f9f395c5f740b97836c0c85
4
- data.tar.gz: f389db1f4bae7f7f2535986317a566d355108ffc5e0652cba87b0a6c2f7566c4
3
+ metadata.gz: be4e30464c63609fc7e169633d341a4479794effbeab1cddae17ec61b7aa99c1
4
+ data.tar.gz: a5d0d7e99cba3df3c022c8524d215509f2fc7ccbec9c547332ef4a67d7473aaf
5
5
  SHA512:
6
- metadata.gz: 742fa42cabacbe0cf3d65a5c7083c60b019a014f0f1e9509edd00507809335bf7315f9e254eccda05f347f32c39c034963cddea8bdd3ad8735648380d3ded6b9
7
- data.tar.gz: 804293d0ccedb1900e65bd4bcec84246e9d3caf01fd87a411c36e2116affc915b1d0b694d88aaa9d527357e09332e2ae5c1a37def8d47852f925acaf725ea63e
6
+ metadata.gz: 2686fd16226e533a3c6689025c14839ac7f446c12d572ab74799ad5db0a1c57fdf6d7674eb496e71ed3fbfcad3cc61b656db5bf7dde46fbfbb695babfcdbece5
7
+ data.tar.gz: 535c3aa7a9db9a4b98d1610e9c26dfea88a2afdc0782c030558e935f13f12442ec886df01c29afe723d70f44840a416b99f059947ee9e43a1a7f534e96c26293
checksums.yaml.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,17 @@
1
+ === 2.14.4 / 2026-04-14
2
+
3
+ * 2 bug fixes:
4
+
5
+ * Fix Sexp#[] to return empty sexp if indicies run off the end. (slbug)
6
+ * Loosened dependency on ruby2ruby to catch up and drop ruby_parser.
7
+
8
+ === 2.14.3 / 2026-03-23
9
+
10
+ * 2 bug fixes:
11
+
12
+ * Fix Sexp#[] to return a Sexp to ensure process_fuzzy can sort sub-sexps.
13
+ * Make Sexp#[] return a single element if integer is used.
14
+
1
15
  === 2.14.2 / 2026-01-06
2
16
 
3
17
  * 1 bug fix:
data/Rakefile CHANGED
@@ -24,7 +24,7 @@ Hoe.spec "flay" do
24
24
  dependency "path_expander", "~> 2.0"
25
25
 
26
26
  dependency "minitest", "> 5.8", :dev
27
- dependency "ruby2ruby", "~> 2.2.0", :dev
27
+ dependency "ruby2ruby", "~> 2.2", :dev
28
28
 
29
29
  self.flay_threshold = 250
30
30
  end
data/lib/flay.rb CHANGED
@@ -9,7 +9,7 @@ require "prism"
9
9
  require "prism/translation/ruby_parser"
10
10
 
11
11
  class Flay
12
- VERSION = "2.14.2" # :nodoc:
12
+ VERSION = "2.14.4" # :nodoc:
13
13
 
14
14
  NotRubyParser = Class.new Prism::Translation::RubyParser # compatibility layer :nodoc:
15
15
 
@@ -584,14 +584,8 @@ class Sexp
584
584
  alias :[] :[] # needed for STRICT_SEXP
585
585
 
586
586
  def [] a # :nodoc:
587
- # TODO: figure out a way to make this STRICT_SEXP happy
588
- s = super
589
- if Sexp === s then
590
- s.file = self.file
591
- s.line = self.line
592
- s.modified = self.modified
593
- end
594
- s
587
+ return super if Integer === a
588
+ self.new._concat super || []
595
589
  end
596
590
 
597
591
  def + o # :nodoc:
data/test/test_flay.rb CHANGED
@@ -229,6 +229,93 @@ class TestSexp < Minitest::Test
229
229
  assert_equal exp.gsub(/\d+/, "N"), out.gsub(/\d+/, "N")
230
230
  end
231
231
 
232
+ def test_sexp_idx
233
+ # sexp = NotRubyParser.new.parse "def x(n); n + 1; end"
234
+ sexp = s(:defn, :x, s(:args, :n),
235
+ s(:call, s(:lvar, :n), :+, s(:lit, 1)))
236
+
237
+ assert_equal :defn, sexp[0]
238
+ assert_equal s(:defn), sexp[0..0]
239
+ assert_equal s(:defn, :x), sexp[0..1]
240
+ end
241
+
242
+ def test_sexp_idx__off
243
+ # sexp = NotRubyParser.new.parse "->(something) { something.to_s }"
244
+ sexp = s(:iter,
245
+ s(:lambda),
246
+ s(:args, :something),
247
+ s(:call, s(:lvar, :something), :to_s))
248
+
249
+ # def arguments_element
250
+ # call_element.sexp_body(3) || []
251
+ call_element = sexp[1] # s(:lambda) = this is just wrong
252
+
253
+ assert_equal s(), call_element[3..-1]
254
+ assert_equal s(), call_element.sexp_body(3)
255
+ end
256
+
257
+ def test__fuzzy__split_at
258
+ # def x(n); n + 1; end
259
+ sexp = s(:defn, :x, s(:args, :n), s(:call, s(:lvar, :n), :+, s(:lit, 1)))
260
+ # sexp = NotRubyParser.new.parse "def x(n); n + 1; end"
261
+
262
+ a, b = sexp.split_at 2
263
+
264
+ assert_equal s(:defn, :x, s(:args, :n)), a
265
+ assert_equal s(s(:call, s(:lvar, :n), :+, s(:lit, 1))), b
266
+ end
267
+
268
+ def test__fuzzy__split_code
269
+ # def x(n); n + 1; end
270
+ sexp = s(:defn, :x, s(:args, :n), s(:call, s(:lvar, :n), :+, s(:lit, 1)))
271
+ # sexp = NotRubyParser.new.parse "def x(n); n + 1; end"
272
+
273
+ a, b = sexp.split_code
274
+
275
+ assert_equal s(:defn, :x, s(:args, :n)), a
276
+ assert_equal s(s(:call, s(:lvar, :n), :+, s(:lit, 1))), b
277
+ end
278
+
279
+ FUZZY_CODE = NotRubyParser.new.process <<-RUBY
280
+ def a
281
+ f1; f2; f3; f4; f5; f6
282
+ end
283
+
284
+ def b
285
+ f2; f3; f4; f5; f6
286
+ end
287
+
288
+ def c
289
+ f2; f3; f4; f5; f6; f7
290
+ end
291
+ RUBY
292
+
293
+ def test_report__fuzzy
294
+ flay = Flay.new OPTS.merge(fuzzy: 1, mass: 5)
295
+
296
+ flay.process_sexp FUZZY_CODE.deep_clone
297
+
298
+ out, err = capture_io do
299
+ flay.report
300
+ end
301
+
302
+ exp = <<~END
303
+ Total score (lower is better) = 37
304
+
305
+ 1) Similar code found in :defn (mass = 21)
306
+ (string):1 (FUZZY)
307
+ (string):5
308
+ (string):9 (FUZZY)
309
+
310
+ 2) Similar code found in :defn (mass = 16)
311
+ (string):1
312
+ (string):9
313
+ END
314
+
315
+ assert_equal "", err
316
+ assert_equal exp.gsub(/\d+/, "N"), out.gsub(/\d+/, "N")
317
+ end
318
+
232
319
  def test_report_io
233
320
  out = StringIO.new
234
321
  flay = Flay.new OPTS
data.tar.gz.sig CHANGED
Binary file
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.14.2
4
+ version: 2.14.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -106,14 +106,14 @@ dependencies:
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: 2.2.0
109
+ version: '2.2'
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
- version: 2.2.0
116
+ version: '2.2'
117
117
  - !ruby/object:Gem::Dependency
118
118
  name: rdoc
119
119
  requirement: !ruby/object:Gem::Requirement
@@ -140,18 +140,40 @@ dependencies:
140
140
  requirements:
141
141
  - - "~>"
142
142
  - !ruby/object:Gem::Version
143
- version: '4.5'
143
+ version: '4.6'
144
144
  type: :development
145
145
  prerelease: false
146
146
  version_requirements: !ruby/object:Gem::Requirement
147
147
  requirements:
148
148
  - - "~>"
149
149
  - !ruby/object:Gem::Version
150
- version: '4.5'
150
+ version: '4.6'
151
151
  description: |-
152
152
  Flay analyzes code for structural similarities. Differences in literal
153
153
  values, variable, class, method names, whitespace, programming style,
154
154
  braces vs do/end, etc are all ignored. Making this totally rad.
155
+
156
+ == Features/Problems:
157
+
158
+ * Reports differences at any level of code.
159
+ * Adds a score multiplier to identical nodes.
160
+ * Differences in literal values, variable, class, and method names are ignored.
161
+ * Differences in whitespace, programming style, braces vs do/end, etc are ignored.
162
+ * Works across files.
163
+ * Add the flay-persistent plugin to work across large/many projects.
164
+ * Run --diff to see an N-way diff of the code.
165
+ * Provides conservative (default) and --liberal pruning options.
166
+ * Provides --fuzzy duplication detection.
167
+ * Language independent: Plugin system allows other languages to be flayed.
168
+ * Ships with .rb and .erb.
169
+ * javascript and others will be available separately.
170
+ * Includes FlayTask for Rakefiles.
171
+ * Uses path_expander, so you can use:
172
+ * dir_arg -- expand a directory automatically
173
+ * @file_of_args -- persist arguments in a file
174
+ * -path_to_subtract -- ignore intersecting subsets of files/directories
175
+ * Skips files matched via patterns in .flayignore (subset format of .gitignore).
176
+ * Totally rad.
155
177
  email:
156
178
  - ryand-ruby@zenspider.com
157
179
  executables:
@@ -178,6 +200,7 @@ licenses:
178
200
  metadata:
179
201
  homepage_uri: http://ruby.sadi.st/
180
202
  source_code_uri: https://github.com/seattlerb/flay
203
+ documentation_uri: http://docs.seattlerb.org/flay/
181
204
  rdoc_options:
182
205
  - "--main"
183
206
  - README.rdoc
metadata.gz.sig CHANGED
Binary file