Sha256: ea3464a68ec3840d7627e8a11dd62ebbfbe8b6028fd2b1bc4997dca39e8dad8c
Contents?: true
Size: 1.12 KB
Versions: 10
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module RBS module Style # @example default # # bad # def initialize: () -> nil # # # good # def initialize: () -> untyped # # # good # def initialize: () -> void class InitializeReturnType < RuboCop::RBS::CopBase extend AutoCorrector MSG = '`#initialize` method should return `void`' def on_rbs_def(decl) return unless decl.name == :initialize return unless decl.kind == :instance return unless decl.overloading == false decl.overloads.each do |overload| return_type = overload.method_type.type.return_type next if return_type.is_a?(::RBS::Types::Bases::Any) next if return_type.is_a?(::RBS::Types::Bases::Void) range = location_to_range(return_type.location) add_offense(range) do |corrector| corrector.replace(range, 'void') end end end end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems