rufo 0.14.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '050197c783154878217024914afe1fc208e624521b5c3c1c4cd182c29ce70795'
4
- data.tar.gz: 8ec88b8b3bc5fa60afbfa7eb7bcf395a2dd906c2b51e2c256d9f11876540279f
3
+ metadata.gz: 1862ef1cb223254a0b735f6af30b3364045bd1c8673ad2c34ccd381571174377
4
+ data.tar.gz: 38d6908494f4a93cc527e914281e44c329dbec4b82a3ca4873acbf188856a559
5
5
  SHA512:
6
- metadata.gz: 7cce9d7529456084473d761247402c659950460bb75155d3689d8c89bc89993793d9638fc0bc47d45a40d97eaf2d06d13c175f1db0aeef1356ad12a8124f5bfe
7
- data.tar.gz: f4e46d300e1a94fc05c1d2aaa99ea6f24fa244faba984e8841f9874e5326ef324cc38b915008948156ec5825c572024dc0e57a0600f6b235fe06f7b7f3695e60
6
+ metadata.gz: c8d78360444224de4502c9f727171e7df9e4ff3344e48b28475d0cf9d92f53d6807755542db05c99d3eaa54cde3f6c2cbe5b67c7b1583d3d5e4346b4c93c7afa
7
+ data.tar.gz: f62ce1f77275410744f235c74a2293d838a5dfe6110768f6434735cc935e7520d6bc0511496e9d5c5912a945a783ac989c990a8bc8b7f61bfffb05c7055f7008
data/.rubocop.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  AllCops:
2
+ NewCops: enable
2
3
  Exclude:
3
4
  - "spec/**/*"
4
5
  - "vendor/**/*"
data/CHANGELOG.md CHANGED
@@ -12,6 +12,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
12
12
 
13
13
  ### Added
14
14
 
15
+ ## [0.15.0] - 2023-02-08
16
+
17
+ ### Fixed
18
+
19
+ ### Changed
20
+
21
+ ### Added
22
+
23
+ - Support for anonymous block argument forwarding
24
+ - Support for valueless hash literals and keyword arguments
25
+ - Support for anonymous rest and rest keyword arguments forwarding
26
+
15
27
  ## [0.14.0] - 2023-01-25
16
28
 
17
29
  ### Fixed
@@ -227,12 +227,11 @@ class Rufo::Formatter
227
227
  when :@CHAR
228
228
  # [:@CHAR, "?a", [1, 0]]
229
229
  consume_token :on_CHAR
230
- when :@gvar
230
+ when :@gvar, :@backref, :@label, :@op
231
231
  # [:@gvar, "$abc", [1, 0]]
232
- write node[1]
233
- next_token
234
- when :@backref
235
232
  # [:@backref, "$1", [1, 0]]
233
+ # [:@label, "foo:", [1, 3]]
234
+ # [:@op, "*", [1, 1]]
236
235
  write node[1]
237
236
  next_token
238
237
  when :@backtick
@@ -289,11 +288,12 @@ class Rufo::Formatter
289
288
  visit_quoted_symbol_literal(node)
290
289
  when :@ident
291
290
  consume_token :on_ident
292
- when :var_ref
291
+ when :var_ref, :var_field, :const_ref, :vcall, :fcall
293
292
  # [:var_ref, exp]
294
- visit node[1]
295
- when :var_field
296
293
  # [:var_field, exp]
294
+ # [:const_ref, [:@const, "Foo", [1, 8]]]
295
+ # [:vcall, exp]
296
+ # [:fcall, [:@ident, "foo", [1, 0]]]
297
297
  visit node[1]
298
298
  when :@kw
299
299
  # [:@kw, "nil", [1, 0]]
@@ -307,9 +307,6 @@ class Rufo::Formatter
307
307
  when :@const
308
308
  # [:@const, "FOO", [1, 0]]
309
309
  consume_token :on_const
310
- when :const_ref
311
- # [:const_ref, [:@const, "Foo", [1, 8]]]
312
- visit node[1]
313
310
  when :top_const_ref
314
311
  # [:top_const_ref, [:@const, "Foo", [1, 2]]]
315
312
  consume_op "::"
@@ -319,9 +316,7 @@ class Rufo::Formatter
319
316
  # [:top_const_field, [:@const, "Foo", [1, 2]]]
320
317
  consume_op "::"
321
318
  visit node[1]
322
- when :const_path_ref
323
- visit_path(node)
324
- when :const_path_field
319
+ when :const_path_ref, :const_path_field
325
320
  visit_path(node)
326
321
  when :assign
327
322
  visit_assign(node)
@@ -341,12 +336,6 @@ class Rufo::Formatter
341
336
  visit_suffix(node, "until")
342
337
  when :rescue_mod
343
338
  visit_suffix(node, "rescue")
344
- when :vcall
345
- # [:vcall, exp]
346
- visit node[1]
347
- when :fcall
348
- # [:fcall, [:@ident, "foo", [1, 0]]]
349
- visit node[1]
350
339
  when :command
351
340
  visit_command(node)
352
341
  when :command_call
@@ -422,10 +411,6 @@ class Rufo::Formatter
422
411
  visit_hash_key_value(node)
423
412
  when :assoc_splat
424
413
  visit_splat_inside_hash(node)
425
- when :@label
426
- # [:@label, "foo:", [1, 3]]
427
- write node[1]
428
- next_token
429
414
  when :dot2
430
415
  visit_range(node, true)
431
416
  when :dot3
@@ -452,10 +437,6 @@ class Rufo::Formatter
452
437
  consume_keyword "yield"
453
438
  when :yield
454
439
  visit_yield(node)
455
- when :@op
456
- # [:@op, "*", [1, 1]]
457
- write node[1]
458
- next_token
459
440
  when :lambda
460
441
  visit_lambda(node)
461
442
  when :zsuper
@@ -1516,6 +1497,9 @@ class Rufo::Formatter
1516
1497
  consume_op "&"
1517
1498
  skip_space_or_newline
1518
1499
  visit block_arg
1500
+ elsif current_token_kind == :on_op && current_token_value == "&"
1501
+ consume_op "&"
1502
+ skip_space_or_newline
1519
1503
  end
1520
1504
  end
1521
1505
 
@@ -1544,7 +1528,10 @@ class Rufo::Formatter
1544
1528
  write_indent(base_column) if needs_indent
1545
1529
  consume_op "*"
1546
1530
  skip_space_or_newline
1547
- visit star
1531
+ # The name of rest arguments might be omitted.
1532
+ if star
1533
+ visit star
1534
+ end
1548
1535
 
1549
1536
  if post_args && !post_args.empty?
1550
1537
  write_params_comma
@@ -2226,7 +2213,10 @@ class Rufo::Formatter
2226
2213
  skip_space_or_newline
2227
2214
  consume_op "&"
2228
2215
  skip_space_or_newline
2229
- visit blockarg[1]
2216
+ # Ruby 3.1 or above, block arg might be anonymous
2217
+ if blockarg[1]
2218
+ visit blockarg[1]
2219
+ end
2230
2220
  end
2231
2221
  end
2232
2222
 
@@ -2403,16 +2393,21 @@ class Rufo::Formatter
2403
2393
  arrow = symbol || !(key[0] == :@label || key[0] == :dyna_symbol)
2404
2394
 
2405
2395
  visit key
2406
- consume_space
2407
2396
 
2408
2397
  # Don't output `=>` for keys that are `label: value`
2409
2398
  # or `"label": value`
2410
2399
  if arrow
2411
- consume_op "=>"
2412
2400
  consume_space
2401
+ consume_op "=>"
2413
2402
  end
2414
2403
 
2415
- visit value
2404
+ if value.nil?
2405
+ # The value for the key is omitted.
2406
+ skip_space
2407
+ else
2408
+ consume_space
2409
+ visit value
2410
+ end
2416
2411
  end
2417
2412
 
2418
2413
  def visit_splat_inside_hash(node)
@@ -2421,7 +2416,11 @@ class Rufo::Formatter
2421
2416
  # [:assoc_splat, exp]
2422
2417
  consume_op "**"
2423
2418
  skip_space_or_newline
2424
- visit node[1]
2419
+ exp = node[1]
2420
+ # The name of rest kwargs might be omitted.
2421
+ if exp
2422
+ visit exp
2423
+ end
2425
2424
  end
2426
2425
 
2427
2426
  def visit_range(node, inclusive)
@@ -3554,7 +3553,7 @@ class Rufo::Formatter
3554
3553
  end
3555
3554
 
3556
3555
  def write_indent(indent = @indent)
3557
- @output << " " * indent
3556
+ @output << (" " * indent)
3558
3557
  @column += indent
3559
3558
  end
3560
3559
 
@@ -3899,7 +3898,7 @@ class Rufo::Formatter
3899
3898
  # get line of node, it is only used in visit_hash right now,
3900
3899
  # so handling the following node types is enough.
3901
3900
  case node.first
3902
- when :hash, :string_literal, :symbol_literal, :symbol, :vcall, :string_content, :assoc_splat, :var_ref
3901
+ when :hash, :string_literal, :symbol_literal, :symbol, :vcall, :string_content, :assoc_splat, :var_ref, :dyna_symbol
3903
3902
  node_line(node[1], beginning: beginning)
3904
3903
  when :assoc_new
3905
3904
  # There's no line number info for empty strings or hashes.
@@ -3912,8 +3911,6 @@ class Rufo::Formatter
3912
3911
  end
3913
3912
  when :assoclist_from_args
3914
3913
  node_line(beginning ? node[1][0] : node[1].last, beginning: beginning)
3915
- when :dyna_symbol
3916
- node_line(node[1], beginning: beginning)
3917
3914
  when :@label, :@int, :@ident, :@tstring_content, :@kw
3918
3915
  node[2][0]
3919
3916
  end
data/lib/rufo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rufo
4
- VERSION = "0.14.0"
4
+ VERSION = "0.15.0"
5
5
  end
data/rufo.gemspec CHANGED
@@ -21,15 +21,16 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
  spec.required_ruby_version = ">= 2.7.0"
24
+ spec.metadata["rubygems_mfa_required"] = "true"
24
25
 
25
26
  spec.add_development_dependency "bundler", ">= 1.15"
26
- spec.add_development_dependency "byebug", "~> 11.0.1"
27
+ spec.add_development_dependency "byebug", "~> 11.1.3"
27
28
  spec.add_development_dependency "guard-rspec", "~> 4.0"
28
29
  spec.add_development_dependency "rake", "~> 13.0"
29
30
  spec.add_development_dependency "rexml", "~> 3.2.5"
30
31
  spec.add_development_dependency "rspec", "~> 3.0"
31
- spec.add_development_dependency "rspec_junit_formatter", "~> 0.4.1"
32
- spec.add_development_dependency "rubocop", "~> 0.79.0"
33
- spec.add_development_dependency "simplecov", "~> 0.18.5"
34
- spec.add_development_dependency "simplecov-cobertura", "~> 1.3.1"
32
+ spec.add_development_dependency "rspec_junit_formatter", "~> 0.6.0"
33
+ spec.add_development_dependency "rubocop", "~> 1.44.1"
34
+ spec.add_development_dependency "simplecov", "~> 0.22.0"
35
+ spec.add_development_dependency "simplecov-cobertura", "~> 2.1"
35
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rufo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ary Borenszweig
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-25 00:00:00.000000000 Z
11
+ date: 2023-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 11.0.1
33
+ version: 11.1.3
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 11.0.1
40
+ version: 11.1.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: guard-rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -100,56 +100,56 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.4.1
103
+ version: 0.6.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.4.1
110
+ version: 0.6.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rubocop
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.79.0
117
+ version: 1.44.1
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.79.0
124
+ version: 1.44.1
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: simplecov
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 0.18.5
131
+ version: 0.22.0
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 0.18.5
138
+ version: 0.22.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: simplecov-cobertura
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.3.1
145
+ version: '2.1'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 1.3.1
152
+ version: '2.1'
153
153
  description: Fast and unobtrusive Ruby code formatter
154
154
  email:
155
155
  - asterite@gmail.com
@@ -193,7 +193,8 @@ files:
193
193
  homepage: https://github.com/ruby-formatter/rufo
194
194
  licenses:
195
195
  - MIT
196
- metadata: {}
196
+ metadata:
197
+ rubygems_mfa_required: 'true'
197
198
  post_install_message:
198
199
  rdoc_options: []
199
200
  require_paths:
@@ -209,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
210
  - !ruby/object:Gem::Version
210
211
  version: '0'
211
212
  requirements: []
212
- rubygems_version: 3.3.7
213
+ rubygems_version: 3.4.1
213
214
  signing_key:
214
215
  specification_version: 4
215
216
  summary: Ruby code formatter