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
49 changes: 28 additions & 21 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
run:
timeout: 2m

version: "2"
linters:
enable:
- revive

issues:
exclude-rules:
- linters:
- staticcheck
text: "SA(4003|1019|5011):"
include:
- EXC0012
- EXC0014

linters-settings:
errcheck:
exclude-functions:
- "fmt.Fprintf"
- "fmt.Fprint"
- "(net/http.ResponseWriter).Write"
settings:
errcheck:
exclude-functions:
- fmt.Fprintf
- fmt.Fprint
- (net/http.ResponseWriter).Write
exclusions:
generated: lax
presets:
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- staticcheck
text: 'SA(4003|1019|5011):'
paths:
- third_party$
- builtin$
- examples$
formatters:
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ endif
GO_BUILDINFO = -X '$(PKG_PREFIX)/lib/buildinfo.Version=$(APP_NAME)-$(DATEINFO_TAG)-$(BUILDINFO_TAG)'
TAR_OWNERSHIP ?= --owner=1000 --group=1000

GOLANGCI_LINT_VERSION := 2.2.1

.PHONY: $(MAKECMDGOALS)

include app/*/Makefile
Expand Down Expand Up @@ -330,7 +332,7 @@ golangci-lint: install-golangci-lint
GOEXPERIMENT=synctest golangci-lint run

install-golangci-lint:
which golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.64.7
which golangci-lint && (golangci-lint --version | grep -q $(GOLANGCI_LINT_VERSION)) || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v$(GOLANGCI_LINT_VERSION)

remove-golangci-lint:
rm -rf `which golangci-lint`
Expand Down
2 changes: 1 addition & 1 deletion app/vlagent/remotewrite/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestCalculateRetryDuration(t *testing.T) {
expectMaxDuration := helper(expectMinDuration)
expectMinDuration = expectMinDuration - (1000 * time.Millisecond) // Avoid edge case when calculating time.Until(now)

if !(retryDuration >= expectMinDuration && retryDuration <= expectMaxDuration) {
if retryDuration < expectMinDuration || retryDuration > expectMaxDuration {
t.Fatalf(
"incorrect retry duration, want (ms): [%d, %d], got (ms): %d",
expectMinDuration.Milliseconds(), expectMaxDuration.Milliseconds(),
Expand Down
4 changes: 2 additions & 2 deletions app/vlinsert/journald/journald.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,13 @@ func isValidFieldName(s string) bool {
return false
}
c := s[0]
if !(c >= 'A' && c <= 'Z' || c == '_') {
if (c < 'A' || c > 'Z') && c != '_' {
return false
}

for i := 1; i < len(s); i++ {
c := s[i]
if !(c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_') {
if (c < 'A' || c > 'Z') && (c < '0' || c > '9') && c != '_' {
return false
}
}
Expand Down
7 changes: 4 additions & 3 deletions lib/logstorage/block_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -830,11 +830,12 @@ func truncateTimestamp(ts, bucketSizeInt, bucketOffsetInt int64, bucketSizeStr s
}

ts -= bucketOffsetInt
if bucketSizeStr == "month" {
switch bucketSizeStr {
case "month":
ts = truncateTimestampToMonth(ts)
} else if bucketSizeStr == "year" {
case "year":
ts = truncateTimestampToYear(ts)
} else {
default:
r := ts % bucketSizeInt
if r < 0 {
r += bucketSizeInt
Expand Down
2 changes: 1 addition & 1 deletion lib/logstorage/pipe_facets.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ func parsePipeFacets(lex *lexer) (pipe, error) {
return nil, fmt.Errorf("cannot parse N in 'facets': %w", err)
}
if limitF < 1 {
return nil, fmt.Errorf("N in 'facets %s' must be integer bigger than 0", s)
return nil, fmt.Errorf("value N in 'facets %s' must be integer bigger than 0", s)
}
limit = uint64(limitF)
}
Expand Down
2 changes: 1 addition & 1 deletion lib/logstorage/pipe_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func parsePipeJoin(lex *lexer) (pipe, error) {
// Parse join query
q, err := parseQueryInParens(lex)
if err != nil {
return nil, fmt.Errorf("Cannot parse join(...) query: %w", err)
return nil, fmt.Errorf("cannot parse join(...) query: %w", err)
}

pj := &pipeJoin{
Expand Down
2 changes: 1 addition & 1 deletion lib/logstorage/pipe_top.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ func parsePipeTop(lex *lexer) (pipe, error) {
return nil, fmt.Errorf("cannot parse N in 'top': %w", err)
}
if limitF < 1 {
return nil, fmt.Errorf("N in 'top %s' must be integer bigger than 0", s)
return nil, fmt.Errorf("value N in 'top %s' must be integer bigger than 0", s)
}
limit = uint64(limitF)
limitStr = s
Expand Down