Out of nowhere, Rubocop is complaining about classes that are not calling super.
W: Lint/MissingSuper: Call `super` to initialize state of the parent class.
Example:
# frozen_string_literal: true
class ApplicationService
class << self
def call(*args)
new(*args).call
end
end
def initialize(_args)
raise NotImplementedError
end
def call
raise NotImplementedError
end
end
class SampleService < ApplicationService
def initialize(something)
@something = something
end
def call
# do something
end
private
# remaining methods
end
I have ApplicationService just as a way to easily call a service with: SampleService.call(arguments).
For the services you could set in .rubocop.yml:
Lint/MissingSuper:
Exclude:
- 'app/services/**/*'
source: Recommend calling super in initialize
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With