Skip to content
Open
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
61 changes: 42 additions & 19 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,63 @@
---
version: "2"
issues:
max-issues-per-linter: 1000
max-same-issues: 1000
linters:
default: none
enable:
- bodyclose
- copyloopvar
- cyclop
- errcheck
- errchkjson
- errorlint
- goconst
- gocritic
- gosec
- govet
- ineffassign
- misspell
- nilerr
- nilnil
- noctx
# - nolintlint # very good linter, but there are 109 issues to solve
- prealloc
- revive
- staticcheck
- unconvert
- unparam
- unused
settings:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that part has wrong indentation

gocritic:
disabled-checks:
- ifElseChain
- singleCaseSwitch
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- path: (.+)\.go$
text: comment on exported (method|function|type|const|var)
paths:
- third_party$
- builtin$
- examples$
- wastedassign
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- path: (.+)\.go$
text: comment on exported (method|function|type|const|var)
paths:
- third_party$
- builtin$
- examples$
Comment on lines +42 to +45
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, locate and examine the .golangci.yaml file
find . -name ".golangci.yaml" -o -name ".golangci.yml" | head -5

Repository: akash-network/node

Length of output: 78


🏁 Script executed:

# Check if the directories mentioned exist
fd -t d -name "third_party" -o -name "builtin" -o -name "examples" | head -10

Repository: akash-network/node

Length of output: 292


🌐 Web query:

golangci-lint path exclusion pattern syntax glob regex

💡 Result:

In golangci-lint, “path exclusion patterns” are usually regular expressions (regex), not glob—but a few linter-specific settings explicitly use glob.

Regex (most common)

run.skip-dirs, run.skip-files

These accept regexp patterns (matched against the path; commonly treated as “full path”). Example patterns like (^|/)vendor($|/) are used to skip directories. (github.com)

linters.exclusions.paths, linters.exclusions.rules[*].path, path-except

These are used to exclude reported issues by path, and the examples in the docs are clearly regex (e.g. (.+)_test\.go, _test\.go). (golangci-lint.run)

Relative path base (run.relative-path-mode)

What the regex is matched against depends on how golangci-lint computes “relative paths” (e.g. relative to go.mod, git root, config file, or working dir). (golangci-lint.run)

Glob (only where explicitly documented)

Some linter settings explicitly say they accept glob patterns. For example:

  • ruleguard.rules: “Glob patterns such as rules-*.go may be specified.” (golangci-lint.run)
  • protogetter.skip-files: “Skip files matching the specified glob pattern…” (examples include *.pb.go, */vendor/*). (golangci-lint.run)

Practical takeaway

  • If you’re configuring run skips or issue exclusions by path: write regex (RE2/Go-style), e.g. .*_test\.go$, (^|/)vendor($|/). (golangci-lint.run)
  • If you want glob, use only the options that explicitly document glob support (typically linter-specific settings). (golangci-lint.run)

Citations:


🏁 Script executed:

# Read the .golangci.yaml file to see the context around lines 42-45
cat -n .golangci.yaml | sed -n '30,50p'

Repository: akash-network/node

Length of output: 629


🏁 Script executed:

# Properly search for the directories mentioned
find . -type d \( -name "third_party" -o -name "builtin" -o -name "examples" \) 2>/dev/null

Repository: akash-network/node

Length of output: 44


🏁 Script executed:

# Check if there are any Go files in these directories (if they exist)
find . -type f -name "*.go" -path "*/third_party/*" -o -name "*.go" -path "*/builtin/*" -o -name "*.go" -path "*/examples/*" 2>/dev/null | head -20

Repository: akash-network/node

Length of output: 44


🏁 Script executed:

# Let's check the golangci-lint documentation more carefully
# Look for any comments or documentation in the repo about these patterns
grep -r "third_party\|builtin\|examples" .golangci.yaml

Repository: akash-network/node

Length of output: 173


🌐 Web query:

golangci-lint exclusions paths regex pattern matching behavior

💡 Result:

In golangci-lint, “exclusion paths” (e.g. linters.exclusions.paths, linters.exclusions.rules[].path, path-except) are treated as Go regular expressions (RE2) and are matched against the file path string (not glob patterns). (golangci-lint.run)

Key behavior:

  • What string is matched: the (relative) file path for the issue/file; patterns like (.+)_test\.go work because the matcher sees the path text. (golangci-lint.run)
  • Relative-to what? Controlled by run.relative-path-mode (used by exclusions, among other things). Options: gomod, gitroot, cfg, or wd (not recommended). Default is cfg in config v2. (golangci-lint.run)
  • Path separators: / in patterns is treated portably (documented as being replaced by the OS path separator) so patterns can work on Windows too. (golangci-lint.run)
  • Not implicitly anchored: regexes match like normal RE2—if you want “whole path” matching, add ^...$ yourself; if you want “directory only”, use an explicit boundary (e.g. (^|.*/)generated(/|$)).

Legacy note (v1 docs / older configs): exclusions were described as matching paths relative to the current working directory, and --path-prefix could affect matching. (golangci.github.io)

Citations:


🏁 Script executed:

# Check if there's a go.mod or any indication of project structure
head -20 go.mod 2>/dev/null || echo "No go.mod found in expected location"

Repository: akash-network/node

Length of output: 573


Path exclusion patterns use regex and won't exclude files within these directories.

The patterns third_party$, builtin$, examples$ are Go regular expressions (not glob). The $ anchor matches only the end of the path string. A path like third_party/somefile.go ends with .go, not third_party, so it won't be excluded.

If the intent is to exclude all files within these directories, adjust the patterns to:

🔧 Suggested fix
     paths:
-      - third_party$
-      - builtin$
-      - examples$
+      - third_party/
+      - builtin/
+      - examples/
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
paths:
- third_party$
- builtin$
- examples$
paths:
- third_party/
- builtin/
- examples/
🤖 Prompt for AI Agents
In @.golangci.yaml around lines 42 - 45, The path exclusion patterns
`third_party$`, `builtin$`, and `examples$` are regexes anchored to the very end
of the path so they won't match files inside those directories (e.g.,
`third_party/somefile.go`); update those patterns to match directory prefixes
instead (for example use patterns that start with the directory name and allow a
trailing slash or any following path segment such as `^third_party(/|$)`,
`^builtin(/|$)`, `^examples(/|$)` or `^third_party/.*`, `^builtin/.*`,
`^examples/.*`) so that the `paths:` entries will correctly exclude all files
under those directories.

settings:
errorlint:
errorf: false
cyclop:
max-complexity: 40
gocritic:
disabled-checks:
- ifElseChain
- singleCaseSwitch
- commentFormatting
revive:
rules:
- name: context-as-argument
- name: error-return
- name: error-naming
formatters:
enable:
- gofmt
Expand Down
16 changes: 1 addition & 15 deletions make/lint.mk
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
SUBLINTERS = unused \
misspell \
gofmt \
gocritic \
goconst \
ineffassign \
unparam \
staticcheck \
revive \
gosec \
exportloopref \
prealloc
# TODO: ^ gochecknoglobals

.PHONY: lint-go
lint-go: $(GOLANGCI_LINT)
$(GOLANGCI_LINT_RUN) ./... --issues-exit-code=0 --timeout=10m
$(GOLANGCI_LINT) run ./... --timeout=10m
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets fail in case of linter errors


.PHONY: lint-go-%
lint-go-%: $(GOLANGCI_LINT)
Expand Down
56 changes: 0 additions & 56 deletions tests/upgrade/sdktypes.go

This file was deleted.

3 changes: 3 additions & 0 deletions upgrades/software/v1.1.0/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@ func (up *upgrade) OnGroupClosed(ctx sdk.Context, id dv1.GroupID) error {
func (up *upgrade) OnEscrowPaymentClosed(ctx sdk.Context, obj etypes.Payment) error {
id, err := mv1.LeaseIDFromPaymentID(obj.ID)
if err != nil {
// Escrow payments can belong to different scopes (e.g., bid-scoped, deployment-scoped).
// This upgrade hook only processes lease payments (deployment-scoped).
// Silently ignore non-lease payment closures.
return nil
}

Expand Down
4 changes: 0 additions & 4 deletions x/escrow/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ import (
"pkg.akt.dev/node/testutil/state"
)

type kTestSuite struct {
*state.TestSuite
}

func Test_AccountSettlement(t *testing.T) {
ssuite := state.SetupTestSuite(t)
ctx := ssuite.Context()
Expand Down
23 changes: 0 additions & 23 deletions x/market/handler/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1427,26 +1427,3 @@ func (st *testSuite) createProvider(attr attr.Attributes) ptypes.Provider {

return prov
}

func (st *testSuite) createDeployment() (dv1.Deployment, dtypes.Groups) {
st.t.Helper()

deployment := testutil.Deployment(st.t)
group := testutil.DeploymentGroup(st.t, deployment.ID, 0)
group.GroupSpec.Resources = dtypes.ResourceUnits{
{
Resources: testutil.ResourceUnits(st.t),
Count: 1,
Price: testutil.AkashDecCoinRandom(st.t),
},
}
groups := dtypes.Groups{
group,
}

for i := range groups {
groups[i].State = dtypes.GroupOpen
}

return deployment, groups
}
5 changes: 4 additions & 1 deletion x/market/hooks/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ func (h *hooks) OnEscrowAccountClosed(ctx sdk.Context, obj etypes.Account) error
func (h *hooks) OnEscrowPaymentClosed(ctx sdk.Context, obj etypes.Payment) error {
id, err := mv1.LeaseIDFromPaymentID(obj.ID)
if err != nil {
return nil
// Escrow payments can belong to different scopes (e.g., bid-scoped, deployment-scoped).
// Market module only handles lease payments (deployment-scoped).
// Silently ignore non-lease payment closures.
return nil //nolint:nilerr // non-lease payment, not an error for this hook
}

bid, ok := h.mkeeper.GetBid(ctx, id.BidID())
Expand Down
Loading