Skip to content

chore: fix linting#90

Merged
freak12techno merged 4 commits intomainfrom
fix-linting
Mar 14, 2026
Merged

chore: fix linting#90
freak12techno merged 4 commits intomainfrom
fix-linting

Conversation

@freak12techno
Copy link
Copy Markdown
Collaborator

@freak12techno freak12techno commented Mar 9, 2026

Summary by CodeRabbit

  • New Features

    • Graceful server shutdown with timeout and enhanced request-ID tracing.
  • Bug Fixes

    • Stricter RPC response validation and improved mutex/unlock behavior to avoid deadlocks.
    • More explicit early returns on error paths to prevent unexpected continuations.
  • Chores

    • Upgraded Go toolchain and linters; migrated linter config and standardized collection/storage types across the codebase.
  • Style

    • Various formatting and whitespace cleanups.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 9, 2026

Warning

Rate limit exceeded

@freak12techno has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 19 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 884d9279-f2da-441a-a88a-2dc81ab4f1ec

📥 Commits

Reviewing files that changed from the base of the PR and between 994c034 and 988e39c.

📒 Files selected for processing (1)
  • go.mod
📝 Walkthrough

Walkthrough

This pull request updates the Go toolchain to 1.25.x, migrates golangci-lint config to v2 schema, replaces uses of interface{} with the any alias across many public APIs, refactors several error handling patterns, tightens RPC response validation, and applies assorted concurrency and formatting adjustments.

Changes

Cohort / File(s) Summary
Go Toolchain & Lint
​.github/workflows/actions.yaml, ​.github/workflows/release.yaml, go.mod, .golangci.yml
Bumps Go versions to 1.25.x in workflows and go.mod; upgrades golangci-lint-action; migrates .golangci.yml to version 2 schema with new defaults, disables, exclusions, and formatters.
Repository config & CLI
.gitignore, cmd/cosmos-validators-exporter.go, cmd/cosmos-validators-exporter_test.go
Removes several .gitignore rules; refactors error-scope in main.Execute to an explicit err variable; test files receive whitespace adjustments.
Fetcher interface & implementations
pkg/fetchers/fetcher.go, pkg/fetchers/* (many files)
Replaces interface{} with any in Fetch signatures and returns; updates ~19 fetcher implementations to match; simplifies RPC map access from two-value to direct lookup; adds/clarifies early returns on errors, and introduces mutex/defer patterns in several concurrent fetchers.
Fetcher tests (formatting)
pkg/fetchers/*_test.go
Consistent whitespace insertion after httpmock.Activate() across many tests; no logic changes.
State API
pkg/state/state.go
Replaces interface{} with any in state storage and public methods (GetData, Set, Get, Convert), updating public API types.
HTTP & Tendermint RPC
pkg/http/http.go, pkg/http/http_test.go, pkg/tendermint/rpc.go
Changes HTTP/RPC method signatures to use any for targets; adds explicit response-code checks (require code == 0) and returns errors on non-zero; unlocks mutex before HTTP calls; minor loop and error-handling refactors.
Application & tracing
pkg/app.go, pkg/app_test.go, pkg/tracing/tracer.go
Adds graceful shutdown (5s timeout) to Stop; sets request-id span attribute in handlers; tiny tracer whitespace change and test formatting tweaks.
Config validation & generators
pkg/config/*, pkg/generators/*
Refactors inline short-error declarations to explicit err assignments in validation routines; generator tests initialize state entries to avoid nil access; several continue/return behavior tightened on not-found conditions.
Utilities, controller, logger, price fetcher
pkg/controller/controller.go, pkg/utils/utils.go, pkg/logger/logger.go, pkg/price_fetchers/coingecko/coingecko.go
Mostly regrouped variable declarations and whitespace/formatting changes; no substantive logic changes.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I hopped through types both old and many,
Swapped interface{} for a friend named any.
With Go bumped up and linters anew,
I nibbled whitespace, tightened a few.
Thump-thump — fetchers prance, the builds say "ready"!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The PR title 'chore: fix linting' is vague and generic, using non-descriptive terms that do not convey meaningful information about the substantial changes in this changeset. Consider using a more specific title that reflects the main changes, such as 'chore: upgrade Go to 1.25.8 and migrate to golangci-lint v9' or 'chore: modernize Go version and linter configuration'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 87.80% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-linting

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/fetchers/signing_info.go (1)

154-163: ⚠️ Potential issue | 🟡 Minor

Skip consumer signing-info lookups when ConsensusAddress is missing.

This path still calls GetConsumerAssignedKey with validator.ConsensusAddress unconditionally. For validators that legitimately omit that field, the fetcher turns an optional config value into an RPC error and noisy logs instead of just skipping the consumer lookup.

Suggested fix
 func (q *SigningInfoFetcher) processConsumerChain(
 	ctx context.Context,
 	validator config.Validator,
 	rpc *tendermint.RPC,
 	providerRPC *tendermint.RPC,
 	chain *config.ConsumerChain,
 ) {
 	defer q.wg.Done()

 	if chain.BechConsensusPrefix == "" || chain.BechValidatorPrefix == "" {
 		return
 	}
+	if validator.ConsensusAddress == "" {
+		return
+	}

 	// 1. Fetching assigned key.
 	assignedKey, queryInfo, err := providerRPC.GetConsumerAssignedKey(
Based on learnings, the `ConsensusAddress` in the `Validator` struct is not a required field, and its absence should be handled as a warning, not an error.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/fetchers/signing_info.go` around lines 154 - 163, The code currently
calls providerRPC.GetConsumerAssignedKey with validator.ConsensusAddress even
when that field is empty; update the fetch path in signing_info.go to check
validator.ConsensusAddress (from the Validator struct) before attempting the
consumer lookup, and if it's empty simply log a warning and return/skip the
consumer-specific work instead of calling GetConsumerAssignedKey (so avoid
generating RPC errors/noisy logs); ensure the early-return happens before
variables assignedKey/queryInfo/err are used.
🧹 Nitpick comments (2)
.golangci.yml (1)

42-45: Redundant staticcheck configuration.

staticcheck is disabled on line 28, but you're still providing settings for it on lines 42-45. This configuration is redundant and can be removed to reduce confusion.

🧹 Suggested cleanup
-    staticcheck:
-      checks:
-        - all
-        - -SA1019
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.golangci.yml around lines 42 - 45, Remove the redundant staticcheck
configuration block (the "staticcheck:" key and its nested "checks:" list) since
staticcheck is already disabled earlier; either delete this block entirely or
consolidate it into the earlier staticcheck configuration if you intended to
enable specific checks.
pkg/fetchers/has_to_validate.go (1)

108-114: Fix the error message to match the RPC being called.

This branch handles GetValidatorConsumerChains, not node info. The current log text will mislabel failures during triage.

📝 Proposed fix
 	if err != nil {
 		q.Logger.Error().
 			Err(err).
 			Str("chain", chainName).
-			Msg("Error querying node info")
+			Msg("Error querying validator consumer chains")
 
 		return
 	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/fetchers/has_to_validate.go` around lines 108 - 114, The log message in
the error branch inside the GetValidatorConsumerChains handling is
incorrect—it's saying "Error querying node info"; update the Msg text in the
q.Logger.Error() call to accurately reflect the RPC being invoked (e.g., "Error
calling GetValidatorConsumerChains" or "Error querying validator consumer
chains") while keeping the existing Err(err) and Str("chain", chainName)
context; locate the branch in has_to_validate.go that calls
GetValidatorConsumerChains and replace the misleading message with the corrected
one.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/actions.yaml:
- Line 10: The workflow's go-version key is set to an invalid value '^1.25.8'
which will break CI; update the go-version entry (the "go-version" key) to a
valid released Go version (for example '1.21' or '1.22') or use a supported
pattern like '1.x' so the setup-go action resolves to a real release; ensure all
jobs that reference "go-version" use the same corrected value.
- Line 30: The workflow currently references uses:
golangci/golangci-lint-action@v9 which enables v2 config schema validation and
Node 24 runtime; before upgrading, either run golangci-lint migrate to update
.golangci.yml and add version: "2", or pin the action to a known v1.x tag, or
add the action input verify: false to temporarily disable validation; also
confirm your runners are compatible with Node 24 if you keep `@v9`. Use the string
uses: golangci/golangci-lint-action@v9 as the location to apply one of these
changes.

In @.github/workflows/release.yaml:
- Line 26: The workflow references an invalid Go version "go-version: 1.25" and
outdated actions; update the Go version to a valid release that matches go.mod
(e.g., "go-version: 1.20" or the version declared in go.mod) and bump the action
versions to newer releases by replacing uses of actions/checkout and
actions/setup-go with actions/checkout@v4 and actions/setup-go@v5 respectively
so the workflow uses a valid Go toolchain and current action releases.

In `@go.mod`:
- Around line 3-5: The go.mod currently declares "go 1.25.8" but the toolchain
is set to "toolchain go1.22.1", which is older and will break builds; fix by
making the toolchain version equal or newer than the module Go version (e.g.,
update "toolchain go1.22.1" to "toolchain go1.25.8" or a newer toolchain), or
alternatively lower the "go 1.25.8" directive to match the intended toolchain;
adjust the "go 1.25.8" and "toolchain go1.22.1" entries accordingly so they are
consistent.

---

Outside diff comments:
In `@pkg/fetchers/signing_info.go`:
- Around line 154-163: The code currently calls
providerRPC.GetConsumerAssignedKey with validator.ConsensusAddress even when
that field is empty; update the fetch path in signing_info.go to check
validator.ConsensusAddress (from the Validator struct) before attempting the
consumer lookup, and if it's empty simply log a warning and return/skip the
consumer-specific work instead of calling GetConsumerAssignedKey (so avoid
generating RPC errors/noisy logs); ensure the early-return happens before
variables assignedKey/queryInfo/err are used.

---

Nitpick comments:
In @.golangci.yml:
- Around line 42-45: Remove the redundant staticcheck configuration block (the
"staticcheck:" key and its nested "checks:" list) since staticcheck is already
disabled earlier; either delete this block entirely or consolidate it into the
earlier staticcheck configuration if you intended to enable specific checks.

In `@pkg/fetchers/has_to_validate.go`:
- Around line 108-114: The log message in the error branch inside the
GetValidatorConsumerChains handling is incorrect—it's saying "Error querying
node info"; update the Msg text in the q.Logger.Error() call to accurately
reflect the RPC being invoked (e.g., "Error calling GetValidatorConsumerChains"
or "Error querying validator consumer chains") while keeping the existing
Err(err) and Str("chain", chainName) context; locate the branch in
has_to_validate.go that calls GetValidatorConsumerChains and replace the
misleading message with the corrected one.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9a0b6786-85f3-4087-80d3-be58bf41e1d1

📥 Commits

Reviewing files that changed from the base of the PR and between bdeeacf and b2370b4.

📒 Files selected for processing (70)
  • .github/workflows/actions.yaml
  • .github/workflows/release.yaml
  • .gitignore
  • .golangci.yml
  • cmd/cosmos-validators-exporter.go
  • cmd/cosmos-validators-exporter_test.go
  • go.mod
  • pkg/app.go
  • pkg/app_test.go
  • pkg/config/chain.go
  • pkg/config/config.go
  • pkg/config/consumer_chain.go
  • pkg/controller/controller.go
  • pkg/fetchers/balance.go
  • pkg/fetchers/balance_test.go
  • pkg/fetchers/commission.go
  • pkg/fetchers/commission_test.go
  • pkg/fetchers/consumer_commission.go
  • pkg/fetchers/consumer_commission_test.go
  • pkg/fetchers/consumer_info.go
  • pkg/fetchers/consumer_info_test.go
  • pkg/fetchers/consumer_validators.go
  • pkg/fetchers/consumer_validators_test.go
  • pkg/fetchers/delegations.go
  • pkg/fetchers/delegations_test.go
  • pkg/fetchers/fetcher.go
  • pkg/fetchers/has_to_validate.go
  • pkg/fetchers/has_to_validate_test.go
  • pkg/fetchers/inflation.go
  • pkg/fetchers/inflation_test.go
  • pkg/fetchers/node_info.go
  • pkg/fetchers/node_info_test.go
  • pkg/fetchers/price.go
  • pkg/fetchers/price_test.go
  • pkg/fetchers/rewards.go
  • pkg/fetchers/rewards_test.go
  • pkg/fetchers/self_delegation.go
  • pkg/fetchers/self_delegation_test.go
  • pkg/fetchers/signing_info.go
  • pkg/fetchers/signing_info_test.go
  • pkg/fetchers/slashing_params.go
  • pkg/fetchers/slashing_params_test.go
  • pkg/fetchers/staking_params.go
  • pkg/fetchers/staking_params_test.go
  • pkg/fetchers/stub.go
  • pkg/fetchers/supply.go
  • pkg/fetchers/supply_test.go
  • pkg/fetchers/unbonds.go
  • pkg/fetchers/unbonds_test.go
  • pkg/fetchers/validators.go
  • pkg/fetchers/validators_test.go
  • pkg/generators/active_set_tokens_test.go
  • pkg/generators/single_validator_info.go
  • pkg/generators/single_validator_info_test.go
  • pkg/generators/validator_active.go
  • pkg/generators/validator_active_test.go
  • pkg/generators/validator_commission_rate.go
  • pkg/generators/validator_commission_rate_test.go
  • pkg/generators/validator_rank.go
  • pkg/generators/validator_rank_test.go
  • pkg/generators/validators_info.go
  • pkg/generators/validators_info_test.go
  • pkg/http/http.go
  • pkg/http/http_test.go
  • pkg/logger/logger.go
  • pkg/price_fetchers/coingecko/coingecko.go
  • pkg/state/state.go
  • pkg/tendermint/rpc.go
  • pkg/tracing/tracer.go
  • pkg/utils/utils.go
💤 Files with no reviewable changes (1)
  • .gitignore

Comment thread .github/workflows/actions.yaml
Comment thread .github/workflows/actions.yaml
Comment thread .github/workflows/release.yaml
Comment thread go.mod Outdated
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.86%. Comparing base (bdeeacf) to head (988e39c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #90   +/-   ##
=======================================
  Coverage   99.85%   99.86%           
=======================================
  Files          68       68           
  Lines        2840     2868   +28     
=======================================
+ Hits         2836     2864   +28     
  Misses          2        2           
  Partials        2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@freak12techno freak12techno merged commit 976cfc4 into main Mar 14, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant