From c146ef4438b296670ce5909db7c1f48f230fb424 Mon Sep 17 00:00:00 2001 From: Sam Bostock Date: Mon, 20 Feb 2023 10:46:32 -0500 Subject: [PATCH] Improve ForbidTUn{safe,typed} --- lib/rubocop/cop/sorbet/forbid_t_unsafe.rb | 5 ++++- lib/rubocop/cop/sorbet/forbid_t_untyped.rb | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/rubocop/cop/sorbet/forbid_t_unsafe.rb b/lib/rubocop/cop/sorbet/forbid_t_unsafe.rb index 51dd9a0f..e7a6e0ab 100644 --- a/lib/rubocop/cop/sorbet/forbid_t_unsafe.rb +++ b/lib/rubocop/cop/sorbet/forbid_t_unsafe.rb @@ -15,11 +15,14 @@ module Sorbet # # good # foo class ForbidTUnsafe < RuboCop::Cop::Base + MSG = "Do not use `T.unsafe`." + RESTRICT_ON_SEND = [:unsafe].freeze + # @!method t_unsafe?(node) def_node_matcher(:t_unsafe?, "(send (const nil? :T) :unsafe _)") def on_send(node) - add_offense(node, message: "Do not use `T.unsafe`.") if t_unsafe?(node) + add_offense(node) if t_unsafe?(node) end end end diff --git a/lib/rubocop/cop/sorbet/forbid_t_untyped.rb b/lib/rubocop/cop/sorbet/forbid_t_untyped.rb index c35b59b9..78bc076f 100644 --- a/lib/rubocop/cop/sorbet/forbid_t_untyped.rb +++ b/lib/rubocop/cop/sorbet/forbid_t_untyped.rb @@ -18,11 +18,14 @@ module Sorbet # def foo(my_argument); end # class ForbidTUntyped < RuboCop::Cop::Base + MSG = "Do not use `T.untyped`." + RESTRICT_ON_SEND = [:untyped].freeze + # @!method t_untyped?(node) def_node_matcher(:t_untyped?, "(send (const nil? :T) :untyped)") def on_send(node) - add_offense(node, message: "Do not use `T.untyped`.") if t_untyped?(node) + add_offense(node) if t_untyped?(node) end end end