File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed 
Sources/SwiftFormat/Rules 
Tests/SwiftFormatTests/Rules Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -131,12 +131,13 @@ public final class ValidateDocumentationComments: SyntaxLintRule {
131131    throwsDescription:  Paragraph ? , 
132132    node:  DeclSyntax 
133133  )  { 
134-     // If a function is marked as `rethrows`, it doesn't have any errors of its
135-     // own that should be documented. So only require documentation for
136-     // functions marked `throws`.
134+     // Documentation is required for functions marked as `throws`.
135+     // For functions marked as `rethrows`, documentation is not enforced
136+     // since they don’t introduce new errors of their own.
137+     // However, it can still be included if needed.
137138    let  needsThrowsDesc  =  throwsOrRethrowsKeyword? . tokenKind ==  . keyword( . throws) 
138139
139-     if  !needsThrowsDesc  && throwsDescription !=  nil  { 
140+     if  throwsOrRethrowsKeyword  ==   nil  && throwsDescription !=  nil  { 
140141      diagnose ( 
141142        . removeThrowsComment( funcName:  name) , 
142143        on:  throwsOrRethrowsKeyword ??  node. firstToken ( viewMode:  . sourceAccurate) 
Original file line number Diff line number Diff line change @@ -95,7 +95,6 @@ final class ValidateDocumentationCommentsTests: LintOrFormatRuleTestCase {
9595      findings:  [ 
9696        FindingSpec ( " 1️⃣ " ,  message:  " remove the 'Throws:' sections of 'doesNotThrow'; it does not throw any errors " ) , 
9797        FindingSpec ( " 2️⃣ " ,  message:  " add a 'Throws:' section to document the errors thrown by 'doesThrow' " ) , 
98-         FindingSpec ( " 3️⃣ " ,  message:  " remove the 'Throws:' sections of 'doesRethrow'; it does not throw any errors " ) , 
9998      ] 
10099    ) 
101100  } 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments