Skip to content

Commit

Permalink
Bump golangci-lint to v1.42.0
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Aug 18, 2021
1 parent 137e07e commit 11d84ed
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ jobs:
- name: Lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.41.1
version: v1.42.0
- name: ShellCheck
uses: ludeeus/action-shellcheck@1.1.0
with:
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ linters:
- dupl
- durationcheck
- errcheck
- errname
- errorlint
- exportloopref
- forbidigo
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GO?=go
GOLANGCI_LINT_VERSION=1.41.1
GOLANGCI_LINT_VERSION=1.42.0

.PHONY: default
default: run build test lint format
Expand Down
2 changes: 1 addition & 1 deletion internal/chezmoi/actualstateentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func NewActualStateEntry(system System, absPath AbsPath, info fs.FileInfo, err e
}),
}, nil
default:
return nil, &errUnsupportedFileType{
return nil, &unsupportedFileTypeError{
absPath: absPath,
mode: info.Mode(),
}
Expand Down
16 changes: 8 additions & 8 deletions internal/chezmoi/chezmoi.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,43 +81,43 @@ var modeTypeNames = map[fs.FileMode]string{
fs.ModeCharDevice: "char device",
}

type errDuplicateTarget struct {
type duplicateTargetError struct {
targetRelPath RelPath
sourceRelPaths []SourceRelPath
}

func (e *errDuplicateTarget) Error() string {
func (e *duplicateTargetError) Error() string {
sourceRelPathStrs := make([]string, 0, len(e.sourceRelPaths))
for _, sourceRelPath := range e.sourceRelPaths {
sourceRelPathStrs = append(sourceRelPathStrs, sourceRelPath.String())
}
return fmt.Sprintf("%s: duplicate source state entries (%s)", e.targetRelPath, strings.Join(sourceRelPathStrs, ", "))
}

type errNotInAbsDir struct {
type notInAbsDirError struct {
pathAbsPath AbsPath
dirAbsPath AbsPath
}

func (e *errNotInAbsDir) Error() string {
func (e *notInAbsDirError) Error() string {
return fmt.Sprintf("%s: not in %s", e.pathAbsPath, e.dirAbsPath)
}

type errNotInRelDir struct {
type notInRelDirError struct {
pathRelPath RelPath
dirRelPath RelPath
}

func (e *errNotInRelDir) Error() string {
func (e *notInRelDirError) Error() string {
return fmt.Sprintf("%s: not in %s", e.pathRelPath, e.dirRelPath)
}

type errUnsupportedFileType struct {
type unsupportedFileTypeError struct {
absPath AbsPath
mode fs.FileMode
}

func (e *errUnsupportedFileType) Error() string {
func (e *unsupportedFileTypeError) Error() string {
return fmt.Sprintf("%s: unsupported file type %s", e.absPath, modeTypeName(e.mode))
}

Expand Down
6 changes: 3 additions & 3 deletions internal/chezmoi/mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ const (
ModeSymlink Mode = "symlink"
)

type errInvalidMode string
type invalidModeError string

func (e errInvalidMode) Error() string {
func (e invalidModeError) Error() string {
return "invalid mode: " + string(e)
}

Expand All @@ -24,7 +24,7 @@ func (m *Mode) Set(s string) error {
*m = ModeSymlink
return nil
default:
return errInvalidMode(Mode(s))
return invalidModeError(Mode(s))
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/chezmoi/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (p AbsPath) TrimDirPrefix(dirPrefixAbsPath AbsPath) (RelPath, error) {
dirAbsPath += "/"
}
if !strings.HasPrefix(string(p), string(dirAbsPath)) {
return "", &errNotInAbsDir{
return "", &notInAbsDirError{
pathAbsPath: p,
dirAbsPath: dirPrefixAbsPath,
}
Expand Down Expand Up @@ -128,7 +128,7 @@ func (p RelPath) Split() (RelPath, RelPath) {
// TrimDirPrefix trims prefix from p.
func (p RelPath) TrimDirPrefix(dirPrefix RelPath) (RelPath, error) {
if !p.HasDirPrefix(dirPrefix) {
return "", &errNotInRelDir{
return "", &notInRelDirError{
pathRelPath: p,
dirRelPath: dirPrefix,
}
Expand Down
6 changes: 3 additions & 3 deletions internal/chezmoi/sourcestate.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ func (s *SourceState) Read() error {
allSourceStateEntries[targetRelPath] = append(allSourceStateEntries[targetRelPath], sourceStateEntry)
return nil
default:
return &errUnsupportedFileType{
return &unsupportedFileTypeError{
absPath: sourceAbsPath,
mode: info.Mode(),
}
Expand Down Expand Up @@ -746,7 +746,7 @@ func (s *SourceState) Read() error {
sort.Slice(sourceRelPaths, func(i, j int) bool {
return sourceRelPaths[i].relPath < sourceRelPaths[j].relPath
})
err = multierr.Append(err, &errDuplicateTarget{
err = multierr.Append(err, &duplicateTargetError{
targetRelPath: targetRelPath,
sourceRelPaths: sourceRelPaths,
})
Expand Down Expand Up @@ -880,7 +880,7 @@ func (s *SourceState) addTemplatesDir(templatesDirAbsPath AbsPath) error {
case info.IsDir():
return nil
default:
return &errUnsupportedFileType{
return &unsupportedFileTypeError{
absPath: templateAbsPath,
mode: info.Mode(),
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/addcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (c *Config) defaultPreAddFunc(targetRelPath chezmoi.RelPath, newSourceState
case choice == "no":
return chezmoi.Skip
case choice == "quit":
return ErrExitCode(1)
return ExitCodeError(1)
case choice == "yes":
return nil
default:
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ var (
helps map[string]*help
)

// An ErrExitCode indicates the the main program should exit with the given
// An ExitCodeError indicates the the main program should exit with the given
// code.
type ErrExitCode int
type ExitCodeError int

func (e ErrExitCode) Error() string { return "" }
func (e ExitCodeError) Error() string { return "" }

// A VersionInfo contains a version.
type VersionInfo struct {
Expand Down Expand Up @@ -88,7 +88,7 @@ func Main(versionInfo VersionInfo, args []string) int {
if s := err.Error(); s != "" {
fmt.Fprintf(os.Stderr, "chezmoi: %s\n", s)
}
errExitCode := ErrExitCode(1)
errExitCode := ExitCodeError(1)
_ = errors.As(err, &errExitCode)
return int(errExitCode)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ func (c *Config) applyArgs(targetSystem chezmoi.System, targetDirAbsPath chezmoi
}
}
if keptGoingAfterErr {
return ErrExitCode(1)
return ExitCodeError(1)
}

return nil
Expand Down Expand Up @@ -611,7 +611,7 @@ func (c *Config) defaultPreApplyFunc(targetRelPath chezmoi.RelPath, targetEntryS
case choice == "skip":
return chezmoi.Skip
case choice == "quit":
return ErrExitCode(1)
return ExitCodeError(1)
default:
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/doctorcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func (c *Config) runDoctorCmd(cmd *cobra.Command, args []string) error {
resultWriter.Flush()

if worstResult > checkWarning {
return ErrExitCode(1)
return ExitCodeError(1)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/verifycmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (c *Config) runVerifyCmd(cmd *cobra.Command, args []string) error {
return err
}
if dryRunSystem.Modified() {
return ErrExitCode(1)
return ExitCodeError(1)
}
return nil
}

0 comments on commit 11d84ed

Please sign in to comment.