rufo 0.16.3 → 0.17.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/CHANGELOG.md +21 -0
- data/bin/verify-sample-code +2 -12
- data/docs/settings.md +3 -0
- data/lib/rufo/formatter.rb +19 -70
- data/lib/rufo/settings.rb +1 -1
- data/lib/rufo/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5df151931108df0740d8602c1bf8b931503e3bede6a337f25a9bf75cb549c70
|
4
|
+
data.tar.gz: 73a321c4a0960f8fc021b062149ccbe3f96ccfc231c780e2612de00e011f590b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a2176ae1780bce5ec076052b63576fc54370a4a5b2a7837166e8d42ec4f6f4f47cc1b4590f5742a6b7a263d7cb2b59fc7985a2dd9f1a37fa41939c502515253
|
7
|
+
data.tar.gz: aad26fad18830aad211ba7d16f65643b78648b4f755d0a43ac1b65edbba1d7f97e05535f7c2f499dc3a5a7fa2cfff295e2a5da1aa63af859090873598406ab60
|
data/.github/workflows/ci.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -12,6 +12,27 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
12
12
|
|
13
13
|
### Added
|
14
14
|
|
15
|
+
## [0.17.1] - 2024-02-03
|
16
|
+
|
17
|
+
### Fixed
|
18
|
+
- Fix incorrect indentation methods call with splat ([#320](https://github.com/ruby-formatter/rufo/pull/320))
|
19
|
+
|
20
|
+
### Changed
|
21
|
+
- Remove unused internal methods from `Rufo::Formatter` ([#321](https://github.com/ruby-formatter/rufo/pull/321))
|
22
|
+
- This change may affect behavior with versions of Ruby not currently supported by Rufo (< 2.7)
|
23
|
+
|
24
|
+
### Added
|
25
|
+
|
26
|
+
## [0.17.0] - 2024-01-06
|
27
|
+
|
28
|
+
### Fixed
|
29
|
+
|
30
|
+
### Changed
|
31
|
+
|
32
|
+
### Added
|
33
|
+
- Add Ruby 3.3 to test runs on CI. ([#314](https://github.com/ruby-formatter/rufo/issues/314))
|
34
|
+
- Add `mixed` option for quote_style setting. ([#315](https://github.com/ruby-formatter/rufo/issues/315))
|
35
|
+
|
15
36
|
## [0.16.3] - 2023-11-09
|
16
37
|
|
17
38
|
### Fixed
|
data/bin/verify-sample-code
CHANGED
@@ -1,18 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
repos = {
|
4
|
-
"rspec/rspec-
|
5
|
-
|
6
|
-
"spec/rspec/core/world_spec.rb",
|
7
|
-
"spec/rspec/core/formatters/exception_presenter_spec.rb",
|
8
|
-
"spec/rspec/core/formatters/snippet_extractor_spec.rb",
|
9
|
-
"spec/rspec/core/metadata_spec.rb",
|
10
|
-
"spec/rspec/core/formatters/html_formatter_spec.rb",
|
11
|
-
"spec/rspec/core/formatters_spec.rb",
|
12
|
-
"spec/rspec/core/formatters/documentation_formatter_spec.rb",
|
13
|
-
"spec/rspec/core/formatters/progress_formatter_spec.rb"
|
14
|
-
].join(","),
|
15
|
-
},
|
4
|
+
"rspec/rspec-expectations" => {},
|
5
|
+
"rspec/rspec-mocks" => {},
|
16
6
|
}
|
17
7
|
|
18
8
|
def run_command(cmd, allowed_statuses: [0])
|
data/docs/settings.md
CHANGED
@@ -227,6 +227,7 @@ Use the specified quotation marks.
|
|
227
227
|
|
228
228
|
- `:double`: (default) use doublequotations unless one or more escaped double-quotations are included
|
229
229
|
- `:single`: use single quotations unless one or more interpolations `#{}` or escaped single quotations are included
|
230
|
+
- `:mixed`: use mixed quotations if you don't want to change quotes
|
230
231
|
|
231
232
|
This does not affect `%q()` (single), `%Q()` (double), or quotation marks within heredocs.
|
232
233
|
|
@@ -278,6 +279,8 @@ code = <<CODE
|
|
278
279
|
CODE
|
279
280
|
```
|
280
281
|
|
282
|
+
With `:mixed`, the formatter will keep lines as is
|
283
|
+
|
281
284
|
### Includes and excludes
|
282
285
|
Files can be excluded or included in formatting with rufo by specifying glob patterns for the `includes` or `excludes` configuration options. Multiple patterns are separated by a comma.
|
283
286
|
|
data/lib/rufo/formatter.rb
CHANGED
@@ -396,8 +396,6 @@ class Rufo::Formatter
|
|
396
396
|
visit_module(node)
|
397
397
|
when :mrhs_new_from_args
|
398
398
|
visit_mrhs_new_from_args(node)
|
399
|
-
when :mlhs_paren
|
400
|
-
visit_mlhs_paren(node)
|
401
399
|
when :mlhs
|
402
400
|
visit_mlhs(node)
|
403
401
|
when :mrhs_add_star
|
@@ -457,8 +455,6 @@ class Rufo::Formatter
|
|
457
455
|
visit_alias(node)
|
458
456
|
when :undef
|
459
457
|
visit_undef(node)
|
460
|
-
when :mlhs_add_star
|
461
|
-
visit_mlhs_add_star(node)
|
462
458
|
when :rest_param
|
463
459
|
visit_rest_param(node)
|
464
460
|
when :kwrest_param
|
@@ -636,6 +632,7 @@ class Rufo::Formatter
|
|
636
632
|
|
637
633
|
# should we format this string according to :quote_style?
|
638
634
|
def should_format_string?(string)
|
635
|
+
return if quote_style == :mixed
|
639
636
|
# don't format %q or %Q
|
640
637
|
return unless current_token_value == "'" || current_token_value == '"'
|
641
638
|
# don't format strings containing slashes
|
@@ -905,26 +902,6 @@ class Rufo::Formatter
|
|
905
902
|
end
|
906
903
|
end
|
907
904
|
|
908
|
-
def indentable_value?(value)
|
909
|
-
return unless current_token_kind == :on_kw
|
910
|
-
|
911
|
-
case current_token_value
|
912
|
-
when "if", "unless", "case"
|
913
|
-
true
|
914
|
-
when "begin"
|
915
|
-
# Only indent if it's begin/rescue
|
916
|
-
return false unless value[0] == :begin
|
917
|
-
|
918
|
-
body = value[1]
|
919
|
-
return false unless body[0] == :bodystmt
|
920
|
-
|
921
|
-
_, _, rescue_body, else_body, ensure_body = body
|
922
|
-
rescue_body || else_body || ensure_body
|
923
|
-
else
|
924
|
-
false
|
925
|
-
end
|
926
|
-
end
|
927
|
-
|
928
905
|
def current_comment_aligned_to_previous_one?
|
929
906
|
@last_comment &&
|
930
907
|
@last_comment[0][0] + 1 == current_token_line &&
|
@@ -1540,7 +1517,8 @@ class Rufo::Formatter
|
|
1540
1517
|
|
1541
1518
|
skip_space
|
1542
1519
|
|
1543
|
-
write_params_comma
|
1520
|
+
# Disable indentation in write_params_comma to avoid double indentation with write_indent
|
1521
|
+
write_params_comma(with_indent: !needs_indent) if comma?
|
1544
1522
|
write_indent(base_column) if needs_indent
|
1545
1523
|
consume_op "*"
|
1546
1524
|
skip_space_or_newline
|
@@ -1550,7 +1528,8 @@ class Rufo::Formatter
|
|
1550
1528
|
end
|
1551
1529
|
|
1552
1530
|
if post_args && !post_args.empty?
|
1553
|
-
write_params_comma
|
1531
|
+
# Disable indentation in write_params_comma to avoid double indentation with visit_comma_separated_list
|
1532
|
+
write_params_comma(with_indent: !needs_indent)
|
1554
1533
|
visit_comma_separated_list post_args, needs_indent: needs_indent, base_column: base_column
|
1555
1534
|
end
|
1556
1535
|
end
|
@@ -1658,23 +1637,10 @@ class Rufo::Formatter
|
|
1658
1637
|
end
|
1659
1638
|
end
|
1660
1639
|
|
1661
|
-
def visit_mlhs_paren(node)
|
1662
|
-
# [:mlhs_paren,
|
1663
|
-
# [[:mlhs_paren, [:@ident, "x", [1, 12]]]]
|
1664
|
-
# ]
|
1665
|
-
_, args = node
|
1666
|
-
|
1667
|
-
visit_mlhs_or_mlhs_paren(args)
|
1668
|
-
end
|
1669
|
-
|
1670
1640
|
def visit_mlhs(node)
|
1671
1641
|
# [:mlsh, *args]
|
1672
1642
|
_, *args = node
|
1673
1643
|
|
1674
|
-
visit_mlhs_or_mlhs_paren(args)
|
1675
|
-
end
|
1676
|
-
|
1677
|
-
def visit_mlhs_or_mlhs_paren(args)
|
1678
1644
|
# Sometimes a paren comes, some times not, so act accordingly.
|
1679
1645
|
has_paren = current_token_kind == :on_lparen
|
1680
1646
|
if has_paren
|
@@ -1818,35 +1784,6 @@ class Rufo::Formatter
|
|
1818
1784
|
end
|
1819
1785
|
end
|
1820
1786
|
|
1821
|
-
def visit_mlhs_add_star(node)
|
1822
|
-
# [:mlhs_add_star, before, star, after]
|
1823
|
-
_, before, star, after = node
|
1824
|
-
|
1825
|
-
if before && !before.empty?
|
1826
|
-
# Maybe a Ripper bug, but if there's something before a star
|
1827
|
-
# then a star shouldn't be here... but if it is... handle it
|
1828
|
-
# somehow...
|
1829
|
-
if op?("*")
|
1830
|
-
star = before
|
1831
|
-
else
|
1832
|
-
visit_comma_separated_list to_ary(before)
|
1833
|
-
write_params_comma
|
1834
|
-
end
|
1835
|
-
end
|
1836
|
-
|
1837
|
-
consume_op "*"
|
1838
|
-
|
1839
|
-
if star
|
1840
|
-
skip_space_or_newline
|
1841
|
-
visit star
|
1842
|
-
end
|
1843
|
-
|
1844
|
-
if after && !after.empty?
|
1845
|
-
write_params_comma
|
1846
|
-
visit_comma_separated_list after
|
1847
|
-
end
|
1848
|
-
end
|
1849
|
-
|
1850
1787
|
def visit_rest_param(node)
|
1851
1788
|
# [:rest_param, name]
|
1852
1789
|
|
@@ -2249,12 +2186,14 @@ class Rufo::Formatter
|
|
2249
2186
|
end
|
2250
2187
|
end
|
2251
2188
|
|
2252
|
-
def write_params_comma
|
2189
|
+
def write_params_comma(with_indent: true)
|
2253
2190
|
skip_space
|
2254
2191
|
check :on_comma
|
2255
2192
|
write ","
|
2256
2193
|
next_token
|
2257
|
-
|
2194
|
+
|
2195
|
+
indent_size = with_indent ? @indent : 0
|
2196
|
+
skip_space_or_newline_using_setting(:one, indent_size)
|
2258
2197
|
end
|
2259
2198
|
|
2260
2199
|
def visit_array(node)
|
@@ -2315,6 +2254,12 @@ class Rufo::Formatter
|
|
2315
2254
|
write_indent next_indent
|
2316
2255
|
end
|
2317
2256
|
next_token
|
2257
|
+
|
2258
|
+
# fix for 3.3 ripper change. two :on_words_sep are generated for "#\n "
|
2259
|
+
while current_token_kind == :on_words_sep
|
2260
|
+
next_token
|
2261
|
+
end
|
2262
|
+
|
2318
2263
|
has_space = true if current_token_value.start_with?(" ")
|
2319
2264
|
end
|
2320
2265
|
|
@@ -2337,6 +2282,10 @@ class Rufo::Formatter
|
|
2337
2282
|
next_token
|
2338
2283
|
write_line
|
2339
2284
|
write_indent(column)
|
2285
|
+
# two :on_words_sep are generated for "#\n " on ruby 3.3
|
2286
|
+
while current_token_kind == :on_words_sep
|
2287
|
+
next_token
|
2288
|
+
end
|
2340
2289
|
else
|
2341
2290
|
next_token
|
2342
2291
|
write_space
|
data/lib/rufo/settings.rb
CHANGED
data/lib/rufo/version.rb
CHANGED
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.
|
4
|
+
version: 0.17.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ary Borenszweig
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -210,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
210
|
- !ruby/object:Gem::Version
|
211
211
|
version: '0'
|
212
212
|
requirements: []
|
213
|
-
rubygems_version: 3.
|
213
|
+
rubygems_version: 3.5.3
|
214
214
|
signing_key:
|
215
215
|
specification_version: 4
|
216
216
|
summary: Ruby code formatter
|