Skip to content

Commit f8a456c

Browse files
chore(ci): golint issues
Signed-off-by: Swarit Pandey <swarit@stepsecurity.io> chore: more golint issues - rebase this Signed-off-by: Swarit Pandey <swarit@stepsecurity.io>
1 parent ba8c71d commit f8a456c

14 files changed

Lines changed: 22 additions & 27 deletions

File tree

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
!docs/**/*.html
1919
!images/**/*.html
2020

21-
# Go build artifacts
22-
/stepsecurity-dev-machine-guard
21+
# Go build artifacts — never commit compiled binaries
22+
**/stepsecurity-dev-machine-guard
23+
*.exe
2324
dist/
2425

2526
# Temporary files

cmd/stepsecurity-dev-machine-guard/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func main() {
8484
}
8585

8686
case "install":
87-
fmt.Fprintf(os.Stdout, "StepSecurity Dev Machine Guard v%s\n\n", buildinfo.Version)
87+
_, _ = fmt.Fprintf(os.Stdout, "StepSecurity Dev Machine Guard v%s\n\n", buildinfo.Version)
8888
if runtime.GOOS == "windows" {
8989
log.Error("Scheduled scanning is not yet supported on Windows. Use the scan command directly.")
9090
os.Exit(1)
@@ -105,7 +105,7 @@ func main() {
105105
}
106106

107107
case "uninstall":
108-
fmt.Fprintf(os.Stdout, "StepSecurity Dev Machine Guard v%s\n\n", buildinfo.Version)
108+
_, _ = fmt.Fprintf(os.Stdout, "StepSecurity Dev Machine Guard v%s\n\n", buildinfo.Version)
109109
if runtime.GOOS == "windows" {
110110
log.Error("Scheduled scanning is not yet supported on Windows. Use the scan command directly.")
111111
os.Exit(1)
-11.5 MB
Binary file not shown.

internal/cli/cli.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ func Parse(args []string) (*Config, error) {
9393
case arg == "--verbose":
9494
cfg.Verbose = true
9595
case arg == "-v" || arg == "--version" || arg == "version":
96-
fmt.Fprintf(os.Stdout, "StepSecurity Dev Machine Guard v%s\n", buildinfo.VersionString())
96+
_, _ = fmt.Fprintf(os.Stdout, "StepSecurity Dev Machine Guard v%s\n", buildinfo.VersionString())
9797
os.Exit(0)
9898
case arg == "-h" || arg == "--help" || arg == "help":
9999
printHelp()
100100
os.Exit(0)
101101
default:
102-
return nil, fmt.Errorf("Unknown option: %s\nRun '%s --help' for usage information.", arg, filepath.Base(os.Args[0]))
102+
return nil, fmt.Errorf("unknown option: %s, run '%s --help' for usage information", arg, filepath.Base(os.Args[0]))
103103
}
104104
i++
105105
}
@@ -109,7 +109,7 @@ func Parse(args []string) (*Config, error) {
109109

110110
func printHelp() {
111111
name := filepath.Base(os.Args[0])
112-
fmt.Fprintf(os.Stdout, `StepSecurity Dev Machine Guard v%s
112+
_, _ = fmt.Fprintf(os.Stdout, `StepSecurity Dev Machine Guard v%s
113113
114114
Usage: %s [COMMAND] [OPTIONS]
115115

internal/detector/ide.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,6 @@ func readPlistVersion(ctx context.Context, exec executor.Executor, plistPath str
177177
return "unknown"
178178
}
179179

180-
// readAppVersion reads app version using platform-appropriate method.
181-
func readAppVersion(ctx context.Context, exec executor.Executor, darwinPlistPath, winAppName string) string {
182-
if exec.GOOS() == "windows" {
183-
return readRegistryVersion(ctx, exec, winAppName)
184-
}
185-
return readPlistVersion(ctx, exec, darwinPlistPath)
186-
}
187-
188180
// readRegistryVersion searches Windows Uninstall registry keys for DisplayVersion.
189181
func readRegistryVersion(ctx context.Context, exec executor.Executor, appName string) string {
190182
for _, root := range []string{

internal/detector/mcp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func stripJSONCComments(input []byte) []byte {
192192
// Block comment
193193
if i+1 < len(input) && input[i] == '/' && input[i+1] == '*' {
194194
i += 2
195-
for i+1 < len(input) && !(input[i] == '*' && input[i+1] == '/') {
195+
for i+1 < len(input) && (input[i] != '*' || input[i+1] != '/') {
196196
i++
197197
}
198198
i += 2 // skip */

internal/launchd/launchd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func Install(exec executor.Executor, log *progress.Logger) error {
8080
if err != nil {
8181
return fmt.Errorf("creating plist file: %w", err)
8282
}
83-
defer f.Close()
83+
defer func() { _ = f.Close() }()
8484

8585
tmpl, err := template.New("plist").Parse(plistTmpl)
8686
if err != nil {
@@ -136,7 +136,7 @@ func doUninstall(ctx context.Context, exec executor.Executor, log *progress.Logg
136136

137137
// Remove plist
138138
if exec.FileExists(plistPath) {
139-
os.Remove(plistPath)
139+
_ = os.Remove(plistPath)
140140
log.Progress("Removed plist file: %s", plistPath)
141141
}
142142

internal/lock/lock.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func Acquire(_ executor.Executor) (*Lock, error) {
4242
}
4343

4444
_, err = fmt.Fprintf(f, "%d", os.Getpid())
45-
f.Close()
45+
_ = f.Close()
4646
if err != nil {
4747
_ = os.Remove(lockFilePath)
4848
return nil, fmt.Errorf("writing PID to lock file: %w", err)

internal/output/html.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func HTML(outputFile string, result *model.ScanResult) error {
4141
if err != nil {
4242
return fmt.Errorf("creating HTML file: %w", err)
4343
}
44-
defer f.Close()
44+
defer func() { _ = f.Close() }()
4545

4646
scanTime := time.Unix(result.ScanTimestamp, 0).Format("2006-01-02 15:04:05")
4747

internal/output/html_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
func TestHTML_GeneratesFile(t *testing.T) {
1212
tmpFile := os.TempDir() + "/test-dmg-report.html"
13-
defer os.Remove(tmpFile)
13+
defer func() { _ = os.Remove(tmpFile) }()
1414

1515
result := &model.ScanResult{
1616
AgentVersion: "1.9.0",
@@ -55,7 +55,7 @@ func TestHTML_GeneratesFile(t *testing.T) {
5555

5656
func TestHTML_ContainsData(t *testing.T) {
5757
tmpFile := os.TempDir() + "/test-dmg-data.html"
58-
defer os.Remove(tmpFile)
58+
defer func() { _ = os.Remove(tmpFile) }()
5959

6060
result := &model.ScanResult{
6161
ScanTimestamp: 1700000000,

0 commit comments

Comments
 (0)