1- # typed: true # rubocop:todo Sorbet/StrictSigil
1+ # typed: strict
22# frozen_string_literal: true
33
44require "rubocops/shared/helper_functions"
@@ -25,7 +25,8 @@ def audit_desc(type, name, desc_call)
2525 return
2626 end
2727
28- @offensive_node = desc_call
28+ @offensive_node = T . let ( desc_call , T . nilable ( RuboCop ::AST ::Node ) )
29+ @name = T . let ( name , T . nilable ( String ) )
2930
3031 desc = T . cast ( desc_call , RuboCop ::AST ::SendNode ) . first_argument
3132
@@ -84,9 +85,10 @@ def audit_desc(type, name, desc_call)
8485 end
8586
8687 # Auto correct desc problems. `regex_match_group` must be called before this to populate @offense_source_range.
88+ sig { params ( message : String ) . void }
8789 def desc_problem ( message )
8890 add_offense ( @offensive_source_range , message :) do |corrector |
89- match_data = @offensive_node . source . match ( /\A (?<quote>["'])(?<correction>.*)(?:\k <quote>)\Z / )
91+ match_data = T . must ( @offensive_node ) . source . match ( /\A (?<quote>["'])(?<correction>.*)(?:\k <quote>)\Z / )
9092 correction = match_data [ :correction ]
9193 quote = match_data [ :quote ]
9294
@@ -112,7 +114,7 @@ def desc_problem(message)
112114
113115 next if correction == match_data [ :correction ]
114116
115- corrector . replace ( @offensive_node . source_range , "#{ quote } #{ correction } #{ quote } " )
117+ corrector . replace ( @offensive_node & .source_range , "#{ quote } #{ correction } #{ quote } " )
116118 end
117119 end
118120 end
0 commit comments