diff --git a/lib/rufo/formatter.rb b/lib/rufo/formatter.rb index 35305203..d37d2d5b 100644 --- a/lib/rufo/formatter.rb +++ b/lib/rufo/formatter.rb @@ -2147,10 +2147,11 @@ def visit_params(node) # [:@label, "b:", [1, 20]] write label[1] next_token - skip_space_or_newline if value consume_space visit value + else + skip_space end end needs_comma = true diff --git a/spec/lib/rufo/formatter_source_specs/3.1/method_definition_with_receiver.rb.spec b/spec/lib/rufo/formatter_source_specs/3.1/method_definition_with_receiver.rb.spec new file mode 100644 index 00000000..8e60ac04 --- /dev/null +++ b/spec/lib/rufo/formatter_source_specs/3.1/method_definition_with_receiver.rb.spec @@ -0,0 +1,14 @@ +#~# ORIGINAL issue_331 +#~# parens_in_def: :dynamic +class User + def self.by_uid uid: + joins(:authentications).where(authentications: { uid: }).first + end +end + +#~# EXPECTED +class User + def self.by_uid uid: + joins(:authentications).where(authentications: { uid: }).first + end +end diff --git a/spec/lib/rufo/formatter_source_specs/method_definition.rb.spec b/spec/lib/rufo/formatter_source_specs/method_definition.rb.spec index c0d995be..bdf487f8 100644 --- a/spec/lib/rufo/formatter_source_specs/method_definition.rb.spec +++ b/spec/lib/rufo/formatter_source_specs/method_definition.rb.spec @@ -371,3 +371,13 @@ end def foo(a, ...) p(...) end + +#~# ORIGINAL issue_331 +def foo a: + a +end + +#~# EXPECTED +def foo(a:) + a +end