I’d like to suggest disabling Style/RedundantStructKeywordInit in Standard’s default config.
It was introduced here #812
RuboCop keeps this cop disabled by default because keyword_init: true is not purely redundant.
Explained here https://docs.rubocop.org/rubocop/latest/cops_style.html#styleredundantstructkeywordinit
My personal concern is that keyword_init: true is a useful public-interface signal:
Result = Struct.new(:eligible, :reason, keyword_init: true)
Makes the intended usage clear:
Result.new(eligible: true, reason: nil)
And tells the caller not to use:
Result.new(true, nil) # As this will now not be allowed.
So while removing keyword_init: true shortens the code, it also removes intent and weakens the constructor contract.
I’d like to suggest disabling
Style/RedundantStructKeywordInitin Standard’s default config.It was introduced here #812
RuboCop keeps this cop disabled by default because
keyword_init: trueis not purely redundant.Explained here https://docs.rubocop.org/rubocop/latest/cops_style.html#styleredundantstructkeywordinit
My personal concern is that
keyword_init: trueis a useful public-interface signal:Makes the intended usage clear:
And tells the caller not to use:
So while removing
keyword_init: trueshortens the code, it also removes intent and weakens the constructor contract.