Update golangci-lint linters
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
IamTheFij 2022-11-10 13:30:30 -08:00
parent e62c83eed8
commit ed3689eae1
6 changed files with 35 additions and 38 deletions

View File

@ -1,16 +1,13 @@
---
linters:
enable:
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
- asciicheck
- bidichk
@ -26,7 +23,7 @@ linters:
- errname
- errorlint
- exhaustive
- exhaustivestruct
- exhaustruct
- exportloopref
- forcetypeassert
- funlen
@ -47,7 +44,6 @@ linters:
- goprintffuncname
- gosec
- grouper
- ifshort
- importas
# - ireturn
- lll
@ -91,22 +87,23 @@ linters:
- interfacer
- maligned
- scopelint
- ifshort
- varcheck
- structcheck
- deadcode
- exhaustivestruct
linters-settings:
# gosec:
# excludes:
# - G204
gomnd:
settings:
mnd:
ignored-functions: math.*
issues:
fix: true
exclude-rules:
- path: _test\.go
linters:
- errcheck
- gosec
- funlen
# Enable autofix
fix: true

View File

@ -27,12 +27,12 @@ func TestResticConfigValidate(t *testing.T) {
{
name: "missing passphrase",
expectedErr: main.ErrMutuallyExclusive,
config: main.ResticConfig{}, //nolint:exhaustivestruct
config: main.ResticConfig{}, //nolint:exhaustruct
},
{
name: "passphrase no file",
expectedErr: nil,
//nolint:exhaustivestruct
//nolint:exhaustruct
config: main.ResticConfig{
Passphrase: "shh",
},
@ -40,7 +40,7 @@ func TestResticConfigValidate(t *testing.T) {
{
name: "file no passphrase",
expectedErr: nil,
//nolint:exhaustivestruct
//nolint:exhaustruct
config: main.ResticConfig{
GlobalOpts: &main.ResticGlobalOpts{
PasswordFile: "file",
@ -50,7 +50,7 @@ func TestResticConfigValidate(t *testing.T) {
{
name: "file and passphrase",
expectedErr: main.ErrMutuallyExclusive,
//nolint:exhaustivestruct
//nolint:exhaustruct
config: main.ResticConfig{
Passphrase: "shh",
GlobalOpts: &main.ResticGlobalOpts{
@ -89,7 +89,7 @@ func TestJobValidation(t *testing.T) {
Schedule: "@daily",
Config: ValidResticConfig(),
Tasks: []main.JobTask{},
Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustivestruct
Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustruct
Forget: nil,
MySQL: []main.JobTaskMySQL{},
Sqlite: []main.JobTaskSqlite{},
@ -103,7 +103,7 @@ func TestJobValidation(t *testing.T) {
Schedule: "@daily",
Config: ValidResticConfig(),
Tasks: []main.JobTask{},
Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustivestruct
Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustruct
Forget: nil,
MySQL: []main.JobTaskMySQL{},
Sqlite: []main.JobTaskSqlite{},
@ -117,7 +117,7 @@ func TestJobValidation(t *testing.T) {
Schedule: "shrug",
Config: ValidResticConfig(),
Tasks: []main.JobTask{},
Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustivestruct
Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustruct
Forget: nil,
MySQL: []main.JobTaskMySQL{},
Sqlite: []main.JobTaskSqlite{},
@ -129,9 +129,9 @@ func TestJobValidation(t *testing.T) {
job: main.Job{
Name: "Test job",
Schedule: "@daily",
Config: main.ResticConfig{}, //nolint:exhaustivestruct
Config: main.ResticConfig{}, //nolint:exhaustruct
Tasks: []main.JobTask{},
Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustivestruct
Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustruct
Forget: nil,
MySQL: []main.JobTaskMySQL{},
Sqlite: []main.JobTaskSqlite{},
@ -145,7 +145,7 @@ func TestJobValidation(t *testing.T) {
Schedule: "@daily",
Config: ValidResticConfig(),
Tasks: []main.JobTask{{}},
Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustivestruct
Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustruct
Forget: nil,
MySQL: []main.JobTaskMySQL{},
Sqlite: []main.JobTaskSqlite{},
@ -159,7 +159,7 @@ func TestJobValidation(t *testing.T) {
Schedule: "@daily",
Config: ValidResticConfig(),
Tasks: []main.JobTask{},
Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustivestruct
Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustruct
Forget: nil,
MySQL: []main.JobTaskMySQL{{}},
Sqlite: []main.JobTaskSqlite{},
@ -173,7 +173,7 @@ func TestJobValidation(t *testing.T) {
Schedule: "@daily",
Config: ValidResticConfig(),
Tasks: []main.JobTask{},
Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustivestruct
Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustruct
Forget: nil,
MySQL: []main.JobTaskMySQL{},
Sqlite: []main.JobTaskSqlite{{}},
@ -212,7 +212,7 @@ func TestConfigValidation(t *testing.T) {
Schedule: "@daily",
Config: ValidResticConfig(),
Tasks: []main.JobTask{},
Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustivestruct
Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustruct
MySQL: []main.JobTaskMySQL{},
Sqlite: []main.JobTaskSqlite{},
}}},
@ -230,7 +230,7 @@ func TestConfigValidation(t *testing.T) {
Schedule: "@daily",
Config: ValidResticConfig(),
Tasks: []main.JobTask{},
Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustivestruct
Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustruct
Forget: nil,
MySQL: []main.JobTaskMySQL{},
Sqlite: []main.JobTaskSqlite{},

View File

@ -49,7 +49,7 @@ func TestRunJobs(t *testing.T) {
Schedule: "@daily",
Config: ValidResticConfig(),
Tasks: []main.JobTask{},
Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustivestruct
Backup: main.BackupFilesTask{Paths: []string{"/test"}}, //nolint:exhaustruct
Forget: nil,
MySQL: []main.JobTaskMySQL{},
Sqlite: []main.JobTaskSqlite{},

View File

@ -160,19 +160,19 @@ func TestBuildEnv(t *testing.T) {
}{
{
name: "No Env",
cmd: main.Restic{}, //nolint:exhaustivestruct
cmd: main.Restic{}, //nolint:exhaustruct
expected: os.Environ(),
},
{
name: "SetEnv",
cmd: main.Restic{ //nolint:exhaustivestruct
cmd: main.Restic{ //nolint:exhaustruct
Env: map[string]string{"TestKey": "Value"},
},
expected: append(os.Environ(), "TestKey=Value"),
},
{
name: "SetEnv",
cmd: main.Restic{ //nolint:exhaustivestruct
cmd: main.Restic{ //nolint:exhaustruct
Passphrase: "Shhhhhhhh!!",
},
expected: append(os.Environ(), "RESTIC_PASSWORD=Shhhhhhhh!!"),
@ -210,7 +210,7 @@ func TestResticInterface(t *testing.T) {
Repo: repoDir,
Env: map[string]string{},
Passphrase: "Correct.Horse.Battery.Staple",
//nolint:exhaustivestruct
//nolint:exhaustruct
GlobalOpts: &main.ResticGlobalOpts{
CacheDir: cacheDir,
Options: map[string]string{
@ -231,7 +231,7 @@ func TestResticInterface(t *testing.T) {
}
// Try to backup when repo is not initialized
err = restic.Backup([]string{dataDir}, main.BackupOpts{}) //nolint:exhaustivestruct
err = restic.Backup([]string{dataDir}, main.BackupOpts{}) //nolint:exhaustruct
if !errors.Is(err, main.ErrRepoNotFound) {
AssertEqualFail(t, "unexpected error creating making backup", nil, err)
}
@ -245,7 +245,7 @@ func TestResticInterface(t *testing.T) {
AssertEqualFail(t, "unexpected error reinitializing repo", nil, err)
// Backup for real this time
err = restic.Backup([]string{dataDir}, main.BackupOpts{Tags: []string{"test"}}) //nolint:exhaustivestruct
err = restic.Backup([]string{dataDir}, main.BackupOpts{Tags: []string{"test"}}) //nolint:exhaustruct
AssertEqualFail(t, "unexpected error creating making backup", nil, err)
// Check snapshots
@ -259,7 +259,7 @@ func TestResticInterface(t *testing.T) {
AssertEqual(t, "unexpected snapshot value: tags", []string{"test"}, snapshots[0].Tags)
// Backup again
err = restic.Backup([]string{dataDir}, main.BackupOpts{}) //nolint:exhaustivestruct
err = restic.Backup([]string{dataDir}, main.BackupOpts{}) //nolint:exhaustruct
AssertEqualFail(t, "unexpected error creating making second backup", nil, err)
// Check for second backup
@ -268,7 +268,7 @@ func TestResticInterface(t *testing.T) {
AssertEqual(t, "unexpected number of snapshots", 2, len(snapshots))
// Forget one backup
err = restic.Forget(main.ForgetOpts{KeepLast: 1, Prune: true}) //nolint:exhaustivestruct
err = restic.Forget(main.ForgetOpts{KeepLast: 1, Prune: true}) //nolint:exhaustruct
AssertEqualFail(t, "unexpected error forgetting snapshot", nil, err)
// Check forgotten snapshot
@ -290,7 +290,7 @@ func TestResticInterface(t *testing.T) {
AssertEqualFail(t, "incorrect value in test file (we expect the unexpected!)", "unexpected", string(value))
// Restore files
err = restic.Restore("latest", main.RestoreOpts{Target: restoreTarget}) //nolint:exhaustivestruct
err = restic.Restore("latest", main.RestoreOpts{Target: restoreTarget}) //nolint:exhaustruct
AssertEqualFail(t, "unexpected error restoring latest snapshot", nil, err)
// Check restored values

View File

@ -230,7 +230,7 @@ type BackupFilesTask struct {
func (t BackupFilesTask) RunBackup(cfg TaskConfig) error {
if t.BackupOpts == nil {
t.BackupOpts = &BackupOpts{} //nolint:exhaustivestruct
t.BackupOpts = &BackupOpts{} //nolint:exhaustruct
}
if err := cfg.Restic.Backup(cfg.BackupPaths, *t.BackupOpts); err != nil {
@ -245,7 +245,7 @@ func (t BackupFilesTask) RunBackup(cfg TaskConfig) error {
func (t BackupFilesTask) RunRestore(cfg TaskConfig) error {
if t.RestoreOpts == nil {
t.RestoreOpts = &RestoreOpts{} //nolint:exhaustivestruct
t.RestoreOpts = &RestoreOpts{} //nolint:exhaustruct
}
// TODO: Make the snapshot configurable

View File

@ -120,7 +120,7 @@ func TestJobTaskSql(t *testing.T) {
}{
{
name: "mysql simple",
//nolint:exhaustivestruct
//nolint:exhaustruct
task: main.JobTaskMySQL{
Name: "simple",
DumpToPath: "./simple.sql",
@ -133,7 +133,7 @@ func TestJobTaskSql(t *testing.T) {
},
{
name: "mysql tables no database",
//nolint:exhaustivestruct
//nolint:exhaustruct
task: main.JobTaskMySQL{
Name: "name",
Tables: []string{"table1", "table2"},