diff --git a/cmd/root.go b/cmd/root.go index 5f609d3f..730995f7 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -451,7 +451,7 @@ var rootCmd = &cobra.Command{ if err != nil { return err } - if err := os.WriteFile(rp, r.Bytes(), os.ModePerm); err != nil { + if err := os.WriteFile(rp, r.Bytes(), os.ModePerm); err != nil { //nolint:gosec return err } addPaths = append(addPaths, rp) diff --git a/datastore/local/local.go b/datastore/local/local.go index 4c43e54b..472539ea 100644 --- a/datastore/local/local.go +++ b/datastore/local/local.go @@ -49,7 +49,7 @@ func (l *Local) Put(ctx context.Context, path string, content []byte) error { return err } } - return os.WriteFile(p, content, os.ModePerm) + return os.WriteFile(p, content, os.ModePerm) // #nosec } func (l *Local) FS() (fs.FS, error) { diff --git a/ratio/copy_from_gocloc.go b/ratio/copy_from_gocloc.go index adbae116..62337c44 100644 --- a/ratio/copy_from_gocloc.go +++ b/ratio/copy_from_gocloc.go @@ -26,9 +26,9 @@ var shebang2ext = map[string]string{ "escript": "erl", } -func getShebang(line string) (shebangLang string, ok bool) { +func getShebang(line string) (shebangLang string, ok bool) { //nostyle:getters ret := reShebangEnv.FindAllStringSubmatch(line, -1) - if ret != nil && len(ret[0]) == 3 { + if ret != nil && len(ret[0]) == 3 { //nostyle:nilslices shebangLang = ret[0][2] if sl, ok := shebang2ext[shebangLang]; ok { return sl, ok @@ -37,7 +37,7 @@ func getShebang(line string) (shebangLang string, ok bool) { } ret = reShebangLang.FindAllStringSubmatch(line, -1) - if ret != nil && len(ret[0]) >= 2 { + if ret != nil && len(ret[0]) >= 2 { //nostyle:nilslices shebangLang = ret[0][1] if sl, ok := shebang2ext[shebangLang]; ok { return sl, ok @@ -48,7 +48,7 @@ func getShebang(line string) (shebangLang string, ok bool) { return "", false } -func getFileTypeByShebang(path string) (shebangLang string, ok bool) { +func getFileTypeByShebang(path string) (shebangLang string, ok bool) { //nostyle:getters f, err := os.Open(path) if err != nil { return // ignore error @@ -68,7 +68,7 @@ func getFileTypeByShebang(path string) (shebangLang string, ok bool) { return } -func getFileType(path string) (ext string, ok bool) { +func getFileType(path string) (ext string, ok bool) { //nostyle:getters ext = filepath.Ext(path) base := filepath.Base(path) diff --git a/report/report.go b/report/report.go index da587dc0..e2c1d385 100644 --- a/report/report.go +++ b/report/report.go @@ -583,7 +583,7 @@ func (r *Report) convertFormat(v any) string { } return fmt.Sprintf("%.1f", floor1(vv)) default: - panic(fmt.Errorf("convert format error .Unknown type:%v", vv)) + panic(fmt.Errorf("convert format error .Unknown type:%v", vv)) //nostyle:dontpanic } } diff --git a/report/report_test.go b/report/report_test.go index 4828908c..73ae88ad 100644 --- a/report/report_test.go +++ b/report/report_test.go @@ -249,7 +249,7 @@ func TestCollectCustomMetrics(t *testing.T) { if err != nil { t.Fatal(err) } - if err := os.WriteFile(filepath.Join(testdataDir(t), "custom_metrics", fmt.Sprintf("%s.json", m.Key)), b, os.ModePerm); err != nil { + if err := os.WriteFile(filepath.Join(testdataDir(t), "custom_metrics", fmt.Sprintf("%s.json", m.Key)), b, 0600); err != nil { t.Fatal(err) } }