Fix linting issues: canonicalheader, embeddedstructfieldcheck, iotamixing, makezero, testableexamples, wastedassign, usetesting, tparallel, unconvert, intrange, iface

- canonicalheader: fix cacheTTL header value to canonical form
- embeddedstructfieldcheck: move embedded fields before regular fields in 4 structs
- iotamixing: split const blocks mixing iota with non-iota constants
- makezero: use make([]T, 0, n) instead of make([]T, n) before appending
- testableexamples: add missing Output: comment to ExampleOption_UnwrapOrZero
- wastedassign: remove wasted initial assignments in 4 locations
- usetesting: replace os.MkdirTemp/os.Setenv with t.TempDir/t.Setenv in tests
- tparallel: add t.Parallel() to 8 top-level test functions
- unconvert: remove 16 unnecessary type conversions
- intrange: convert 3 for loops to use integer range syntax
- iface: consolidate identical EditPrompter and Prompt interfaces via type alias

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-03-24 11:05:52 +00:00
parent 6c11ecd9ab
commit dca59d52b6
113 changed files with 222 additions and 287 deletions

View file

@ -237,7 +237,6 @@ func (a *App) Create(ctx context.Context, opts createOptions) error {
}
if len(devcontainers) > 0 {
// if there is only one devcontainer.json file and it is one of the default paths we can auto-select it
if len(devcontainers) == 1 && stringInSlice(devcontainers[0].Path, DEFAULT_DEVCONTAINER_DEFINITIONS) {
devContainerPath = devcontainers[0].Path
@ -527,7 +526,7 @@ func getMachineName(ctx context.Context, apiClient apiClient, prompter SurveyPro
}
availableMachines := make([]string, len(machines))
for i := 0; i < len(machines); i++ {
for i := range machines {
availableMachines[i] = machines[i].Name
}

View file

@ -268,7 +268,6 @@ func (a *App) UpdatePortVisibility(ctx context.Context, selector *CodespaceSelec
if err != nil {
return err
}
}
return nil

View file

@ -52,7 +52,7 @@ func TestApp_Select(t *testing.T) {
opts := selectOptions{}
if tt.outputToFile {
file, err := os.CreateTemp("", "codespace-selection-test")
file, err := os.CreateTemp(t.TempDir(), "codespace-selection-test")
if err != nil {
t.Fatal(err)
}

View file

@ -327,7 +327,7 @@ func selectSSHKeys(
opts sshOptions,
) (*ssh.KeyPair, bool, error) {
customConfigPath := ""
for i := 0; i < len(args); i += 1 {
for i := range args {
arg := args[i]
if arg == "-i" {
@ -703,6 +703,7 @@ func automaticPrivateKeyPath(sshContext ssh.Context) (string, error) {
type cpOptions struct {
sshOptions
recursive bool // -r
expand bool // -e
}
@ -778,7 +779,6 @@ func (a *App) Copy(ctx context.Context, args []string, opts cpOptions) error {
if !opts.expand {
arg = `remote:'` + strings.Replace(rest, `'`, `'\''`, -1) + `'`
}
} else if !filepath.IsAbs(arg) {
// scp treats a colon in the first path segment as a host identifier.
// Escape it by prepending "./".