2023-03-15 16:00:52 +00:00
|
|
|
# Copyright (c) HashiCorp, Inc.
|
|
|
|
# SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2022-03-18 18:14:03 +00:00
|
|
|
rules:
|
2022-11-17 23:12:03 +00:00
|
|
|
- id: hc-return-nil
|
2022-03-18 18:14:03 +00:00
|
|
|
patterns:
|
|
|
|
- pattern-either:
|
|
|
|
- pattern: |
|
|
|
|
if $X == nil {
|
|
|
|
return $X
|
|
|
|
}
|
|
|
|
- pattern: |
|
|
|
|
if $X != nil {
|
|
|
|
return ...
|
|
|
|
}
|
|
|
|
return $X
|
|
|
|
message: return nil instead of nil value
|
|
|
|
languages:
|
|
|
|
- go
|
|
|
|
severity: ERROR
|
|
|
|
metadata:
|
|
|
|
license: MIT
|