Skip to content

Commit

Permalink
fix: Lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiPrasad committed Jun 2, 2020
1 parent 0d0bf23 commit 2c8d11e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ func (client *Client) processEvent(event *Event, hint *EventHint, scope EventMod
return nil
}

if event.Type != "transaction" && options.BeforeSend != nil {
if event.Type != transactionType && options.BeforeSend != nil {
h := &EventHint{}
if hint != nil {
h = hint
Expand Down
12 changes: 10 additions & 2 deletions interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import (
// Level marks the severity of the event
type Level string

// transactionType refers to an transaction event
const transactionType = "transaction"

const (
LevelDebug Level = "debug"
LevelInfo Level = "info"
Expand Down Expand Up @@ -223,21 +226,26 @@ func (e *Event) MarshalJSON() ([]byte, error) {
}{
alias: (*alias)(e),
})
} else if e.Timestamp.IsZero() {
}

if e.Timestamp.IsZero() {
return json.Marshal(&struct {
*alias
Timestamp json.RawMessage `json:"timestamp,omitempty"`
}{
alias: (*alias)(e),
})
} else if e.StartTimestamp.IsZero() {
}

if e.StartTimestamp.IsZero() {
return json.Marshal(&struct {
*alias
StartTimestamp json.RawMessage `json:"start_timestamp,omitempty"`
}{
alias: (*alias)(e),
})
}

return json.Marshal(&struct {
*alias
}{
Expand Down
5 changes: 3 additions & 2 deletions interfaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/google/go-cmp/cmp"
)

var update = flag.Bool("update", false, "update .golden files")
var update = flag.Bool("update", false, "update .golden files") //nolint: gochecknoglobals

func TestNewRequest(t *testing.T) {
const payload = `{"test_data": true}`
Expand Down Expand Up @@ -66,6 +66,7 @@ func TestMarshalStruct(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.testName, func(t *testing.T) {
got, err := json.MarshalIndent(test.sentryStruct, "", " ")
if err != nil {
Expand All @@ -74,7 +75,7 @@ func TestMarshalStruct(t *testing.T) {

golden := filepath.Join(".", "testdata", fmt.Sprintf("%s.golden", test.testName))
if *update {
err := ioutil.WriteFile(golden, got, 0644)
err := ioutil.WriteFile(golden, got, 0600)
if err != nil {
t.Error(err)
}
Expand Down
2 changes: 1 addition & 1 deletion transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func getRequestFromEvent(event *Event, dsn *Dsn) (*http.Request, error) {
return nil, errors.New("event could not be marshalled")
}

if event.Type == "transaction" {
if event.Type == transactionType {
env := getEnvelopeFromBody(body)
request, _ := http.NewRequest(
http.MethodPost,
Expand Down
3 changes: 2 additions & 1 deletion transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func TestGetRequestFromEvent(t *testing.T) {
testName: "Transaction",
event: func() *Event {
event := NewEvent()
event.Type = "transaction"
event.Type = transactionType

return event
}(),
Expand All @@ -184,6 +184,7 @@ func TestGetRequestFromEvent(t *testing.T) {
}

for _, test := range testCases {
test := test
t.Run(test.testName, func(t *testing.T) {
dsn, err := NewDsn("https://key@host/path/42")
if err != nil {
Expand Down

0 comments on commit 2c8d11e

Please sign in to comment.