flay 2.14.2 → 2.14.3

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: '0796aba130c20f61f7558524c865ae0abc87502218ee9e6bbdb348b9b9f1b80e'
4
+ data.tar.gz: a3a06b20c0ccd6358c4937cd0cfa267fcd435870f804afc799fe24f70a2bd664
5
5
  SHA512:
6
- metadata.gz: 742fa42cabacbe0cf3d65a5c7083c60b019a014f0f1e9509edd00507809335bf7315f9e254eccda05f347f32c39c034963cddea8bdd3ad8735648380d3ded6b9
7
- data.tar.gz: 804293d0ccedb1900e65bd4bcec84246e9d3caf01fd87a411c36e2116affc915b1d0b694d88aaa9d527357e09332e2ae5c1a37def8d47852f925acaf725ea63e
6
+ metadata.gz: 62f49813a8d3f8a08a6727330b229f333389ad9394c75a4777d7818a1b7c689d392617c6bd011ceca46eaca8d3009ed88ce0fc9ae3556d2d65f86d9307cb8f32
7
+ data.tar.gz: d6c5ebdd419d2623989b907cbc3fb89dd07404d702d7860ebebfa0db2d92ecab1e1d10a98ec57536d3b35b8e81f3ee5e5a72c9a50019fabe4df3dac3f21479f2
checksums.yaml.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,10 @@
1
+ === 2.4.3 / 2026-03-23
2
+
3
+ * 2 bug fixes:
4
+
5
+ * Fix Sexp#[] to return a Sexp to ensure process_fuzzy can sort sub-sexps.
6
+ * Make Sexp#[] return a single element if integer is used.
7
+
1
8
  === 2.14.2 / 2026-01-06
2
9
 
3
10
  * 1 bug fix:
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.3" # :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,76 @@ class TestSexp < Minitest::Test
229
229
  assert_equal exp.gsub(/\d+/, "N"), out.gsub(/\d+/, "N")
230
230
  end
231
231
 
232
+ def test__fuzzy__idx
233
+ sexp = NotRubyParser.new.parse "def x(n); n + 1; end"
234
+
235
+ assert_equal :defn, sexp[0]
236
+ assert_equal s(:defn), sexp[0..0]
237
+ assert_equal s(:defn, :x), sexp[0..1]
238
+ end
239
+
240
+ def test__fuzzy__split_at
241
+ # def x(n); n + 1; end
242
+ sexp = s(:defn, :x, s(:args, :n), s(:call, s(:lvar, :n), :+, s(:lit, 1)))
243
+ sexp = NotRubyParser.new.parse "def x(n); n + 1; end"
244
+
245
+ a, b = sexp.split_at 2
246
+
247
+ assert_equal s(:defn, :x, s(:args, :n)), a
248
+ assert_equal s(s(:call, s(:lvar, :n), :+, s(:lit, 1))), b
249
+ end
250
+
251
+ def test__fuzzy__split_code
252
+ # def x(n); n + 1; end
253
+ sexp = s(:defn, :x, s(:args, :n), s(:call, s(:lvar, :n), :+, s(:lit, 1)))
254
+ sexp = NotRubyParser.new.parse "def x(n); n + 1; end"
255
+
256
+ a, b = sexp.split_code
257
+
258
+ assert_equal s(:defn, :x, s(:args, :n)), a
259
+ assert_equal s(s(:call, s(:lvar, :n), :+, s(:lit, 1))), b
260
+ end
261
+
262
+ FUZZY_CODE = NotRubyParser.new.process <<-RUBY
263
+ def a
264
+ f1; f2; f3; f4; f5; f6
265
+ end
266
+
267
+ def b
268
+ f2; f3; f4; f5; f6
269
+ end
270
+
271
+ def c
272
+ f2; f3; f4; f5; f6; f7
273
+ end
274
+ RUBY
275
+
276
+ def test_report__fuzzy
277
+ flay = Flay.new OPTS.merge(fuzzy: 1, mass: 5)
278
+
279
+ flay.process_sexp FUZZY_CODE.deep_clone
280
+
281
+ out, err = capture_io do
282
+ flay.report
283
+ end
284
+
285
+ exp = <<~END
286
+ Total score (lower is better) = 37
287
+
288
+ 1) Similar code found in :defn (mass = 21)
289
+ (string):1 (FUZZY)
290
+ (string):5
291
+ (string):9 (FUZZY)
292
+
293
+ 2) Similar code found in :defn (mass = 16)
294
+ (string):1
295
+ (string):9
296
+ END
297
+
298
+ assert_equal "", err
299
+ assert_equal exp.gsub(/\d+/, "N"), out.gsub(/\d+/, "N")
300
+ end
301
+
232
302
  def test_report_io
233
303
  out = StringIO.new
234
304
  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.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -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