trailofbits.go.sleep-used-for-synchronizations.sleep-used-for-synchronizations

profile photo of trailofbitstrailofbits
Author
232
Download Count*

Using time.Sleep for synchronizations is generally considered bad practice.

Run Locally

Run in CI

Defintion

rules:
  - id: sleep-used-for-synchronizations
    patterns:
      - pattern-either:
          - pattern: |
              ...
              go func(...) {
              ...
              }(...)
              time.Sleep(...)
              ...
          - pattern: |
              ...
              go $FOO(...)
              time.Sleep(...)
              ...
      - pattern-inside: func $FUNC(...){ ... }
    message: Using `time.Sleep` for synchronizations is generally considered bad
      practice.
    languages:
      - go
    severity: WARNING
    metadata:
      license: CC-BY-NC-SA-4.0