Skip to content

Commit 24cf729

Browse files
authored
chore(golangci-lint): enable format, import, and unused presets; disable depguard (#387)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 0d3394c commit 24cf729

File tree

10 files changed

+42
-14
lines changed

10 files changed

+42
-14
lines changed

.golangci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ issues:
44
max-issues-per-linter: 0
55
max-same-issues: 0
66
linters:
7+
disable:
8+
- depguard
79
enable:
810
- errcheck
911
- gosimple
@@ -12,9 +14,15 @@ linters:
1214
- staticcheck
1315
- unused
1416
# Defaults above ours below
17+
- copyloopvar
18+
- usestdlibvars
19+
- whitespace
1520
presets:
1621
- bugs
22+
- format
23+
- import
1724
- performance
25+
- unused
1826
#linters-settings:
1927
# errcheck:
2028
# check-type-assertions: true

cmd/cardano-up/context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func contextListCommand() *cobra.Command {
6969
tmpContextNames = append(tmpContextNames, contextName)
7070
}
7171
sort.Strings(tmpContextNames)
72-
//for contextName, context := range contexts {
72+
// for contextName, context := range contexts {
7373
for _, contextName := range tmpContextNames {
7474
context := contexts[contextName]
7575
activeMarker := " "

cmd/cardano-up/list_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ func TestCompareVersions(t *testing.T) {
1616
for _, tc := range cases {
1717
result := compareVersions(tc.v1, tc.v2)
1818
if result == tc.expected {
19-
t.Logf("Test Passed: compareVersions(%s, %s) = %v (Expected: %v)\n", tc.v1, tc.v2, result, tc.expected)
19+
t.Logf(
20+
"Test Passed: compareVersions(%s, %s) = %v (Expected: %v)\n",
21+
tc.v1,
22+
tc.v2,
23+
result,
24+
tc.expected,
25+
)
2026

2127
} else {
2228
t.Errorf("Test Failed: compareVersions(%s, %s) = %v; Expected %v", tc.v1, tc.v2, result, tc.expected)

cmd/cardano-up/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121

2222
"github.com/blinklabs-io/cardano-up/internal/consolelog"
2323
"github.com/blinklabs-io/cardano-up/pkgmgr"
24-
2524
"github.com/spf13/cobra"
2625
)
2726

internal/version/version.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ import (
1919
)
2020

2121
// These are populated at build time
22-
var Version string
23-
var CommitHash string
22+
var (
23+
Version string
24+
CommitHash string
25+
)
2426

2527
func GetVersionString() string {
2628
if Version != "" {

pkgmgr/package.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ func (p Package) services(
627627
err,
628628
),
629629
)
630-
continue
630+
return ret, ErrOperationFailed
631631
}
632632
ret = append(ret, dockerService)
633633
}
@@ -674,6 +674,7 @@ type PackageInstallStepDocker struct {
674674

675675
func (p *PackageInstallStepDocker) validate(cfg Config) error {
676676
if p.Image == "" {
677+
cfg.Logger.Debug("docker image missing")
677678
return errors.New("docker image must be provided")
678679
}
679680
// TODO: add more checks
@@ -1034,7 +1035,7 @@ func (p *PackageInstallStepFile) deactivate(cfg Config, pkgName string) error {
10341035
return err
10351036
}
10361037
}
1037-
cfg.Logger.Debug("removed symlink " + binPath)
1038+
cfg.Logger.Debug("removed symlink " + binPath + "for " + pkgName)
10381039
}
10391040
return nil
10401041
}

pkgmgr/package_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ func TestOSAndARCH(t *testing.T) {
128128
}
129129

130130
if actualOS == expectOS && actualARCH == expectARCH {
131-
t.Logf("Test is successful and OS, ARCH values are correctly injected to config template")
131+
t.Logf(
132+
"Test is successful and OS, ARCH values are correctly injected to config template",
133+
)
132134
}
133135
}

pkgmgr/pkgmgr.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ func (p *PackageManager) Up() error {
122122
if err != nil {
123123
return err
124124
}
125-
126125
}
127126
return nil
128127
}
@@ -514,10 +513,16 @@ func (p *PackageManager) Info(pkgs ...string) error {
514513
}
515514
}
516515
if statusOutput != "" {
517-
infoOutput += "\n\nServices:\n\n" + strings.TrimSuffix(statusOutput, "\n")
516+
infoOutput += "\n\nServices:\n\n" + strings.TrimSuffix(
517+
statusOutput,
518+
"\n",
519+
)
518520
}
519521
if portOutput != "" {
520-
infoOutput += "\n\nMapped ports:\n\n" + strings.TrimSuffix(portOutput, "\n")
522+
infoOutput += "\n\nMapped ports:\n\n" + strings.TrimSuffix(
523+
portOutput,
524+
"\n",
525+
)
521526
}
522527
if idx < len(infoPkgs)-1 {
523528
infoOutput += "\n\n---\n\n"

pkgmgr/registry.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,12 @@ func registryPackagesUrl(cfg Config, validate bool) ([]Package, error) {
138138
"Fetching package registry " + cfg.RegistryUrl,
139139
)
140140
ctx := context.Background()
141-
req, err := http.NewRequestWithContext(ctx, http.MethodGet, cfg.RegistryUrl, nil)
141+
req, err := http.NewRequestWithContext(
142+
ctx,
143+
http.MethodGet,
144+
cfg.RegistryUrl,
145+
nil,
146+
)
142147
if err != nil {
143148
return nil, err
144149
}

pkgmgr/state.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (s *State) saveFile(filename string, src any) error {
9494
// Create parent directory if it doesn't exist
9595
if _, err := os.Stat(s.config.ConfigDir); err != nil {
9696
if os.IsNotExist(err) {
97-
if err := os.MkdirAll(s.config.ConfigDir, 0700); err != nil {
97+
if err := os.MkdirAll(s.config.ConfigDir, 0o700); err != nil {
9898
return err
9999
}
100100
}
@@ -107,7 +107,7 @@ func (s *State) saveFile(filename string, src any) error {
107107
if err != nil {
108108
return err
109109
}
110-
if err := os.WriteFile(tmpPath, yamlContent, 0600); err != nil {
110+
if err := os.WriteFile(tmpPath, yamlContent, 0o600); err != nil {
111111
return err
112112
}
113113
return nil

0 commit comments

Comments
 (0)