Skip to content

fix(web_search): align with CONVENTION.md var ordering and function order - #79

Merged
devproje merged 1 commit into
masterfrom
fix/web-search-convention
Sep 23, 2026
Merged

devproje merged 1 commit into
masterfrom
fix/web-search-convention

Conversation

@devproje

Copy link
Copy Markdown
Owner

What this changes

A convention pass over the just-merged #78 found violations of docs/CONVENTION.md in modules/web_search/web_search.go and its test:

  • braveSearch/tavilySearch/ollamaSearch declared results before hit, but hit is what the for _, hit = range ... loop actually assigns first each iteration — results is only touched inside the loop body afterward.
  • formatResults declared body before index/result, but the for index, result = range results assigns those first; body.WriteString only happens after.
  • formatResults itself was defined above the three backend functions even though Search's Execute calls it only after (and outside) the backend dispatch switch — CONVENTION.md wants helpers ordered by when their caller actually invokes them.
  • Two test functions had the same first-use-order issue (lookup/wantErr, got/results).

How it was verified

  • make test-race passes
  • New behaviour has a test, or there is nothing to test — pure reordering, no behavior change, existing tests cover it

Checklist

  • Follows docs/CONVENTION.md: no comments, no :=, one var block per function in first-use order with err last, callees before callers, and main unconditionally last
  • New .go files carry the two-line SPDX header
  • Documentation updated if behaviour a user can see has changed (none — no behavior change)
  • My contribution is licensed GPL-3.0-only, matching the project

…rder

Several var blocks declared results before hit (or body before the
loop variables that get assigned first), and formatResults sat above
the backend functions it's actually called after. Convention.md
requires declaration order to follow first use, and helpers to appear
in the order their caller invokes them.
@devproje
devproje merged commit 459776b into master Sep 23, 2026
3 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