Skip to content

test: remove unreachable code in GetServerVersion (#48) - #49

Merged
talmacschen-arch merged 1 commit into
cloudberry-contrib:mainfrom
talmacschen-arch:fix/vet-unreachable-getserverversion
Jul 16, 2026
Merged

test: remove unreachable code in GetServerVersion (#48)#49
talmacschen-arch merged 1 commit into
cloudberry-contrib:mainfrom
talmacschen-arch:fix/vet-unreachable-getserverversion

Conversation

@talmacschen-arch

@talmacschen-arch talmacschen-arch commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

What

Removes the unreachable code block at the end of GetServerVersion in testutils/functions.go.

Why

go vet ./... reports one warning on main:

# github.com/cloudberry-contrib/cbcopy/testutils
testutils/functions.go:648:2: unreachable code

GetServerVersion returns serverVersion early, so the trailing regexp-extraction block (a comment block + regexp.MustCompile + return match) is dead code — never executed. The function has no callers in the repo, so there is no intended behavior to preserve; the safe, minimal fix is to drop the unreachable block.

Verification

  • gofmt -l — clean
  • go vet ./...now clean (warning gone)
  • go build ./... — passes
  • make unit — all 5 suites pass (dbconn 12/12, backup 469/470 + skips, TOC 45/45, testutils 8/8, utils 58/58)

regexp is still imported and used by the sibling GetPslVersion, so no import change is needed. No behavior change.

Fixes #48

Summary by CodeRabbit

  • Bug Fixes
    • Improved server version reporting by preserving the complete version output returned by the database client.
    • Removed unnecessary version parsing that could omit non-numeric version details.

)

GetServerVersion returned serverVersion early, leaving the trailing
regexp-extraction block dead code, which go vet flagged as:

  testutils/functions.go:648:2: unreachable code

The function has no callers, so drop the unreachable block to keep
`go vet ./...` clean. No behavior change.

Fixes cloudberry-contrib#48
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3ea152f8-3284-467c-aba7-1305062ca81f

📥 Commits

Reviewing files that changed from the base of the PR and between b100694 and 2a1ea9f.

📒 Files selected for processing (1)
  • testutils/functions.go
💤 Files with no reviewable changes (1)
  • testutils/functions.go

📝 Walkthrough

Walkthrough

GetServerVersion now returns the trimmed raw output from psql directly. The unreachable regular-expression parsing and related version comments were removed.

Changes

Server version output

Layer / File(s) Summary
Remove unreachable version parsing
testutils/functions.go
GetServerVersion returns the complete trimmed psql output and removes the unreachable regex-based numeric extraction.

Estimated code review effort: 1 (Trivial) | ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: removing unreachable code in GetServerVersion.
Description check ✅ Passed The description explains the change, motivation, and verification, with the linked issue referenced.
Linked Issues check ✅ Passed The PR removes the dead code block that triggers the reported go vet warning, matching issue #48.
Out of Scope Changes check ✅ Passed The changes stay narrowly focused on deleting unreachable code in testutils/functions.go.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@leaocx leaocx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Clean removal of unreachable code.

  • Confirmed the code after return serverVersion is indeed dead
  • GetServerVersion has no callers in the repo
  • regexp import is still used by GetPslVersion, no import change needed
  • No behavior change

@talmacschen-arch
talmacschen-arch merged commit 7fa402b into cloudberry-contrib:main Jul 16, 2026
4 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.

go vet: unreachable code in testutils GetServerVersion (functions.go:648)

2 participants