Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Conversation

@mattjohnsonpint
Copy link
Contributor

I used gopls/modernize to find and apply a few simple code modernizations.

@mattjohnsonpint mattjohnsonpint requested review from a team and Copilot April 23, 2025 18:09
@mattjohnsonpint mattjohnsonpint enabled auto-merge (squash) April 23, 2025 18:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

The PR applies automated modernizations to the codebase using gopls/modernize. Key changes include replacing interface{} with any, converting loops to a range‐based syntax, and switching to the new slices package for list operations.

Reviewed Changes

Copilot reviewed 38 out of 38 changed files in this pull request and generated no comments.

Show a summary per file
File Description
runtime/integration_tests/postgresql_integration_test.go Updated GraphQL request’s variable type from interface{} to any.
runtime/hnsw/heap/heap_test.go Changed loop iteration from a classic counting loop to a range clause.
runtime/hnsw/graph_test.go Updated several loops in tests to use range and new b.Loop() calls.
runtime/hnsw/graph.go Altered loop over max level using range instead of counting index.
runtime/hnsw/encode_test.go Converted test loop iterations to use range over integer literals.
runtime/hnsw/encode.go Updated a loop to range over nLayers.
runtime/collections/vector.go Modified batch insertion loop to use range, potentially altering step logic.
runtime/collections/utils/heap_test.go Updated loop over an integer variable using range.
runtime/collections/index/helper.go Changed loop iteration to use range over an integer length.
runtime/collections/in_mem/text_index_test.go Converted loop from a counting loop to range over an integer literal.
runtime/collections/in_mem/sequential/vector_index_test.go Changed loop iteration from a counting loop to range over an integer literal.
runtime/collections/in_mem/hnsw/vector_index_test.go Updated loop iteration to use range over an integer literal.
lib/wasmextractor/wasmextractor.go Changed import loop to use range over int(numItems).
Comments suppressed due to low confidence (14)

runtime/collections/vector.go:38

  • Changing the loop to 'for i := range textIds' removes the intended batch increment (i += batchSize), potentially altering the batching logic. Please ensure the batch step is retained.
for i := range textIds {

runtime/collections/index/helper.go:50

  • Iterating with 'for i := range resultLen' is invalid since resultLen is an integer; please use the standard loop syntax.
for i := range resultLen {

runtime/hnsw/heap/heap_test.go:30

  • Using 'for range 20' is invalid because 20 is an integer literal. Please revert to the conventional 'for i := 0; i < 20; i++' form or iterate over a constructed slice.
for range 20 {

runtime/hnsw/graph_test.go:109

  • Ranging over an integer literal (128) is not allowed; please use a proper loop construct (e.g. 'for i := 0; i < 128; i++') or range over a slice.
for i := range 128 {

runtime/hnsw/graph_test.go:154

  • Iterating using 'for i := range 128' is invalid since 128 is an integer literal; consider reverting to the standard counting loop.
for i := range 128 {

runtime/hnsw/graph_test.go:210

  • The use of 'b.Loop()' in the loop condition is nonstandard; please verify that b.Loop() is a valid method returning a boolean and that its behavior is as intended.
for i := 0; b.Loop(); i++ {

runtime/hnsw/graph.go:358

  • Using 'for level := range max' is invalid because max is an integer value; please revert to a conventional counting loop like 'for level := 0; level < max; level++'.
for level := range max {

runtime/hnsw/encode_test.go:136

  • Looping with 'for i := range 128' is not valid; integer literals cannot be used directly in a range expression.
for i := range 128 {

runtime/hnsw/encode.go:222

  • If nLayers is an integer, the 'for i := range nLayers' syntax is invalid; please use the standard counting loop.
for i := range nLayers {

runtime/collections/utils/heap_test.go:46

  • Using range on 'initialLen', an integer, is invalid; revert to the previous counting loop to iterate the expected number of times.
for i := range initialLen {

runtime/collections/in_mem/text_index_test.go:28

  • Using a range loop over the integer 'numCollections' is not permitted; please revert to a counting loop.
for i := range numCollections {

runtime/collections/in_mem/sequential/vector_index_test.go:40

  • A loop written as 'for i := range numIndexes' is invalid since numIndexes is an integer literal; consider using a traditional counting loop.
for i := range numIndexes {

runtime/collections/in_mem/hnsw/vector_index_test.go:40

  • Using 'for i := range numIndexes' is incorrect as numIndexes is an integer; please revert to the standard counting loop syntax.
for i := range numIndexes {

lib/wasmextractor/wasmextractor.go:130

  • Iterating with 'for i := range int(numItems)' is invalid because int(numItems) is an integer literal; consider iterating over a slice or using the standard counting loop.
for i := range int(numItems) {

@mattjohnsonpint mattjohnsonpint merged commit 89f659e into main Apr 23, 2025
48 checks passed
@mattjohnsonpint mattjohnsonpint deleted the mjp/modernize branch April 23, 2025 21:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants