Improve class method printing
Rails in particular has a lot of class methods within its API. I'm not massively opinionated here, but perhaps the convention should be to drop brackets on method calls within class bodies
Input
class MyClass
helper :all
before_action :hello_world
include FooBarBaz
def self.foo
puts "foo"
end
private_class_method :foo
private_class_method def self.bar
puts "bar"
end
end
Current output
class MyClass
helper(:all)
before_action(:hello_world)
include(FooBarBaz)
def self.foo
puts 'foo'
end
private_class_method(:foo)
private_class_method(def self.bar
puts 'bar'
end)
end
Expected Output
Brackets are dropped from method/command calls within the class body
class MyClass
helper :all
before_action :hello_world
include FooBarBaz
def self.foo
puts 'foo'
end
private_class_method :foo
private_class_method def self.bar
puts 'bar'
end
end
Hey, we do drop parens when we should like for puts etc.
we can add more method names where parens are not required, or we can default to no paren and add it as an option.
Yip, all sound good - I'm sure we'll get the right balance here 🤞
There's also a bunch of nice examples within Rubocop too - https://github.com/rubocop-hq/ruby-style-guide#classes--modules
How about printing parens if the call breaks, if there is a nested call, or if there are 3 or more parameters?