Skip to content

Commit

Permalink
pin golangci-lint version to latest available, fix reported errors
Browse files Browse the repository at this point in the history
  • Loading branch information
paskal authored and umputun committed Nov 7, 2024
1 parent 381c896 commit 734d6eb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
version: v1.58

- name: install goveralls
run: go install github.com/mattn/goveralls@latest
Expand Down
72 changes: 4 additions & 68 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
run:
modules-download-mode: vendor
concurrency: 4
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 10m
Expand All @@ -10,59 +9,11 @@ run:
# include test files or not, default is true
tests: true

# list of build tags, all linters use it. Default is empty list.
# build-tags:
# - mytag

# which dirs to skip: issues from them won't be reported;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but default dirs are skipped independently
# from this option's value (see skip-dirs-use-default).
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
# skip-dirs:
# - src/external_libs
# - autogenerated_by_my_lib

# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true

# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
# autogenerated files. If it's not please let us know.
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
# skip-files:
# - ".*\\.my\\.go$"
# - lib/bad.go

# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
# to go.mod are needed. This setting is most useful to check that go.mod does
# not need updates, such as in a continuous integration and testing system.
# If invoked with -mod=vendor, the go command assumes that the vendor
# directory holds the correct copies of dependencies and ignores
# the dependency descriptions in go.mod.
# modules-download-mode: readonly|vendor|mod

# Allow multiple parallel golangci-lint instances running.
# If false (default) - golangci-lint acquires file lock on start.
allow-parallel-runners: false

# Define the Go version limit.
# Mainly related to generics support in go1.18.
# Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.17
go: '1.22'


linters:
enable-all: true
enable-all: false
disable:
- deadcode # [deprecated]: Finds unused code [fast: false, auto-fix: false]
- depguard # : Go linter that checks if package imports are in a list of acceptable packages
- unused
- exhaustivestruct # [deprecated]: Checks if all struct's fields are initialized [fast: false, auto-fix: false]
- godot # : Check if comments end in a period [fast: true, auto-fix: true]
- godox # : Tool for detection of FIXME, TODO and other comment keywords [fast: true, auto-fix: false]
Expand All @@ -76,30 +27,16 @@ linters:
- nosnakecase # [deprecated]: Checks that no snake_case names are used [fast: true, auto-fix: false]
- paralleltest # : paralleltest detects missing usage of t.Parallel() method in your Go test [fast: true, auto-fix: false]
- scopelint # [deprecated]: Scopelint checks for unpinned variables in go programs [fast: false, auto-fix: false]
- structcheck # [deprecated]: Finds unused struct fields [fast: false, auto-fix: false]
- varcheck # [deprecated]: Finds unused global variables and constants [fast: false, auto-fix: false]
- unused # [deprecated]: Finds unused struct fields [fast: false, auto-fix: false]
- unused # [deprecated]: Finds unused global variables and constants [fast: false, auto-fix: false]
- varnamelen #: checks that the length of a variable's name matches its scope [fast: false, auto-fix: false]
- wsl # : Whitespace Linter - Forces you to use empty lines! [fast: true, auto-fix: false]

# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions
# default is "colored-line-number"
formats:
- format: colored-line-number

# print lines of code with issue, default is true
print-issued-lines: false

# print linter name in the end of issue text, default is true
print-linter-name: true

# make issues output unique by line, default is true
# uniq-by-line: true

# add a prefix to the output file references; default is no prefix
# path-prefix: ""

# sorts results by: filepath, line and column
sort-results: true

Expand Down Expand Up @@ -131,7 +68,6 @@ linters-settings:
- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
skip-generated: false
custom-order: true
revive:

tagalign:
order:
Expand Down
14 changes: 7 additions & 7 deletions app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
)

var opts struct { //nolint:gochecknoglobals
Stream string `default:"https://stream.radio-t.com" description:"Stream url" env:"STREAM" long:"stream" short:"s"`
Site string `default:"https://radio-t.com/site-api/last/1" description:"Radio-t API" env:"SITE" long:"site"`
Dir string `default:"./" description:"Recording directory" env:"DIR" long:"dir" short:"d"`
Port string `description:"If provided will start API server on the port otherwise server is disabled" env:"PORT" long:"port" short:"p"`
Stream string `default:"https://stream.radio-t.com" description:"Stream url" env:"STREAM" long:"stream" short:"s"`
Site string `default:"https://radio-t.com/site-api/last/1" description:"Radio-t API" env:"SITE" long:"site"`
Dir string `default:"./" description:"Recording directory" env:"DIR" long:"dir" short:"d"`
Port string `description:"If provided will start API server on the port otherwise server is disabled" env:"PORT" long:"port" short:"p"`
}

var revision = "local" //nolint: gochecknoglobals
Expand All @@ -32,7 +32,7 @@ func main() {
}

if _, err := flags.Parse(&opts); err != nil {
slog.Error("[ERROR] failed to parse flags: %v", err)
slog.Error("failed to parse flags", slog.String("err", err.Error()))
os.Exit(1)
}

Expand Down Expand Up @@ -84,12 +84,12 @@ func run(ctx context.Context, l *recorder.Listener, r *recorder.Recorder) {
slog.Debug("stream is not available")

case err != nil:
slog.Error("error while listening", err)
slog.Error("error while listening", slog.String("err", err.Error()))

default:
err = r.Record(ctx, stream)
if err != nil {
slog.Error("error while recording", err)
slog.Error("error while recording", slog.String("err", err.Error()))
return
}
}
Expand Down

0 comments on commit 734d6eb

Please sign in to comment.