Skip to content

Task: Resolve lint errors#98

Merged
hsluoyz merged 1 commit intoapache:masterfrom
kenjones-cisco:task/lint-fixes
May 4, 2018
Merged

Task: Resolve lint errors#98
hsluoyz merged 1 commit intoapache:masterfrom
kenjones-cisco:task/lint-fixes

Conversation

@kenjones-cisco
Copy link
Contributor

No description provided.

@coveralls
Copy link

coveralls commented May 3, 2018

Coverage Status

Coverage decreased (-0.5%) to 81.078% when pulling 437f266 on kenjones-cisco:task/lint-fixes into 25ad5e6 on casbin:master.

rm.AddLink("u4", "g2")
rm.AddLink("u4", "g3")
rm.AddLink("g1", "g3")
_ = rm.AddLink("u1", "g1")
Copy link
Member

Choose a reason for hiding this comment

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

Why this kind of change is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AddLink returns an error. This explicitly indicates the error is being ignored.
Otherwise errcheck via gometalinter produces the following:

rbac/default-role-manager/role_manager_test.go:57:12:warning: error return value not checked (rm.AddLink("u1", "g1")) (errcheck)

Copy link
Member

Choose a reason for hiding this comment

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

Given it is not a Golang official advice, I tend not to follow it. Because it makes a lot of code look tedious and doesn't help readers to understand the code better. Can you rework the commit by removing such changes? Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Golang official advice would be to actually check each of the errors:
https://github.com/golang/go/wiki/CodeReviewComments#handle-errors
https://github.com/golang/lint

To keep backwards compatibility I took the path of explicitly ignoring the errors.

Copy link
Member

Choose a reason for hiding this comment

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

Handling each error is not practical. My thought is to keep the code as simple as possible, but leave users the option to make it robust (and complicated at most times).

To keep backwards compatibility I took the path of explicitly ignoring the errors.

Could the commit be improved?

@@ -286,8 +286,12 @@ func NewRoleManager() rbac.RoleManager {
return &testCustomRoleManager{}
}
func (rm *testCustomRoleManager) Clear() error { return nil }
Copy link
Member

Choose a reason for hiding this comment

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

Why the below two functions are expanded except this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Either goimports or my IDE expanded the others. I did not manually expand any of those.

Copy link
Member

Choose a reason for hiding this comment

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

OK. Strange..

@hsluoyz
Copy link
Member

hsluoyz commented May 3, 2018

All other changes are OK for me, just reverting all the _ = would be OK.

@hsluoyz
Copy link
Member

hsluoyz commented May 4, 2018

@kenjones-cisco LGTM.

BTW, can you help me answer the questionnaire here: #79? Thanks.

@hsluoyz hsluoyz merged commit 2d8d2b2 into apache:master May 4, 2018
@kenjones-cisco kenjones-cisco deleted the task/lint-fixes branch March 25, 2019 00:13
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