Class: RuboCop::Cop::Sorbet::EnforceSignatures::SigSuggestion

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/cop/sorbet/signatures/enforce_signatures.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(indent, param_placeholder, return_placeholder) ⇒ SigSuggestion

Returns a new instance of SigSuggestion.



107
108
109
110
111
112
113
# File 'lib/rubocop/cop/sorbet/signatures/enforce_signatures.rb', line 107

def initialize(indent, param_placeholder, return_placeholder)
  @params = []
  @returns = nil
  @indent = indent
  @param_placeholder = param_placeholder
  @return_placeholder = return_placeholder
end

Instance Attribute Details

#paramsObject

Returns the value of attribute params.



105
106
107
# File 'lib/rubocop/cop/sorbet/signatures/enforce_signatures.rb', line 105

def params
  @params
end

#returnsObject

Returns the value of attribute returns.



105
106
107
# File 'lib/rubocop/cop/sorbet/signatures/enforce_signatures.rb', line 105

def returns
  @returns
end

Instance Method Details

#to_autocorrectObject



115
116
117
118
119
120
121
122
123
# File 'lib/rubocop/cop/sorbet/signatures/enforce_signatures.rb', line 115

def to_autocorrect
  out = StringIO.new
  out << "sig { "
  out << generate_params
  out << generate_return
  out << " }\n"
  out << " " * @indent # preserve indent for the next line
  out.string
end