Skip to content

Commit b22ddef

Browse files
committed
build: fix lint
Signed-off-by: Carlos Alexandro Becker <[email protected]>
1 parent 60200f1 commit b22ddef

File tree

9 files changed

+25
-12
lines changed

9 files changed

+25
-12
lines changed

.golangci.yaml

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
run:
2-
go: "1.21"
2+
go: "1.22"
33
timeout: 5m
44
linters:
55
enable:
@@ -14,7 +14,13 @@ linters:
1414
- tagliatelle
1515
- misspell
1616
- depguard
17+
- testifylint
18+
- gocritic
1719
linters-settings:
20+
staticcheck:
21+
checks:
22+
- all
23+
- "-SA1019"
1824
forbidigo:
1925
forbid:
2026
- 'ioutil\.*'
@@ -30,3 +36,10 @@ linters-settings:
3036
deny:
3137
- pkg: "github.com/pkg/errors"
3238
desc: "use stdlib instead"
39+
gocritic:
40+
enabled-checks:
41+
- exitAfterDefer
42+
testifylint:
43+
enable-all: true
44+
disable:
45+
- error-is-as # false positive

cmd/chglog/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func main() {
3535
``)
3636
_ = config.BindPFlag("config-file", cmdRoot.PersistentFlags().Lookup("config-file"))
3737

38-
cmdRoot.PersistentPreRunE = func(c *cobra.Command, args []string) error {
38+
cmdRoot.PersistentPreRunE = func(*cobra.Command, []string) error {
3939
if cfgFile == config.GetString("config-file") {
4040
return nil
4141
}

order_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ func (r *testRepo) modifyAndCommit(opts *git.CommitOptions) plumbing.Hash {
5858
if file, err = r.Source.Filesystem.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0o666); err != nil {
5959
log.Fatal(err)
6060
}
61-
defer file.Close()
6261

63-
if _, err = file.Write([]byte(fmt.Sprintf("commit %d\n", r.seqno))); err != nil {
62+
if _, err = fmt.Fprintf(file, "commit %d\n", r.seqno); err != nil {
6463
log.Fatal(err)
6564
}
65+
_ = file.Close()
6666

6767
if _, err = r.Source.Add(filename); err != nil {
6868
log.Fatal(err)

pkg/commands/add.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func AddCmd(config *viper.Viper) (cmd *cobra.Command) {
7575
"",
7676
"Footer note for this entry")
7777

78-
cmd.RunE = func(c *cobra.Command, args []string) (err error) {
78+
cmd.RunE = func(_ *cobra.Command, args []string) (err error) {
7979
var (
8080
repoPath string
8181
gitRepo *git.Repository

pkg/commands/commands.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func commonFlags(cmd *cobra.Command, config *viper.Viper) (*cobra.Command, *vipe
4545
distribution,
4646
`set debian distributions for`)
4747

48-
cmd.PreRunE = func(c *cobra.Command, args []string) error {
48+
cmd.PreRunE = func(*cobra.Command, []string) error {
4949
if err := config.BindPFlag("conventional-commits", cmd.Flags().Lookup("conventional-commits")); err != nil {
5050
return err
5151
}

pkg/commands/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ func ConfigCmd(config *viper.Viper) (cmd *cobra.Command) {
2020
"",
2121
"package name to use in formatting")
2222

23-
cmd.PreRunE = func(cmd *cobra.Command, args []string) error {
23+
cmd.PreRunE = func(cmd *cobra.Command, _ []string) error {
2424
return config.BindPFlag("package-name", cmd.Flags().Lookup("package-name"))
2525
}
2626

27-
cmd.RunE = func(c *cobra.Command, args []string) error {
27+
cmd.RunE = func(*cobra.Command, []string) error {
2828
// Filter some config settings
2929
cfgMap := config.AllSettings()
3030
delete(cfgMap, "app")

pkg/commands/format.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ func FormatCmd(config *viper.Viper) (cmd *cobra.Command) {
5858
"",
5959
"custom template file to use")
6060

61-
cmd.PreRunE = func(cmd *cobra.Command, args []string) error {
61+
cmd.PreRunE = func(cmd *cobra.Command, _ []string) error {
6262
return config.BindPFlag("package-name", cmd.Flags().Lookup("package-name"))
6363
}
6464

65-
cmd.RunE = func(c *cobra.Command, args []string) (err error) {
65+
cmd.RunE = func(*cobra.Command, []string) (err error) {
6666
var (
6767
tpl *template.Template
6868
data []byte

pkg/commands/init.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func InitCmd(config *viper.Viper) (cmd *cobra.Command) {
3131
"changelog.yml",
3232
"file to save the new changelog to")
3333

34-
cmd.RunE = func(c *cobra.Command, args []string) (err error) {
34+
cmd.RunE = func(_ *cobra.Command, args []string) (err error) {
3535
var (
3636
repoPath string
3737
gitRepo *git.Repository

pkg/commands/version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func VersionCmd(config *viper.Viper) (cmd *cobra.Command) {
1212
Use: "version",
1313
Short: "display version info",
1414
}
15-
cmd.Run = func(c *cobra.Command, args []string) {
15+
cmd.Run = func(*cobra.Command, []string) {
1616
version := fmt.Sprintf("%s %s", config.GetString("app.name"), config.GetString("app.version"))
1717
if config.GetBool("debug") {
1818
version = fmt.Sprintf("%s+%s", version, config.GetString("app.commit"))

0 commit comments

Comments
 (0)