Skip to content

Conversation

@julio-lopez
Copy link
Collaborator

Applies the modernize changes for the following categories:

  • mapsloop
  • stringsseq
  • stringscutprefix
  • sortslice

Refs:

@julio-lopez julio-lopez requested a review from Copilot October 23, 2025 23:30
Copy link

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

This PR modernizes Go code by adopting newer standard library APIs introduced in recent Go versions. The changes follow recommendations from the golang.org/x/tools/gopls/internal/analysis/modernize tool.

Key changes:

  • Replaced strings.Split() iteration patterns with strings.SplitSeq() for more efficient sequential processing
  • Replaced manual map copying loops with maps.Copy() for clearer intent and better performance
  • Replaced strings.HasPrefix() + strings.TrimPrefix() patterns with strings.CutPrefix() for atomic prefix handling
  • Replaced sort.Slice() calls with slices.Sort() for simpler, more idiomatic sorting

Reviewed Changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tools/gettool/gettool.go Replaced strings.Split iteration with strings.SplitSeq
tests/tools/kopiarunner/kopia_snapshotter.go Replaced multiple strings.Split iterations with strings.SplitSeq and strings.FieldsSeq
tests/tools/fio/options.go Replaced manual map copy loops with maps.Copy
tests/robustness/fiofilewriter/fio_filewriter.go Replaced manual map copy loops with maps.Copy
tests/end_to_end_test/snapshot_fail_test.go Replaced manual map copy loops with maps.Copy
tests/end_to_end_test/repository_connect_test.go Replaced strings.HasPrefix + TrimPrefix with strings.CutPrefix
tests/end_to_end_test/auto_update_test.go Replaced manual map copy loop with maps.Copy
snapshot/manager.go Replaced manual map copy loop with maps.Copy
repo/manifest/manifest_manager_test.go Replaced sort.Slice with slices.Sort
repo/compression/compressor_test.go Replaced sort.Slice with slices.Sort
repo/blob/webdav/webdav_storage_test.go Replaced manual map copy loop with maps.Copy
notification/sender/webhook/webhook_sender.go Replaced strings.Split iteration with strings.SplitSeq
internal/uitask/uitask_counter.go Replaced manual map copy loop with maps.Copy
internal/testutil/tmpdir.go Replaced strings.Split iteration with strings.SplitSeq
internal/testutil/serverparameters.go Replaced multiple strings.HasPrefix + TrimPrefix patterns with strings.CutPrefix
internal/server/server_mount_manager.go Replaced manual map copy loop with maps.Copy
internal/server/server.go Replaced manual map copy loops with maps.Copy
internal/releasable/releaseable_tracker.go Replaced manual map copy loop with maps.Copy
internal/cache/content_cache_test.go Replaced sort.Slice with slices.Sort, removed unused sort import
internal/blobtesting/object_locking_map.go Replaced sort.Slice with slices.Sort
internal/blobtesting/map.go Replaced sort.Slice with slices.Sort
internal/blobtesting/asserts.go Replaced sort.Slice with slices.Sort
fs/cachefs/cache_test.go Replaced manual map copy loop with maps.Copy
cli/command_server_tls.go Replaced strings.HasPrefix + TrimPrefix with strings.CutPrefix
cli/command_policy_set_scheduling.go Replaced strings.Split iterations with strings.SplitSeq
cli/command_blob_shards_modify.go Replaced strings.Split iteration with strings.SplitSeq
cli/command_benchmark_compression.go Replaced strings.Split iteration with strings.SplitSeq
cli/command_acl_add.go Replaced strings.Split iteration with strings.SplitSeq

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

fields := strings.FieldsSeq(l)

for _, f := range fields {
for f := range fields {
Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

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

This code attempts to range over the result of strings.FieldsSeq, which does not exist. Even if it did exist and returned an iterator, the iteration would need to be updated to match the iterator protocol. Since strings.Fields returns []string, this should be for _, f := range fields.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@copilot this is incorrect

@codecov
Copy link

codecov bot commented Oct 23, 2025

Codecov Report

❌ Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 77.96%. Comparing base (cb455c6) to head (e7df927).
⚠️ Report is 696 commits behind head on master.

Files with missing lines Patch % Lines
cli/command_benchmark_compression.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4903      +/-   ##
==========================================
+ Coverage   75.86%   77.96%   +2.09%     
==========================================
  Files         470      537      +67     
  Lines       37301    31216    -6085     
==========================================
- Hits        28299    24336    -3963     
+ Misses       7071     4837    -2234     
- Partials     1931     2043     +112     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@julio-lopez julio-lopez marked this pull request as ready for review October 24, 2025 00:10
@julio-lopez julio-lopez merged commit 995e7fd into kopia:master Oct 24, 2025
30 of 32 checks passed
@julio-lopez julio-lopez deleted the refactor/modernize branch October 24, 2025 00:11
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