Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: golangci/golangci-lint-action@v6.5.1
- uses: golangci/golangci-lint-action@v7.0.0
with:
args: --config .golangci.yml
36 changes: 28 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
version: "2"
run:
# Timeout for analysis, e.g. 30s, 5m.
# Default: 1m
Expand All @@ -12,16 +13,35 @@ linters:
- gocyclo
# Inspects source code for security problems.
- gosec
linters-settings:
gocyclo:
# Minimal code complexity to report.
# https://github.com/fzipp/gocyclo#readme
min-complexity: 28
gosec:
excludes:
- G115
settings:
gocyclo:
# Minimal code complexity to report.
# https://github.com/fzipp/gocyclo#readme
min-complexity: 28
gosec:
excludes:
# Ignore controversial integer overflow warnings.
- G115
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
issues:
# Disable max issues per linter.
max-issues-per-linter: 0
# Disable max same issues.
max-same-issues: 0
formatters:
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
2 changes: 1 addition & 1 deletion internal/command/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func getOptions(args []string, log Logger, mopts ...MetaOption) optionsFlags {
}
}

if opts.ShowGUID && !(_platform.Equal(opts.SourceType) || _all.Equal(opts.SourceType) || _default.Equal(opts.SourceType)) {
if opts.ShowGUID && !_platform.Equal(opts.SourceType) && !_all.Equal(opts.SourceType) && !_default.Equal(opts.SourceType) {
log.Fatalf("Source type must be 'platform' when using the --guid flag")
}

Expand Down
12 changes: 6 additions & 6 deletions internal/command/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@ func newQueryOptions(cli plugin.CliConnection, args []string, log Logger) (query
}

if len(args) != 1 {
return queryOptions{}, fmt.Errorf("Expected 1 argument, got %d.", len(args))
return queryOptions{}, fmt.Errorf("expected 1 argument, got %d", len(args))
}

if isInstantQuery(opts) && !validInstantQueryArgs(opts) {
return queryOptions{}, errors.New("When issuing an instant query, you cannot specify --start, --end, or --step")
return queryOptions{}, errors.New("when issuing an instant query, you cannot specify --start, --end, or --step")
}

if isRangeQuery(opts) && !validRangeQueryArgs(opts) {
return queryOptions{}, errors.New("When issuing a range query, you must specify all of --start, --end, and --step")
return queryOptions{}, errors.New("when issuing a range query, you must specify all of --start, --end, and --step")
}

if isInstantQuery(opts) {
Expand All @@ -150,7 +150,7 @@ func newQueryOptions(cli plugin.CliConnection, args []string, log Logger) (query

parsedTime, err := getParsedTime(opts.Time)
if err != nil {
return queryOptions{}, fmt.Errorf("Couldn't parse --time: %s", err.Error())
return queryOptions{}, fmt.Errorf("couldn't parse --time: %s", err.Error())
}

return queryOptions{timeProvided: true, time: parsedTime}, nil
Expand All @@ -159,11 +159,11 @@ func newQueryOptions(cli plugin.CliConnection, args []string, log Logger) (query
if isRangeQuery(opts) {
parsedStart, err := getParsedTime(opts.Start)
if err != nil {
return queryOptions{}, fmt.Errorf("Couldn't parse --start: %s", err.Error())
return queryOptions{}, fmt.Errorf("couldn't parse --start: %s", err.Error())
}
parsedEnd, err := getParsedTime(opts.End)
if err != nil {
return queryOptions{}, fmt.Errorf("Couldn't parse --end: %s", err.Error())
return queryOptions{}, fmt.Errorf("couldn't parse --end: %s", err.Error())
}

return queryOptions{start: parsedStart, end: parsedEnd, step: opts.Step, rangeQuery: true}, nil
Expand Down
8 changes: 4 additions & 4 deletions internal/command/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var _ = Describe("LogCache", func() {
}).To(Panic())

Expect(tc.logger.fatalfMessage).To(HavePrefix(
"When issuing a range query, you must specify all of --start, --end, and --step",
"when issuing a range query, you must specify all of --start, --end, and --step",
))
})

Expand All @@ -85,7 +85,7 @@ var _ = Describe("LogCache", func() {
}).To(Panic())

Expect(tc.logger.fatalfMessage).To(HavePrefix(
"When issuing an instant query, you cannot specify --start, --end, or --step",
"when issuing an instant query, you cannot specify --start, --end, or --step",
))
})

Expand Down Expand Up @@ -152,7 +152,7 @@ var _ = Describe("LogCache", func() {
}).To(Panic())

Expect(tc.logger.fatalfMessage).To(HavePrefix(
fmt.Sprintf("Couldn't parse --time: invalid time format: %s", timeArg),
fmt.Sprintf("couldn't parse --time: invalid time format: %s", timeArg),
))
},
Entry("with an arbitary string", "asdfkj"),
Expand Down Expand Up @@ -229,7 +229,7 @@ var _ = Describe("LogCache", func() {
}).To(Panic())

Expect(tc.logger.fatalfMessage).To(HavePrefix(
fmt.Sprintf("Couldn't parse --%s: invalid time format: %s", invalidField, invalidArg),
fmt.Sprintf("couldn't parse --%s: invalid time format: %s", invalidField, invalidArg),
))
},
Entry("with an arbitary string for start", "start", "asdfkj"),
Expand Down
10 changes: 5 additions & 5 deletions internal/command/tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,11 @@ func newTailOptions(cli plugin.CliConnection, args []string, log Logger) (tailOp
}

if len(args) != 1 {
return tailOptions{}, fmt.Errorf("Expected 1 argument, got %d.", len(args))
return tailOptions{}, fmt.Errorf("expected 1 argument, got %d", len(args))
}

if opts.JSONOutput && opts.OutputFormat != "" {
return tailOptions{}, errors.New("Cannot use output-format and json flags together")
return tailOptions{}, errors.New("cannot use output-format and json flags together")
}

if opts.EnvelopeType != "" && opts.EnvelopeClass != "" {
Expand Down Expand Up @@ -331,16 +331,16 @@ func typeFilter(e *loggregator_v2.Envelope, o tailOptions) bool {

func (o tailOptions) validate() error {
if o.startTime.After(o.endTime) && o.endTime != time.Unix(0, 0) {
return errors.New("Invalid date/time range. Ensure your start time is prior or equal the end time.")
return errors.New("invalid date/time range. Ensure your start time is prior or equal the end time")
}

if o.lines > 1000 || o.lines < 0 {
return errors.New("Lines cannot be greater than 1000.")
return errors.New("lines cannot be greater than 1000")
}

_, err := regexp.Compile(o.nameFilter)
if err != nil {
return fmt.Errorf("Invalid name filter '%s'. Ensure your name-filter is a valid regex.", o.nameFilter)
return fmt.Errorf("invalid name filter '%s'. Ensure your name-filter is a valid regex", o.nameFilter)
}

return nil
Expand Down
12 changes: 6 additions & 6 deletions internal/command/tail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,7 @@ var _ = Describe("LogCache", func() {
)
}).To(Panic())

Expect(logger.fatalfMessage).To(Equal("Cannot use output-format and json flags together"))
Expect(logger.fatalfMessage).To(Equal("cannot use output-format and json flags together"))
})

It("fatally logs if an output-format is malformed", func() {
Expand Down Expand Up @@ -1158,7 +1158,7 @@ var _ = Describe("LogCache", func() {
)
}).To(Panic())

Expect(logger.fatalfMessage).To(Equal("Lines cannot be greater than 1000."))
Expect(logger.fatalfMessage).To(Equal("lines cannot be greater than 1000"))
})

It("accepts 0 for --lines", func() {
Expand Down Expand Up @@ -1245,7 +1245,7 @@ var _ = Describe("LogCache", func() {
)
}).To(Panic())

Expect(logger.fatalfMessage).To(Equal("Invalid date/time range. Ensure your start time is prior or equal the end time."))
Expect(logger.fatalfMessage).To(Equal("invalid date/time range. Ensure your start time is prior or equal the end time"))
})

It("fatally logs if the name-filter regex is invalid", func() {
Expand All @@ -1261,7 +1261,7 @@ var _ = Describe("LogCache", func() {
)
}).To(Panic())

Expect(logger.fatalfMessage).To(Equal("Invalid name filter '*foo'. Ensure your name-filter is a valid regex."))
Expect(logger.fatalfMessage).To(Equal("invalid name filter '*foo'. Ensure your name-filter is a valid regex"))
})

It("fatally logs if too many arguments are given", func() {
Expand All @@ -1276,7 +1276,7 @@ var _ = Describe("LogCache", func() {
)
}).To(Panic())

Expect(logger.fatalfMessage).To(Equal("Expected 1 argument, got 2."))
Expect(logger.fatalfMessage).To(Equal("expected 1 argument, got 2"))
})

It("fatally logs if not enough arguments are given", func() {
Expand All @@ -1291,7 +1291,7 @@ var _ = Describe("LogCache", func() {
)
}).To(Panic())

Expect(logger.fatalfMessage).To(Equal("Expected 1 argument, got 0."))
Expect(logger.fatalfMessage).To(Equal("expected 1 argument, got 0"))
})

Context("when name-filter argument is not supplied", func() {
Expand Down
Loading