rules:
  - id: channel-guarded-with-mutex
    pattern-either:
      - pattern: |
          $MUX.Lock()
          $VALUE <- $CHANNEL
          $MUX.Unlock()
      - pattern: |
          $MUX.Lock()
          $VALUE = <- $CHANNEL
          $MUX.Unlock()
    message: >-
      Detected a channel guarded with a mutex. Channels already have
      an internal mutex, so this is unnecessary. Remove the mutex.
      See https://hackmongo.com/page/golang-antipatterns/#guarded-channel
      for more information.
    languages: [go]
    severity: WARNING
    metadata:
      category: best-practice
      technology:
        - go
