Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lint warn #396

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion datastore/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
return err
}
}
return os.WriteFile(p, content, os.ModePerm)
return os.WriteFile(p, content, os.ModePerm) // #nosec
}

func (l *Local) FS() (fs.FS, error) {

Check failure on line 55 in datastore/local/local.go

View workflow job for this annotation

GitHub Actions / Test

[gostyle.mixedcaps] Go source code uses MixedCaps or mixedCaps (camel case) rather than underscores (snake case) when writing multi-word names. (ref: https://google.github.io/styleguide/go/guide#mixed-caps ): FS
return os.DirFS(l.root), nil
}
10 changes: 5 additions & 5 deletions ratio/copy_from_gocloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
2 changes: 1 addition & 1 deletion report/report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
Loading