Skip to content
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

CI: enable errorlint #2512

Closed
wants to merge 7 commits into from
Closed

CI: enable errorlint #2512

wants to merge 7 commits into from

Commits on Aug 10, 2024

  1. copy.Image: improve wrapping Close errors

    When commit 849dd70 was written, Go did not have an ability to wrap
    multiple errors. Since Go 1.20 it's possible by either using multiple
    %w, or via errors.Join (which discards nil errors).
    
    In a sense, this is what the code was doing before commit 849dd70,
    except we don't add extra spaces or parentheses -- as joined error,
    when converted to a string, is represented with newlines added between
    elements.
    
    Signed-off-by: Kir Kolyshkin <[email protected]>
    kolyshkin committed Aug 10, 2024
    Configuration menu
    Copy the full SHA
    7092582 View commit details
    Browse the repository at this point in the history
  2. pkg/blobcache: simplify test case

    1. Use os.ReadDir to remove a few lines of code.
    
    2. Don't wrap errors from os, they already contain file name.
    
    Signed-off-by: Kir Kolyshkin <[email protected]>
    kolyshkin committed Aug 10, 2024
    Configuration menu
    Copy the full SHA
    1d4025f View commit details
    Browse the repository at this point in the history
  3. Improvements wrt errors

    1. Don't add context (such as file name and operation) to errors from
       "os" as they already have this information.
    
    2. Use %w for errors, including multiple errors (works Go 1.20).
    
    Signed-off-by: Kir Kolyshkin <[email protected]>
    kolyshkin committed Aug 10, 2024
    Configuration menu
    Copy the full SHA
    aa038a5 View commit details
    Browse the repository at this point in the history
  4. directory: test case nit

    This needs to be "require" rather than "assert", as if error is
    returned, test needs to fail now. Otherwise, close will panic.
    
    Signed-off-by: Kir Kolyshkin <[email protected]>
    kolyshkin committed Aug 10, 2024
    Configuration menu
    Copy the full SHA
    61852e6 View commit details
    Browse the repository at this point in the history
  5. directory: simplify newImageDestination

    The current code is unnecessarily complicated:
     - check if a file/directory exists before opening it unnecessary;
     - it uses three helper functions not used anywhere else;
     - directory contents is read twice.
    
    Untangle all this, making the code simpler.
    
    Signed-off-by: Kir Kolyshkin <[email protected]>
    kolyshkin committed Aug 10, 2024
    Configuration menu
    Copy the full SHA
    c7da673 View commit details
    Browse the repository at this point in the history
  6. sig/int: simplify error conversion

    Use errors.As to convert errors.
    
    Move the code that converts JSONFormatError to NewInvalidSignatureError
    to a separate helper, and use it everywhere.
    
    Remove the intermediary functions where they became unnecessary.
    
    Signed-off-by: Kir Kolyshkin <[email protected]>
    kolyshkin committed Aug 10, 2024
    Configuration menu
    Copy the full SHA
    1adc5c4 View commit details
    Browse the repository at this point in the history
  7. Enable errorlint, ignore some warnings

    This enables errorlint to golangci-lint configuration, and silences last
    warnings found (three of these are to be removed once a new version of
    errorlint will be used).
    
    Signed-off-by: Kir Kolyshkin <[email protected]>
    kolyshkin committed Aug 10, 2024
    Configuration menu
    Copy the full SHA
    2f691ef View commit details
    Browse the repository at this point in the history