Skip to content

Commit

Permalink
chore: Enable most govet linters
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Feb 25, 2023
1 parent 5fda8a4 commit 33c4c4b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
6 changes: 5 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ linters:
- promlinter
- reassign
- revive
- sqlclosecheck
- staticcheck
- stylecheck
- tagliatelle
Expand Down Expand Up @@ -115,6 +114,11 @@ linters-settings:
module-path: github.com/twpayne/chezmoi
goimports:
local-prefixes: github.com/twpayne/chezmoi
govet:
disable:
- fieldalignment
- shadow
enable-all: true
ireturn:
allow:
- anon
Expand Down
31 changes: 17 additions & 14 deletions pkg/cmd/cdcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,26 @@ func (c *Config) runCDCmd(cmd *cobra.Command, args []string) error {
var dir chezmoi.AbsPath
if len(args) == 0 {
dir = c.WorkingTreeAbsPath
} else if argAbsPath, err := chezmoi.NewAbsPathFromExtPath(args[0], c.homeDirAbsPath); err != nil {
return err
} else if argAbsPath == c.DestDirAbsPath {
dir, err = c.getSourceDirAbsPath(nil)
if err != nil {
return err
}
} else {
sourceState, err := c.getSourceState(cmd.Context())
if err != nil {
return err
}
sourceAbsPaths, err := c.sourceAbsPaths(sourceState, args)
if err != nil {
switch argAbsPath, err := chezmoi.NewAbsPathFromExtPath(args[0], c.homeDirAbsPath); {
case err != nil:
return err
case argAbsPath == c.DestDirAbsPath:
dir, err = c.getSourceDirAbsPath(nil)
if err != nil {
return err
}
default:
sourceState, err := c.getSourceState(cmd.Context())
if err != nil {
return err
}
sourceAbsPaths, err := c.sourceAbsPaths(sourceState, args)
if err != nil {
return err
}
dir = sourceAbsPaths[0]
}
dir = sourceAbsPaths[0]
}
return c.run(dir, cdCommand, cdArgs)
}
Expand Down
5 changes: 1 addition & 4 deletions pkg/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1827,7 +1827,7 @@ func (c *Config) persistentPreRunRootE(cmd *cobra.Command, args []string) error
// Do nothing.
case err == nil:
return fmt.Errorf("%s: not a directory", c.SourceDirAbsPath)
case err != nil:
default:
return err
}
}
Expand Down Expand Up @@ -2205,9 +2205,6 @@ func (c *Config) targetRelPaths(
if err != nil {
return nil, err
}
if err != nil {
return nil, err
}
if options.mustBeInSourceState {
if !sourceState.Contains(targetRelPath) {
return nil, fmt.Errorf("%s: not in source state", arg)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/keepassxctemplatefuncs.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func keepassxcParseOutput(output []byte) (map[string]string, error) {
case match != nil:
key = match[1]
data[key] = match[2]
case match == nil && key != "":
case key != "":
data[key] += "\n" + s.Text()
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/updatecmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ func (c *Config) runUpdateCmd(cmd *cobra.Command, args []string) error {
return err
}
default:
args := []string{
gitArgs := []string{
"pull",
"--autostash",
"--rebase",
}
if c.Update.RecurseSubmodules {
args = append(args,
gitArgs = append(gitArgs,
"--recurse-submodules",
)
}
if err := c.run(c.WorkingTreeAbsPath, c.Git.Command, args); err != nil {
if err := c.run(c.WorkingTreeAbsPath, c.Git.Command, gitArgs); err != nil {
return err
}
}
Expand Down

0 comments on commit 33c4c4b

Please sign in to comment.