Skip to content

Commit

Permalink
Fix linter warnings (#156)
Browse files Browse the repository at this point in the history
- Unreachable code
- Variable names using snake_case instead of CamelCase
- Unused parameters
- Redundant parenthesis
- Shell-bang was not set correctly

Any code after `t.Fatalf` is not executed, because this function stops
execution.

Signed-off-by: Aitor Pérez Cedres <acedres@vmware.com>

Signed-off-by: Aitor Pérez Cedres <acedres@vmware.com>
Co-authored-by: Luke Bakken <luke@bakken.io>
  • Loading branch information
Zerpet and lukebakken committed Jan 20, 2023
1 parent 2b29a8e commit 32d6f86
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 24 deletions.
2 changes: 1 addition & 1 deletion change_version.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#/bin/bash
#!/bin/bash
echo $1 > VERSION
sed -i -e "s/.*buildVersion = \"*.*/buildVersion = \"$1\"/" ./connection.go
go fmt ./...
2 changes: 1 addition & 1 deletion connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ func (c *Connection) closeWith(err *Error) error {
// IsClosed returns true if the connection is marked as closed, otherwise false
// is returned.
func (c *Connection) IsClosed() bool {
return (atomic.LoadInt32(&c.closed) == 1)
return atomic.LoadInt32(&c.closed) == 1
}

func (c *Connection) send(f frame) error {
Expand Down
31 changes: 10 additions & 21 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ func TestIntegrationConsumeCancel(t *testing.T) {
}
}

func (c *Connection) Generate(r *rand.Rand, _ int) reflect.Value {
func (c *Connection) Generate(_ *rand.Rand, _ int) reflect.Value {
urlStr := amqpURL

conn, err := Dial(urlStr)
Expand Down Expand Up @@ -1259,22 +1259,22 @@ func TestIntegrationCancel(t *testing.T) {
defer c.Close()

cancels := ch.NotifyCancel(make(chan string, 1))
consume_err := make(chan error, 1)
delete_err := make(chan error, 1)
consumeErr := make(chan error, 1)
deleteErr := make(chan error, 1)

go func() {
if _, err := ch.Consume(queue, consumerTag, false, false, false, false, nil); err != nil {
consume_err <- err
consumeErr <- err
}
if _, err := ch.QueueDelete(queue, false, false, false); err != nil {
delete_err <- err
deleteErr <- err
}
}()

select {
case err := <-consume_err:
case err := <-consumeErr:
t.Fatalf("cannot consume from %q to test NotifyCancel: %v", queue, err)
case err := <-delete_err:
case err := <-deleteErr:
t.Fatalf("cannot delete integration queue: %v", err)
case tag := <-cancels:
if want, got := consumerTag, tag; want != got {
Expand Down Expand Up @@ -1445,11 +1445,11 @@ func TestDeclareArgsRejectToDeadLetterQueue(t *testing.T) {
}

// Reject everything consumed
reject_errs := make(chan error, len(fails))
rejectErrs := make(chan error, len(fails))
go func() {
for d := range fails {
if err := d.Reject(false); err != nil {
reject_errs <- err
rejectErrs <- err
}
}
}()
Expand Down Expand Up @@ -1479,16 +1479,6 @@ func TestDeclareArgsRejectToDeadLetterQueue(t *testing.T) {
}
}
t.Fatalf("expected dead-letter after 10 get attempts")

if err := ch.Close(); err != nil {
t.Fatalf("channel close error: %v", err)
}
close(reject_errs)
for err := range reject_errs {
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
}
}
}

Expand Down Expand Up @@ -1915,7 +1905,6 @@ func TestConsumerCancelNotification(t *testing.T) {
// do nothing
case <-time.After(time.Second * 10):
t.Fatalf("basic.cancel wasn't received")
t.Fail()
}
// we don't close ccnChan because channel shutdown
// does it
Expand Down Expand Up @@ -2058,7 +2047,7 @@ func integrationQueueDelete(t *testing.T, c *Channel, queue string) {
// Delegates to integrationConnection and only returns a connection if the
// product is RabbitMQ
func integrationRabbitMQ(t *testing.T, name string) *Connection {
if conn := integrationConnection(t, "connect"); conn != nil {
if conn := integrationConnection(t, name); conn != nil {
if server, ok := conn.Properties["product"]; ok && server == "RabbitMQ" {
return conn
}
Expand Down
2 changes: 1 addition & 1 deletion read.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func readField(r io.Reader) (v interface{}, err error) {
if err = binary.Read(r, binary.BigEndian, &value); err != nil {
return
}
return (value != 0), nil
return value != 0, nil

case 'B':
var value [1]byte
Expand Down

0 comments on commit 32d6f86

Please sign in to comment.