Skip to content

Incorrect ValidateDocumentationComments warning for rethrows function #928

@rauhul

Description

@rauhul

Sources/ArgumentParser/Utilities/Mutex.swift:53:5: warning: [ValidateDocumentationComments] remove the 'Throws:' sections of 'withLock'; it does not throw any errors

  /// Calls the given closure after acquiring the lock and then releases
  /// ownership.
  ///
  /// - Warning: Recursive calls to `withLock` within the closure parameter has
  ///   behavior that is platform dependent. Some platforms may choose to panic
  ///   the process, deadlock, or leave this behavior unspecified. This will
  ///   never reacquire the lock however.
  ///
  /// - Parameter body: A closure with a parameter of `Value` that has exclusive
  ///   access to the value being stored within this mutex. This closure is
  ///   considered the critical section as it will only be executed once the
  ///   calling thread has acquired the lock.
  ///
  /// - Throws: Re-throws any error thrown by `body`.
  ///
  /// - Returns: The return value, if any, of the `body` closure parameter.
  func withLock<U>(
    _ body: (inout T) throws -> U
  ) rethrows -> U {
    self.lock.lock()
    defer { self.lock.unlock() }
    return try body(&self.value)
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions