Skip to content

Commit 9bb092b

Browse files
chenhaoxuaniseki0
authored andcommitted
fix: linter
1 parent 73dd92e commit 9bb092b

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

inspector/managed_inspect.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ import (
1212
"time"
1313
)
1414

15-
const BASEPATH = "basePath"
16-
1715
func setBasePath(ctx context.Context, path string) context.Context {
18-
return context.WithValue(ctx, BASEPATH, path)
16+
return context.WithValue(ctx, model.BasePathKey, path)
1917
}
2018
func ManagedInspect(ctx context.Context) error {
2119
var logger = logctx.Use(ctx)

model/base_path.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package model
2+
3+
type basePathKey struct{}
4+
5+
var BasePathKey = &basePathKey{}
6+
7+
func (basePathKey) String() string {
8+
return "basePath"
9+
}

module/go_mod/gopkg.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ func parseGopkgLock(dir string) (goPkgLock, error) {
2424
if err != nil {
2525
return m, err
2626
}
27-
toml.NewDecoder(file).Decode(&m)
27+
_, err = toml.NewDecoder(file).Decode(&m)
28+
if err != nil {
29+
return m, err
30+
}
2831
return m, nil
2932
}
3033
func parserGoPkgLock(ctx context.Context) error {

module/npm/checkWorkspace.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package npm
22

33
import (
44
"context"
5+
"github.com/murphysecurity/murphysec/model"
56
"os"
67
"path/filepath"
8+
"strings"
79
)
810

911
func getWorkspace(packagePath string, mp map[string]bool) error {
@@ -29,7 +31,7 @@ func getWorkspace(packagePath string, mp map[string]bool) error {
2931
return nil
3032
}
3133
func getGlobPath(ctx context.Context, dir string, mp map[string]bool) error {
32-
basePath := ctx.Value("basePath").(string)
34+
basePath := ctx.Value(model.BasePathKey).(string)
3335
if basePath != "" && filepath.Clean(filepath.Dir(basePath)) == filepath.Clean(dir) {
3436
return nil
3537
}
@@ -48,8 +50,8 @@ func skipWorkspaceDirectory(ctx context.Context, dir string) bool {
4850
if err := getGlobPath(ctx, dir, mp); err != nil {
4951
return false
5052
}
51-
for k, _ := range mp {
52-
if filepath.HasPrefix(k, dir) {
53+
for k := range mp {
54+
if strings.HasPrefix(k, dir) {
5355
return false
5456
}
5557
}

0 commit comments

Comments
 (0)