vault/tools/codechecker/pkg/gonilnilfunctions/testdata/funcs.go
miagilepner 8c18f24b9d
VAULT-17734, VAULT-17735: Combine linters (#21611)
* combine into one checker

* combine and simplify ci checks

* add to test package list

* remove testing test

* only run deprecations check

* only run deprecations check

* remove unneeded repo check

* fix bash options
2023-07-06 15:18:42 +02:00

74 lines
1.6 KiB
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package testdata
func ReturnReturnOkay() (any, error) {
var i interface{}
return i, nil
}
func OneGoodOneBad() (any, error) { // want "Function OneGoodOneBad can return an error, and has a statement that returns only nils"
var i interface{}
if true {
return i, nil
}
return nil, nil
}
func OneBadOneGood() (any, error) { // want "Function OneBadOneGood can return an error, and has a statement that returns only nils"
var i interface{}
if true {
return nil, nil
}
return i, nil
}
func EmptyFunc() {}
func TwoNilNils() (any, error) { // want "Function TwoNilNils can return an error, and has a statement that returns only nils"
if true {
return nil, nil
}
return nil, nil
}
// ThreeResults should not fail, as while it returns nil, nil, nil, it has three results, not two.
func ThreeResults() (any, any, error) {
return nil, nil, nil
}
func TwoArgsNoError() (any, any) {
return nil, nil
}
func NestedReturn() (any, error) { // want "Function NestedReturn can return an error, and has a statement that returns only nils"
{
{
{
return nil, nil
}
}
}
}
func NestedForReturn() (any, error) { // want "Function NestedForReturn can return an error, and has a statement that returns only nils"
for {
for i := 0; i < 100; i++ {
{
return nil, nil
}
}
}
}
func AnyErrorNilNil() (any, error) { // want "Function AnyErrorNilNil can return an error, and has a statement that returns only nils"
return nil, nil
}
// Skipped should be skipped because of the following line:
// ignore-nil-nil-function-check
func Skipped() (any, error) {
return nil, nil
}