Skip to content

fix linting issues #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 15, 2025
Merged

fix linting issues #2

merged 11 commits into from
Apr 15, 2025

Conversation

thaJeztah
Copy link
Member

fix "struct literal uses unkeyed fields" (govet), and rename a function to prevent shadowing.

pkg/archive/changes_test.go:123:18: composites: github.com/docker/docker/pkg/archive.Change struct literal uses unkeyed fields (govet)
    modifyChange := Change{"change", ChangeModify}
                    ^
pkg/archive/changes_test.go:128:15: composites: github.com/docker/docker/pkg/archive.Change struct literal uses unkeyed fields (govet)
    addChange := Change{"change", ChangeAdd}
                 ^
...

@thaJeztah
Copy link
Member Author

Had some other changes, but need to make sure we have CI running in this repository first.

changes_test.go Outdated
Comment on lines 197 to 198
dir3 := path.Join(baseLayer, "dir1/dir2/dir3")
os.MkdirAll(dir3, 0o7400)
assert.NilError(t, os.MkdirAll(dir3, 0o7400))
Copy link
Member Author

Choose a reason for hiding this comment

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

Interesting; so this is failing;

=== RUN   TestChangesWithChangesGH13590
    changes_test.go:198: assertion failed: error is not nil: mkdir /tmp/docker-changes-test.2086521634/dir1/dir2: permission denied
--- FAIL: TestChangesWithChangesGH13590 (0.00s)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ooooh! Look at that;

os.MkdirAll(dir3, 0o7400)

Extra trailing zero???

Signed-off-by: Sebastiaan van Stijn <[email protected]>
fix "struct literal uses unkeyed fields" (govet), and rename a function
to prevent shadowing.

    pkg/archive/changes_test.go:123:18: composites: github.com/docker/docker/pkg/archive.Change struct literal uses unkeyed fields (govet)
        modifyChange := Change{"change", ChangeModify}
                        ^
    pkg/archive/changes_test.go:128:15: composites: github.com/docker/docker/pkg/archive.Change struct literal uses unkeyed fields (govet)
        addChange := Change{"change", ChangeAdd}
                     ^
    ...

Signed-off-by: Sebastiaan van Stijn <[email protected]>
      Error: archive.go:1138:8: comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
                    if err == io.ErrClosedPipe {
                       ^
      Error: archive.go:1495:46: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
                pipeW.CloseWithError(fmt.Errorf("%s: %s", err, errBuf.String()))
                                                          ^
      Error: changes_test.go:37:20: type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors (errorlint)
        if exiterr, ok := err.(*exec.ExitError); ok {
                          ^
      Error: copy_unix_test.go:358:5: comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
        if err != ErrDirNotExists {
           ^
      Error: copy_unix_test.go:367:5: comparing with != will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
        if err != ErrDirNotExists {
           ^
      Error: diff.go:226:63: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
            return true, fmt.Errorf("failed to decompress archive: %v", err)
                                                                        ^
      Error: diff.go:235:70: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
            return false, fmt.Errorf("failed to read next archive header: %v", err)
                                                                               ^
      Error: utils_test.go:78:15: type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors (errorlint)
            if _, ok := err.(breakoutError); !ok {
                        ^

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah
Copy link
Member Author

@dmcgowan ptal 🤗

      Error: archive.go:347:15: ST1005: error strings should not be capitalized (staticcheck)
            return nil, fmt.Errorf("Unsupported compression format %s", (&compression).Extension())
                        ^
      Error: archive.go:367:15: ST1005: error strings should not be capitalized (staticcheck)
            return nil, fmt.Errorf("Unsupported compression format %s", (&compression).Extension())
                        ^
      Error: archive.go:369:15: ST1005: error strings should not be capitalized (staticcheck)
            return nil, fmt.Errorf("Unsupported compression format %s", (&compression).Extension())
                        ^
      Error: internal/mounttree/switchroot_linux.go:29:55: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
            return fmt.Errorf("Error setting up pivot dir: %v", err)
                                                                ^
      Error: internal/mounttree/switchroot_linux.go:48:65: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
                errCleanup = fmt.Errorf("Error cleaning up after pivot: %v", errCleanup)
                                                                             ^
      Error: internal/mounttree/switchroot_linux.go:58:66: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
                return fmt.Errorf("Error cleaning up after failed pivot: %v", err)
                                                                              ^

Signed-off-by: Sebastiaan van Stijn <[email protected]>
    chrootarchive/archive_test.go:105:29: prepareSourceDirectory - numberOfFiles always receives 10 (unparam)
    func prepareSourceDirectory(numberOfFiles int, targetPath string, makeSymLinks bool) (int, error) {
                                ^

    chrootarchive/archive_test.go:105:68: prepareSourceDirectory - result 0 (int) is never used (unparam)
    func prepareSourceDirectory(targetPath string, makeSymLinks bool) (int, error) {
                                                                       ^

Signed-off-by: Sebastiaan van Stijn <[email protected]>
    archive.go:1034:19: Error return value of `filepath.WalkDir` is not checked (errcheck)
    		filepath.WalkDir(walkRoot, func(filePath string, f os.DirEntry, err error) error {
    		                ^

Signed-off-by: Sebastiaan van Stijn <[email protected]>
     Error: changes_linux.go:136:3: QF1006: could lift into loop condition (staticcheck)
            if ix1 >= len(names1) {
            ^

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah merged commit d4d21a8 into moby:main Apr 15, 2025
12 checks passed
@thaJeztah thaJeztah deleted the fix_linting branch April 15, 2025 07:09
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.

2 participants