Skip to content

Commit

Permalink
Simplify code (#354)
Browse files Browse the repository at this point in the history
- Remove unnecessary fmt.Sprintf
- Use fmt.Errorf instead of errors.New(fmt.Sprintf(...))
  • Loading branch information
muesli authored and Andrea Nodari committed Jul 21, 2019
1 parent 3f647c4 commit 0d9100e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion format/format.go
Expand Up @@ -300,7 +300,7 @@ func formatString(object interface{}, indentation uint) string {
}
}

return fmt.Sprintf("%s", result)
return result
} else {
return fmt.Sprintf("%q", object)
}
Expand Down
2 changes: 1 addition & 1 deletion matchers/receive_matcher_test.go
Expand Up @@ -265,7 +265,7 @@ var _ = Describe("ReceiveMatcher", func() {
Describe("when used with eventually and a custom matcher", func() {
It("should return the matcher's error when a failing value is received on the channel, instead of the must receive something failure", func() {
failures := InterceptGomegaFailures(func() {
c := make(chan string, 0)
c := make(chan string)
Eventually(c, 0.01).Should(Receive(Equal("hello")))
})
Expect(failures[0]).Should(ContainSubstring("When passed a matcher, ReceiveMatcher's channel *must* receive something."))
Expand Down
3 changes: 1 addition & 2 deletions matchers/support/goraph/bipartitegraph/bipartitegraph.go
@@ -1,6 +1,5 @@
package bipartitegraph

import "errors"
import "fmt"

import . "github.com/onsi/gomega/matchers/support/goraph/node"
Expand Down Expand Up @@ -28,7 +27,7 @@ func NewBipartiteGraph(leftValues, rightValues []interface{}, neighbours func(in
for j, rightValue := range rightValues {
neighbours, err := neighbours(leftValue, rightValue)
if err != nil {
return nil, errors.New(fmt.Sprintf("error determining adjacency for %v and %v: %s", leftValue, rightValue, err.Error()))
return nil, fmt.Errorf("error determining adjacency for %v and %v: %s", leftValue, rightValue, err.Error())
}

if neighbours {
Expand Down

0 comments on commit 0d9100e

Please sign in to comment.