Skip to content

Commit

Permalink
Merge pull request #1238 from euglena1215/remove-unused-rules
Browse files Browse the repository at this point in the history
Remove unused rules
  • Loading branch information
soutaro authored Oct 3, 2024
2 parents d05fac6 + a589395 commit a595da0
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 127 deletions.
57 changes: 0 additions & 57 deletions lib/steep/diagnostic/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -458,22 +458,6 @@ def header_line
end
end

class IncompatibleMethodTypeAnnotation < Base
attr_reader :interface_method
attr_reader :annotation_method
attr_reader :result

include ResultPrinter

def initialize(node:, interface_method:, annotation_method:, result:)
raise
super(node: node)
@interface_method = interface_method
@annotation_method = annotation_method
@result = result
end
end

class MethodReturnTypeAnnotationMismatch < Base
attr_reader :method_type
attr_reader :annotation_type
Expand Down Expand Up @@ -697,25 +681,6 @@ def header_line
end
end

class IncompatibleTypeCase < Base
attr_reader :var_name
attr_reader :result
attr_reader :relation

def initialize(node:, var_name:, result:, relation:)
super(node: node)
@var_name = var_name
@result = result
@relation = relation
end

include ResultPrinter

def header_line
"Type annotation for branch about `#{var_name}` is incompatible since #{relation} doesn't hold"
end
end

class UnreachableBranch < Base
def header_line
"The branch is unreachable"
Expand All @@ -735,19 +700,6 @@ def header_line
end
end

class UnexpectedSplat < Base
attr_reader :type

def initialize(node:, type:)
super(node: node)
@type = type
end

def header_line
"Hash splat is given with object other than `Hash[X, Y]`"
end
end

class ProcTypeExpected < Base
attr_reader :type

Expand Down Expand Up @@ -991,8 +943,6 @@ def self.default
IncompatibleAnnotation => :hint,
IncompatibleArgumentForwarding => :warning,
IncompatibleAssignment => :hint,
IncompatibleMethodTypeAnnotation => :hint,
IncompatibleTypeCase => :hint,
InsufficientKeywordArguments => :error,
InsufficientPositionalArguments => :error,
InsufficientTypeArgument => :hint,
Expand Down Expand Up @@ -1020,7 +970,6 @@ def self.default
UnexpectedJumpValue => :hint,
UnexpectedKeywordArgument => :error,
UnexpectedPositionalArgument => :error,
UnexpectedSplat => :hint,
UnexpectedSuper => :information,
UnexpectedTypeArgument => :hint,
UnexpectedYield => :warning,
Expand Down Expand Up @@ -1050,8 +999,6 @@ def self.strict
IncompatibleAnnotation => :error,
IncompatibleArgumentForwarding => :error,
IncompatibleAssignment => :error,
IncompatibleMethodTypeAnnotation => :error,
IncompatibleTypeCase => :error,
InsufficientKeywordArguments => :error,
InsufficientPositionalArguments => :error,
InsufficientTypeArgument => :error,
Expand Down Expand Up @@ -1079,7 +1026,6 @@ def self.strict
UnexpectedJumpValue => :error,
UnexpectedKeywordArgument => :error,
UnexpectedPositionalArgument => :error,
UnexpectedSplat => :warning,
UnexpectedSuper => :error,
UnexpectedTypeArgument => :error,
UnexpectedYield => :error,
Expand Down Expand Up @@ -1109,8 +1055,6 @@ def self.lenient
IncompatibleAnnotation => nil,
IncompatibleArgumentForwarding => :information,
IncompatibleAssignment => :hint,
IncompatibleMethodTypeAnnotation => nil,
IncompatibleTypeCase => nil,
InsufficientKeywordArguments => :information,
InsufficientPositionalArguments => :information,
InsufficientTypeArgument => nil,
Expand Down Expand Up @@ -1138,7 +1082,6 @@ def self.lenient
UnexpectedJumpValue => nil,
UnexpectedKeywordArgument => :information,
UnexpectedPositionalArgument => :information,
UnexpectedSplat => nil,
UnexpectedSuper => nil,
UnexpectedTypeArgument => nil,
UnexpectedYield => :information,
Expand Down
34 changes: 0 additions & 34 deletions sig/steep/diagnostic/ruby.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -283,18 +283,6 @@ module Steep
def header_line: () -> ::String
end

class IncompatibleMethodTypeAnnotation < Base
attr_reader interface_method: untyped

attr_reader annotation_method: untyped

attr_reader result: untyped

include ResultPrinter

def initialize: (node: untyped, interface_method: untyped, annotation_method: untyped, result: untyped) -> void
end

class MethodReturnTypeAnnotationMismatch < Base
attr_reader method_type: untyped

Expand Down Expand Up @@ -455,20 +443,6 @@ module Steep
def header_line: () -> ::String
end

class IncompatibleTypeCase < Base
attr_reader var_name: untyped

attr_reader result: untyped

attr_reader relation: untyped

def initialize: (node: untyped, var_name: untyped, result: untyped, relation: untyped) -> void

include ResultPrinter

def header_line: () -> ::String
end

class UnreachableBranch < Base
def header_line: () -> String
end
Expand Down Expand Up @@ -498,14 +472,6 @@ module Steep
def header_line: () -> String
end

class UnexpectedSplat < Base
attr_reader type: untyped

def initialize: (node: untyped, type: untyped) -> void

def header_line: () -> "Hash splat is given with object other than `Hash[X, Y]`"
end

class ProcTypeExpected < Base
attr_reader type: untyped

Expand Down
1 change: 0 additions & 1 deletion smoke/diagnostics/unexpected_splat.rb

This file was deleted.

35 changes: 0 additions & 35 deletions test/type_construction_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1331,41 +1331,6 @@ def foo(x)
end
end

def test_new_method_with_incompatible_annotation
with_checker <<-EOF do |checker|
class A
def foo: (String) -> Integer
end
EOF

source = parse_ruby(<<-RUBY)
class A
# @type method foo: (String) -> String
def foo(x)
nil
end
end
RUBY

with_standard_construction(checker, source) do |construction, typing|
def_node = source.node.children[2]
type_name = parse_type("::A").name
instance_definition = checker.factory.definition_builder.build_instance(type_name)

construction.for_new_method(:foo,
def_node,
args: def_node.children[1].children,
self_type: parse_type("::A"),
definition: instance_definition)

skip "Skip testing if method type annotation is compatible with interface"

assert_equal 1, typing.errors.size
assert_instance_of Diagnostic::Ruby::IncompatibleMethodTypeAnnotation, typing.errors.first
end
end
end

def test_relative_type_name
with_checker <<-EOF do |checker|
class A::String
Expand Down

0 comments on commit a595da0

Please sign in to comment.