Update full linter list and enable some easily resolved new ones

This commit is contained in:
Katrina Verey
2022-03-30 14:07:54 -04:00
parent 0a9c5cb0cf
commit 71bf0d5d14
61 changed files with 185 additions and 184 deletions

View File

@@ -32,6 +32,7 @@ func run(input string, f kio.Filter) (string, error) {
// RunFilter runs filter and panic if there is error
func RunFilter(t *testing.T, input string, f kio.Filter) string {
t.Helper()
output, err := run(input, f)
if !assert.NoError(t, err) {
t.FailNow()
@@ -41,6 +42,7 @@ func RunFilter(t *testing.T, input string, f kio.Filter) string {
// RunFilterE runs filter and return error if there is
func RunFilterE(t *testing.T, input string, f kio.Filter) (string, error) {
t.Helper()
output, err := run(input, f)
if err != nil {
return "", err

View File

@@ -22,11 +22,13 @@ type Harness struct {
}
func MakeHarness(t *testing.T) Harness {
t.Helper()
return MakeHarnessWithFs(t, filesys.MakeFsInMemory())
}
func MakeHarnessWithFs(
t *testing.T, fSys filesys.FileSystem) Harness {
t.Helper()
return Harness{
t: t,
fSys: fSys,

View File

@@ -47,6 +47,7 @@ type HarnessEnhanced struct {
}
func MakeEnhancedHarness(t *testing.T) *HarnessEnhanced {
t.Helper()
r := makeBaseEnhancedHarness(t)
r.Harness = MakeHarnessWithFs(t, filesys.MakeFsInMemory())
// Point the Harness's file loader to the root ('/')
@@ -56,6 +57,7 @@ func MakeEnhancedHarness(t *testing.T) *HarnessEnhanced {
}
func MakeEnhancedHarnessWithTmpRoot(t *testing.T) *HarnessEnhanced {
t.Helper()
r := makeBaseEnhancedHarness(t)
fSys := filesys.MakeFsOnDisk()
r.Harness = MakeHarnessWithFs(t, fSys)
@@ -72,6 +74,7 @@ func MakeEnhancedHarnessWithTmpRoot(t *testing.T) *HarnessEnhanced {
}
func makeBaseEnhancedHarness(t *testing.T) *HarnessEnhanced {
t.Helper()
rf := resmap.NewFactory(
provider.NewDefaultDepProvider().GetResourceFactory())
return &HarnessEnhanced{

View File

@@ -26,6 +26,7 @@ func AssertActualEqualsExpectedWithTweak(
t *testing.T,
m resmap.ResMap,
tweaker func([]byte) []byte, expected string) {
t.Helper()
if m == nil {
t.Fatalf("Map should not be nil.")
}
@@ -49,13 +50,14 @@ func AssertActualEqualsExpectedWithTweak(
// Pretty printing of file differences.
func reportDiffAndFail(
t *testing.T, actual []byte, expected string) {
t.Helper()
sE, maxLen := convertToArray(expected)
sA, _ := convertToArray(string(actual))
fmt.Println("===== ACTUAL BEGIN ========================================")
fmt.Print(string(actual))
fmt.Println("===== ACTUAL END ==========================================")
format := fmt.Sprintf("%%s %%-%ds %%s\n", maxLen+4)
limit := 0
var limit int
if len(sE) < len(sA) {
limit = len(sE)
} else {

View File

@@ -25,6 +25,7 @@ type pluginTestEnv struct {
// newPluginTestEnv returns a new instance of pluginTestEnv.
func newPluginTestEnv(t *testing.T) *pluginTestEnv {
t.Helper()
return &pluginTestEnv{t: t}
}

View File

@@ -20,18 +20,22 @@ type rmBuilder struct {
}
func NewSeededRmBuilder(t *testing.T, rf *resource.Factory, m resmap.ResMap) *rmBuilder {
t.Helper()
return &rmBuilder{t: t, rf: rf, m: m}
}
func NewRmBuilder(t *testing.T, rf *resource.Factory) *rmBuilder {
t.Helper()
return NewSeededRmBuilder(t, rf, resmap.New())
}
func NewRmBuilderDefault(t *testing.T) *rmBuilder {
t.Helper()
return NewSeededRmBuilderDefault(t, resmap.New())
}
func NewSeededRmBuilderDefault(t *testing.T, m resmap.ResMap) *rmBuilder {
t.Helper()
return NewSeededRmBuilder(
t, provider.NewDefaultDepProvider().GetResourceFactory(), m)
}

View File

@@ -22,11 +22,13 @@ const SAD = "i'm not happy Bob, NOT HAPPY"
// MakeHappyMapValidator makes a fakeValidator that always passes.
func MakeHappyMapValidator(t *testing.T) *fakeValidator {
t.Helper()
return &fakeValidator{happy: true, t: t}
}
// MakeSadMapValidator makes a fakeValidator that always fails.
func MakeSadMapValidator(t *testing.T) *fakeValidator {
t.Helper()
return &fakeValidator{happy: false, t: t}
}