Skip to content

Commit

Permalink
👷 Added wrapcheck
Browse files Browse the repository at this point in the history
Added another linter and resolved the issues it raises.

Signed-off-by: Geoffrey Wiseman <[email protected]>
  • Loading branch information
geoffreywiseman committed Nov 28, 2024
1 parent 2d51ad2 commit d2013a4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ linters:
- bugs
- error
- unused
disable:
- wrapcheck # TODO: Resolve and Enable

12 changes: 6 additions & 6 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (c *Client) getWorkflowPage(repository Repository, page uint8) ([]Workflow,
url := fmt.Sprintf("repos/%s/actions/workflows?page=%d", repository.FullName, page)
err := c.Rest.Get(url, &response)
if err != nil {
return nil, err
return nil, fmt.Errorf("could not get workflow page: %w", err)
}
return response.Workflows, nil
}
Expand All @@ -107,7 +107,7 @@ func (c *Client) GetWorkflowUsage(repository Repository, workflow Workflow) (*Us
path := fmt.Sprintf("repos/%s/actions/workflows/%d/timing", repository.FullName, workflow.ID)
err := c.Rest.Get(path, &response)
if err != nil {
return nil, err
return nil, fmt.Errorf("could not get workflow usage: %w", err)
}
return &response, nil
}
Expand Down Expand Up @@ -150,7 +150,7 @@ func (c *Client) GetRepository(fullName string) (*Repository, error) {
if is404(err) {
return nil, nil
}
return nil, err
return nil, fmt.Errorf("could not get repository: %w", err)
}
return &response, nil
}
Expand All @@ -159,7 +159,7 @@ func (c *Client) GetRepository(fullName string) (*Repository, error) {
func (c *Client) GetCurrentRepository() (*Repository, error) {
repo, err := gh.CurrentRepository()
if err != nil {
return nil, err
return nil, fmt.Errorf("could not get current repository: %w", err)
}

if repo.Host() != "github.com" {
Expand All @@ -182,7 +182,7 @@ func (c *Client) GetUser(name string) (*User, error) {
if is404(err) {
return nil, nil
}
return nil, err
return nil, fmt.Errorf("could not get user: %w", err)
}
return &response, nil
}
Expand Down Expand Up @@ -228,7 +228,7 @@ func (c *Client) getAllRepositoriesPage(pagePath string) ([]*Repository, error)
if is404(err) {
return nil, nil
}
return nil, err
return nil, fmt.Errorf("could not get repositories: %w", err)
}
return response, nil
}
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func getRepositories(targets []string) (repoMap, error) {
func mapRepository(repos repoMap, repoName string) error {
repo, err := gh.GetRepository(repoName)
if err != nil {
return err
return fmt.Errorf("could not get repository: %w", err)
}
if repo == nil {
return UnknownRepoError(repoName)
Expand All @@ -151,7 +151,7 @@ func mapRepository(repos repoMap, repoName string) error {
func mapOwner(repos repoMap, userName string) error {
user, err := gh.GetUser(userName)
if err != nil {
return err
return fmt.Errorf("could not get user: %w", err)
}
if user == nil {
return UnknownUserError(userName)
Expand All @@ -164,7 +164,7 @@ func mapOwner(repos repoMap, userName string) error {

ors, err := gh.GetAllRepositories(user)
if err != nil {
return err
return fmt.Errorf("could not get repositories: %w", err)
}

list = append(list, ors...)
Expand Down
18 changes: 9 additions & 9 deletions mock/mock_rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,53 +16,53 @@ type RestMock struct {
// Do is a mock implementation of RESTClient.Do
func (m *RestMock) Do(method, path string, body io.Reader, response interface{}) error {
args := m.Called(method, path, body, response)
return args.Error(0)
return args.Error(0) //nolint:wrapcheck
}

// DoWithContext is a mock implementation of RESTClient.DoWithContext
func (m *RestMock) DoWithContext(ctx context.Context, method, path string, body io.Reader, response interface{}) error {
args := m.Called(ctx, method, path, body, response)
return args.Error(0)
return args.Error(0) //nolint:wrapcheck
}

// Delete is a mock implementation of RESTClient.Delete
func (m *RestMock) Delete(path string, response interface{}) error {
args := m.Called(path, response)
return args.Error(0)
return args.Error(0) //nolint:wrapcheck
}

// Get is a mock implementation of RESTClient.Get
func (m *RestMock) Get(path string, response interface{}) error {
args := m.Called(path, response)
return args.Error(0)
return args.Error(0) //nolint:wrapcheck
}

// Patch is a mock implementation of RESTClient.Patch
func (m *RestMock) Patch(path string, body io.Reader, response interface{}) error {
args := m.Called(path, body, response)
return args.Error(0)
return args.Error(0) //nolint:wrapcheck
}

// Post is a mock implementation of RESTClient.Post
func (m *RestMock) Post(path string, body io.Reader, response interface{}) error {
args := m.Called(path, body, response)
return args.Error(0)
return args.Error(0) //nolint:wrapcheck
}

// Put is a mock implementation of RESTClient.Put
func (m *RestMock) Put(path string, body io.Reader, response interface{}) error {
args := m.Called(path, body, response)
return args.Error(0)
return args.Error(0) //nolint:wrapcheck
}

// Request is a mock implementation of RESTClient.Request
func (m *RestMock) Request(method, path string, body io.Reader) (*http.Response, error) {
args := m.Called(method, path, body)
return nil, args.Error(0)
return nil, args.Error(0) //nolint:wrapcheck
}

// RequestWithContext is a mock implementation of RESTClient.RequestWithContext
func (m *RestMock) RequestWithContext(ctx context.Context, method, path string, body io.Reader) (*http.Response, error) {
args := m.Called(ctx, method, path, body)
return nil, args.Error(0)
return nil, args.Error(0) //nolint:wrapcheck
}

0 comments on commit d2013a4

Please sign in to comment.