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

Make TravisCI build green again #62

Merged
merged 4 commits into from
Sep 10, 2018
Merged

Conversation

andygrunwald
Copy link
Owner

This PR makes the TravisCI build green again. In detail

  • Rename struct fields to Go naming convention (golint)
  • Renamed the gometalinter gas to gosec
  • Fixed the handing of an unhandled error

One important note: The renaming of struct fields is a breaking change. It was introduced in #60. @achew22 would be nice if you can check this as well, because it might break your code.

gometalinter/golint raised some warnings about the naming of struct fields:

gometalinter --config gometalinter.json ./...
changes.go:261:2:warning: struct field RobotId should be RobotID (golint)
changes.go:263:2:warning: struct field RobotRunId should be RobotRunID (golint)
changes.go:265:2:warning: struct field Url should be URL (golint)
changes.go:280:2:warning: struct field RobotId should be RobotID (golint)
changes.go:282:2:warning: struct field RobotRunId should be RobotRunID (golint)
changes.go:284:2:warning: struct field Url should be URL (golint)
changes.go:297:2:warning: struct field FixId should be FixID (golint)
@codecov-io
Copy link

codecov-io commented Sep 9, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@197fe0d). Click here to learn what that means.
The diff coverage is 60%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #62   +/-   ##
=========================================
  Coverage          ?   22.48%           
=========================================
  Files             ?       21           
  Lines             ?     1801           
  Branches          ?        0           
=========================================
  Hits              ?      405           
  Misses            ?     1341           
  Partials          ?       55
Impacted Files Coverage Δ
authentication.go 76% <100%> (ø)
changes.go 15.15% <42.85%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 197fe0d...46fe642. Read the comment docs.

Copy link
Collaborator

@dmitshur dmitshur left a comment

Choose a reason for hiding this comment

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

LGTM with inline suggestions for you to consider.

changes.go Outdated
@@ -780,8 +780,15 @@ func (s *ChangesService) change(tail string, changeID string, input interface{})

v := new(ChangeInfo)
resp, err := s.client.Do(req, v)
if err != nil {
return v, resp, err
Copy link
Collaborator

Choose a reason for hiding this comment

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

Other similar lines (above) do return nil, resp, err. Better to be consistent.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Good one!

changes.go Outdated
body, err = ioutil.ReadAll(resp.Body)
if err != nil {
return v, resp, err
}
err = errors.New(string(body[:]))
}
return v, resp, err
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest rewriting as follows to make the code more readable:

...
if resp.StatusCode == http.StatusConflict {
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return v, resp, err
	}
	return v, resp, errors.New(string(body[:]))
}
return v, resp, nil

Also, I'm suspect about this whole thing working. Doesn't s.client.Do(req, v) already consume the resp.Body before returning? There are no tests for it, and no rationale for why it was added in #15. I'd remove it and simplify this endpoint to be like all others. But it's out of scope of this PR.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I adjusted the code according to your suggestion.

Regarding your comment: Indeed. That could be a possible mistake. And I am with you, that this has to be investigated in a separate ticket/pr. Let me check this, and I will ping you for a review again.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Hey @dmitshur, i am a little bit packed with private things the next days/weeks. I will come back to this later. If you have some spare time around, feel free to make the change. Otherwise i can do it later. Sorry, but thanks for understanding.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not at a problem at all, this isn't blocking me in any way.

If you don't want this opportunity to improve code to be forgotten, I'd suggest opening an issue to track it.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Just to not forget it: #64 (was short on time, but i think it is enough for us now).

@andygrunwald andygrunwald merged commit 30ce279 into master Sep 10, 2018
@andygrunwald andygrunwald deleted the fix-build-gometalinter branch September 11, 2018 14:36
if err != nil {
return v, resp, err
}
return v, resp, errors.New(string(body[:]))
Copy link
Collaborator

Choose a reason for hiding this comment

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

A trivial thing I just spotted: body[:] could be simplified to body. It's already a slice, no need to slice it again.

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.

3 participants