Skip to content

Commit d7e0397

Browse files
fix linter issues
1 parent e6b0fac commit d7e0397

File tree

9 files changed

+20
-20
lines changed

9 files changed

+20
-20
lines changed

engine/engine.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,10 @@ func GetRulesCommand(engineConfig *EngineConfig) *cobra.Command {
290290

291291
tab := tabwriter.NewWriter(os.Stdout, 1, 2, 2, ' ', 0)
292292

293-
fmt.Fprintln(tab, "Name\tDescription\tTags\tValidity Check")
294-
fmt.Fprintln(tab, "----\t----\t----\t----")
293+
fmt.Fprintln(tab, "Name\tDescription\tTags\tValidity Check") //nolint:errcheck
294+
fmt.Fprintln(tab, "----\t----\t----\t----") //nolint:errcheck
295295
for _, rule := range *rules {
296-
fmt.Fprintf(
296+
fmt.Fprintf( //nolint:errcheck
297297
tab,
298298
"%s\t%s\t%s\t%s\n",
299299
rule.Rule.RuleID,
@@ -352,7 +352,8 @@ func getStartAndEndLines(ctx context.Context, pluginName string, gitInfo *plugin
352352
var startLine, endLine int
353353
var err error
354354

355-
if pluginName == "filesystem" {
355+
switch pluginName {
356+
case "filesystem":
356357
totalLines, totalOK := ctx.Value(totalLinesKey).(int)
357358
chunkLines, chunkOK := ctx.Value(linesInChunkKey).(int)
358359

@@ -363,12 +364,12 @@ func getStartAndEndLines(ctx context.Context, pluginName string, gitInfo *plugin
363364

364365
startLine = value.StartLine + offset
365366
endLine = value.EndLine + offset
366-
} else if pluginName == "git" {
367+
case "git":
367368
startLine, endLine, err = plugins.GetGitStartAndEndLine(gitInfo, value.StartLine, value.EndLine)
368369
if err != nil {
369370
return 0, 0, err
370371
}
371-
} else {
372+
default:
372373
startLine = value.StartLine
373374
endLine = value.EndLine
374375
}

engine/engine_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ func writeTempFile(t *testing.T, dir string, size int, content []byte) string {
470470

471471
f, err := os.CreateTemp(dir, "testfile-*.tmp")
472472
require.NoError(t, err, "create temp file")
473-
defer f.Close()
473+
defer f.Close() //nolint:errcheck
474474

475475
var data []byte
476476
if content != nil {

lib/reporting/report_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,6 @@ func TestWriteReportInNonExistingDir(t *testing.T) {
221221
if err != nil {
222222
t.Error(err)
223223
}
224-
225-
os.RemoveAll(filepath.Join(tempDir, "test_temp_dir"))
226224
}
227225

228226
func TestGetOutputSarif(t *testing.T) {

lib/utils/flags_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ subcommand:
685685
var configFileName string
686686
if tc.config != nil {
687687
configFileName = writeTempFile(t, tc.config, tc.configFormat)
688-
defer os.Remove(configFileName)
688+
defer os.Remove(configFileName) //nolint:errcheck
689689

690690
tc.args = append(tc.args, "--"+configFlagName, configFileName)
691691
}

lib/utils/http.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func HttpRequest(method string, url string, authorization IAuthorizationHeader,
4343
return nil, response, fmt.Errorf("unable to send http request %w", err)
4444
}
4545

46-
defer response.Body.Close()
46+
defer response.Body.Close() //nolint:errcheck
4747

4848
if response.StatusCode < 200 || response.StatusCode >= 300 {
4949
if retry.MaxRetries > 0 {

plugins/git.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (p *GitPlugin) DefineCommand(items chan ISourceItem, errors chan error) (*c
5858
Args: cobra.MatchAll(cobra.ExactArgs(1), validGitRepoArgs),
5959
Run: func(cmd *cobra.Command, args []string) {
6060
log.Info().Msg("Git plugin started")
61-
p.scanGit(args[0], p.buildScanOptions(), p.Channels.Items, p.Channels.Errors)
61+
p.scanGit(args[0], p.buildScanOptions(), p.Items, p.Errors)
6262
p.WaitGroup.Wait()
6363
close(items)
6464
},

plugins/paligo.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (p *PaligoPlugin) DefineCommand(items chan ISourceItem, errors chan error)
7373
Run: func(cmd *cobra.Command, args []string) {
7474
// Waits for MarkFlagsOneRequired https://github.com/spf13/cobra/pull/1952
7575
if p.auth == "" && (p.username == "" || p.token == "") {
76-
p.Channels.Errors <- fmt.Errorf("exactly one of the flags in the group %v must be set; none were set", []string{paligoAuthFlag, paligoUsernameFlag, paligoTokenFlag})
76+
p.Errors <- fmt.Errorf("exactly one of the flags in the group %v must be set; none were set", []string{paligoAuthFlag, paligoUsernameFlag, paligoTokenFlag})
7777
return
7878
}
7979
log.Info().Msg("Paligo plugin started")
@@ -107,7 +107,7 @@ func (p *PaligoPlugin) getItems() {
107107

108108
foldersToProcess, err := p.getFirstProcessingFolders()
109109
if err != nil {
110-
p.Channels.Errors <- err
110+
p.Errors <- err
111111
return
112112
}
113113

@@ -156,14 +156,15 @@ func (p *PaligoPlugin) processFolders(foldersToProcess []PaligoItem) chan Paligo
156156
folderInfo, err := p.paligoApi.showFolder(folder.ID)
157157
if err != nil {
158158
log.Error().Err(err).Msgf("error while getting %s '%s'", folder.Type, folder.Name)
159-
p.Channels.Errors <- err
159+
p.Errors <- err
160160
continue
161161
}
162162

163163
for _, child := range folderInfo.Children {
164-
if child.Type == "component" {
164+
switch child.Type {
165+
case "component":
165166
itemsChan <- child
166-
} else if child.Type == "folder" {
167+
case "folder":
167168
foldersToProcess = append(foldersToProcess, child)
168169
}
169170
}
@@ -180,7 +181,7 @@ func (p *PaligoPlugin) handleComponent(paligoItem PaligoItem) {
180181
document, err := p.paligoApi.showDocument(paligoItem.ID)
181182
if err != nil {
182183
log.Error().Err(err).Msgf("error while getting document '%s'", paligoItem.Name)
183-
p.Channels.Errors <- fmt.Errorf("error while getting document '%s': %w", paligoItem.Name, err)
184+
p.Errors <- fmt.Errorf("error while getting document '%s': %w", paligoItem.Name, err)
184185
return
185186
}
186187

plugins/slack.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (p *SlackPlugin) DefineCommand(items chan ISourceItem, errors chan error) (
5252
Long: "Scan Slack team for sensitive information.",
5353
Run: func(cmd *cobra.Command, args []string) {
5454
p.getItems()
55-
p.Channels.WaitGroup.Wait()
55+
p.WaitGroup.Wait()
5656
close(items)
5757
},
5858
}

tests/lint.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func lintFile(path string) error {
6666
if err != nil {
6767
return err
6868
}
69-
defer file.Close()
69+
defer file.Close() //nolint:errcheck
7070

7171
scanner := bufio.NewScanner(file)
7272
line := 1

0 commit comments

Comments
 (0)