Skip to content

Commit

Permalink
build: fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
  • Loading branch information
caarlos0 committed Apr 12, 2024
1 parent 60200f1 commit b22ddef
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 12 deletions.
15 changes: 14 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
run:
go: "1.21"
go: "1.22"
timeout: 5m
linters:
enable:
Expand All @@ -14,7 +14,13 @@ linters:
- tagliatelle
- misspell
- depguard
- testifylint
- gocritic
linters-settings:
staticcheck:
checks:
- all
- "-SA1019"
forbidigo:
forbid:
- 'ioutil\.*'
Expand All @@ -30,3 +36,10 @@ linters-settings:
deny:
- pkg: "github.com/pkg/errors"
desc: "use stdlib instead"
gocritic:
enabled-checks:
- exitAfterDefer
testifylint:
enable-all: true
disable:
- error-is-as # false positive
2 changes: 1 addition & 1 deletion cmd/chglog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func main() {
``)
_ = config.BindPFlag("config-file", cmdRoot.PersistentFlags().Lookup("config-file"))

cmdRoot.PersistentPreRunE = func(c *cobra.Command, args []string) error {
cmdRoot.PersistentPreRunE = func(*cobra.Command, []string) error {
if cfgFile == config.GetString("config-file") {
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions order_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ func (r *testRepo) modifyAndCommit(opts *git.CommitOptions) plumbing.Hash {
if file, err = r.Source.Filesystem.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0o666); err != nil {
log.Fatal(err)
}
defer file.Close()

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

if _, err = r.Source.Add(filename); err != nil {
log.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func AddCmd(config *viper.Viper) (cmd *cobra.Command) {
"",
"Footer note for this entry")

cmd.RunE = func(c *cobra.Command, args []string) (err error) {
cmd.RunE = func(_ *cobra.Command, args []string) (err error) {
var (
repoPath string
gitRepo *git.Repository
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func commonFlags(cmd *cobra.Command, config *viper.Viper) (*cobra.Command, *vipe
distribution,
`set debian distributions for`)

cmd.PreRunE = func(c *cobra.Command, args []string) error {
cmd.PreRunE = func(*cobra.Command, []string) error {
if err := config.BindPFlag("conventional-commits", cmd.Flags().Lookup("conventional-commits")); err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ func ConfigCmd(config *viper.Viper) (cmd *cobra.Command) {
"",
"package name to use in formatting")

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

cmd.RunE = func(c *cobra.Command, args []string) error {
cmd.RunE = func(*cobra.Command, []string) error {
// Filter some config settings
cfgMap := config.AllSettings()
delete(cfgMap, "app")
Expand Down
4 changes: 2 additions & 2 deletions pkg/commands/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ func FormatCmd(config *viper.Viper) (cmd *cobra.Command) {
"",
"custom template file to use")

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

cmd.RunE = func(c *cobra.Command, args []string) (err error) {
cmd.RunE = func(*cobra.Command, []string) (err error) {
var (
tpl *template.Template
data []byte
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func InitCmd(config *viper.Viper) (cmd *cobra.Command) {
"changelog.yml",
"file to save the new changelog to")

cmd.RunE = func(c *cobra.Command, args []string) (err error) {
cmd.RunE = func(_ *cobra.Command, args []string) (err error) {
var (
repoPath string
gitRepo *git.Repository
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func VersionCmd(config *viper.Viper) (cmd *cobra.Command) {
Use: "version",
Short: "display version info",
}
cmd.Run = func(c *cobra.Command, args []string) {
cmd.Run = func(*cobra.Command, []string) {
version := fmt.Sprintf("%s %s", config.GetString("app.name"), config.GetString("app.version"))
if config.GetBool("debug") {
version = fmt.Sprintf("%s+%s", version, config.GetString("app.commit"))
Expand Down

0 comments on commit b22ddef

Please sign in to comment.