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

Fix lint errors #78

Merged
merged 1 commit into from May 2, 2022
Merged

Fix lint errors #78

merged 1 commit into from May 2, 2022

Conversation

lukebakken
Copy link
Contributor

@lukebakken lukebakken commented Apr 20, 2022

Start by removing some dead code.

@fho I have added you as a collaborator on my fork. Please feel free to push to this branch.

@lukebakken lukebakken added this to the 1.3.5 milestone Apr 20, 2022
@lukebakken lukebakken self-assigned this Apr 20, 2022
@lukebakken lukebakken mentioned this pull request Apr 20, 2022
3 tasks
@lukebakken
Copy link
Contributor Author

@fho I left some TODO statements to figure out what to do in some error situations.

@fho
Copy link
Contributor

fho commented Apr 22, 2022

@lukebakken I'm looking into handling the error returned by channel.recv.
It seems that channel.recv() never returns an error and that all the involved functions can be simplified to not return one.
If that works out, I'll create a separate PR to simplify that, otherwise I'll keep you uptodate :-)

@fho
Copy link
Contributor

fho commented Apr 22, 2022

@lukebakken that worked, here is the PR: #80

@lukebakken
Copy link
Contributor Author

Tests pass but there are still quite a few TODOs.

@lukebakken lukebakken marked this pull request as ready for review May 1, 2022 18:57
@lukebakken
Copy link
Contributor Author

lukebakken commented May 1, 2022

@fho @Zerpet @deadtrickster -

For now I think we can review this and address the TODOs around panic via #81. lmk what you think.

I will squash before merging of course.

connection.go Outdated Show resolved Hide resolved
@lukebakken lukebakken requested a review from ansd May 1, 2022 23:05
Copy link
Member

@ansd ansd left a comment

Choose a reason for hiding this comment

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

As you already wrote, except for the panic() which should be avoided in libraries, the remaining changes look good to me. Thanks @lukebakken !

Copy link
Contributor

@fho fho left a comment

Choose a reason for hiding this comment

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

I think we should not add new panic calls to the master branch.
Applications would now crash instead of ignoring errors in places where it seems to not have caused issues so far.

We could keep the linter errors on those lines (+ enable that golangci-lint only complains for new issues on PRs again) or add TODO + // nolint lines, merge this PR and do #81 later.

This would ensure that the version in master is as stable as before and a new release could be created anytime.

@lukebakken
Copy link
Contributor Author

@fho we can do that.

One of the main reasons for this project to be created was that versioning was not being used in https://github.com/streadway/amqp. If you're using main you should know the risks.

Start by removing some dead code.

types: remove unused typeSet type

The type was not used at all, remove it.

This was found by the unused linter:
  types.go:269:6: type `tagSet` is unused (unused)

tests: fix: declaration of unused value

This fixes:
  integration_test.go:1941:2: SA4006: this value of `ch` is never used
  (staticcheck)

tests: fix: check returned errors when getting a channel

This fixes:
  integration_test.go:808:8: ineffectual assignment to err (ineffassign)
  		pub, err := c.Channel()
  		     ^
  integration_test.go:915:8: ineffectual assignment to err (ineffassign)
  		pub, err := c1.Channel()
  		     ^
  integration_test.go:916:8: ineffectual assignment to err (ineffassign)
  		sub, err := c2.Channel()
		     ^

fix warnings from gosimple

This fixes:
client_test.go:75:5: S1004: should use !bytes.Equal(b, in) instead (gosimple)
	if bytes.Compare(b, in) != 0 {
integration_test.go:1009:7: S1004: should use !bytes.Equal(msg.Body, fixture.Body) instead (gosimple)
			if bytes.Compare(msg.Body, fixture.Body) != 0 {
integration_test.go:1928:6: S1004: should use !bytes.Equal(want, got.Body) instead (gosimple)
		if bytes.Compare(want, got.Body) != 0 {
uri.go:58:5: S1002: should omit comparison to bool constant, can be simplified to `strings.Contains(uri, " ")` (gosimple)
	if strings.Contains(uri, " ") == true {
	   ^
write.go:421:25: S1030: should use buf.String() instead of string(buf.Bytes()) (gosimple)
	return writeLongstr(w, string(buf.Bytes()))

tests/TestIntegrationChannelClosing: don't call func that does nothing

The TestIntegrationChannelClosing was defining a function that was doing
nothing and calling it 2x, remove this.

ci: report all existing golangci-lint issues

Instead of only reporting golangci-lint issues that are new in a
pull-request, report all existing ones.

All open issues are fixed, afterwards having 0 issues can be norm.

Add error check with TODO

golangci-lint fixes

client_test.go is now lint-free

examples_test.go is now lint-free

reconnect_test.go is now lint-free

connection_test.go is now lint-free

connection_test.go is now lint-free

Starting de-linting on integration_test.go

Fix TestRaceBetweenChannelShutdownAndSend

connection.go is lint-free

removing lint from integration_test.go. Ignore net.OpError in heartbeater

remove more lint from integration_test.go

remove more lint from integration_test.go

Fix deadlocked test

Fix test

Variable naming

Do not panic

Bump and simplify some CI settings
@lukebakken lukebakken merged commit b221bfd into rabbitmq:main May 2, 2022
@lukebakken lukebakken deleted the fix-golangci-lint branch May 2, 2022 16:56
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.

None yet

3 participants