Skip to content

Commit

Permalink
refactor: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ayakovlenko committed Oct 30, 2024
1 parent 6bfe9fe commit 8ce04cf
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ linters:
- gomnd # deprecated
- execinquery # deprecated
- depguard
- gci

linters-settings:
varnamelen:
Expand Down
6 changes: 3 additions & 3 deletions cmd/zit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
func main() {
userHomeDir, err := os.UserHomeDir()
if err != nil {
fmt.Println(err)
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}

Expand All @@ -28,7 +28,7 @@ func main() {
os.Getenv(xdg.ConfigHome),
)

app := &cli.App{
app := &cli.App{ //nolint: exhaustruct
Name: appConfig.AppName(),
Usage: "git identity manager",
Commands: []*cli.Command{
Expand All @@ -40,7 +40,7 @@ func main() {
}

if err := app.Run(os.Args); err != nil {
fmt.Println(err)
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
28 changes: 23 additions & 5 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
#!/usr/bin/env sh
#!/usr/bin/env bash
set -e

MODULE=${MODULE:-"./..."}

if [ "$1" == "all" ]; then
golangci-lint run --config .golangci.yaml "$MODULE"
exit 0
golangci-lint run --config .golangci.yaml "$MODULE"
exit 0
fi

if [ "$1" == "only" ]; then
golangci-lint run --no-config --enable "$2" "$MODULE"
exit 0
golangci-lint run --no-config --enable "$2" "$MODULE"
exit 0
fi

if [ "$1" == "linted" ]; then
# The following packages are already linted and should stay this way.
#
# Should be replaced by simply `./lint all` in the future.
packages=(
'./cmd/zit/...'
'./internal/app/...'
'./pkg/xdg/...'
)

for package in "${packages[@]}"; do
echo "linting package $package"
golangci-lint run --config .golangci.yaml "$package"
done

exit 0
fi

echo "Usage:"
Expand Down

0 comments on commit 8ce04cf

Please sign in to comment.