Skip to content

Commit

Permalink
misc: Fix some minor linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilogorek committed May 30, 2019
1 parent 18c9012 commit 946f336
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 27 deletions.
6 changes: 3 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ type ClientOptions struct {
// In debug mode debug information is printed to stdput to help you understand what
// sentry is doing.
Debug bool
// The sample rate for event submission (0.0 - 1.0, defaults to 1.0)
SampleRate float32
// Configures whether SDK should generate and attach stacktraces to pure capture message calls
AttachStacktrace bool
// The sample rate for event submission (0.0 - 1.0, defaults to 1.0)
SampleRate float32
// Before send callback.
BeforeSend func(event *Event, hint *EventHint) *Event
// Before breadcrumb add callback.
Expand Down Expand Up @@ -240,7 +240,7 @@ func (client *Client) eventFromMessage(message string, level Level) *Event {
Message: message,
}

if client.Options().AttachStacktrace == true {
if client.Options().AttachStacktrace {
event.Threads = []Thread{{
Stacktrace: NewStacktrace(),
Crashed: false,
Expand Down
4 changes: 2 additions & 2 deletions example/recover/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func barErr() {
}

func bazErr() {
panic(errors.New("Sorry with error :("))
panic(errors.New("sorry with error :("))
}

func fooMsg() {
Expand All @@ -35,7 +35,7 @@ func barMsg() {
}

func bazMsg() {
panic("Sorry with message :(")
panic("sorry with message :(")
}

func main() {
Expand Down
18 changes: 8 additions & 10 deletions stacktrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,14 @@ func contextifyFrames(frames []Frame) []Frame {
for _, frame := range frames {
lines, initial := sr.readContextLines(frame.AbsPath, frame.Lineno, contextLines)

if lines != nil {
for i, line := range lines {
switch {
case i < initial:
frame.PreContext = append(frame.PreContext, string(line))
case i == initial:
frame.ContextLine = string(line)
default:
frame.PostContext = append(frame.PostContext, string(line))
}
for i, line := range lines {
switch {
case i < initial:
frame.PreContext = append(frame.PreContext, string(line))
case i == initial:
frame.ContextLine = string(line)
default:
frame.PostContext = append(frame.PostContext, string(line))
}
}

Expand Down
25 changes: 13 additions & 12 deletions stacktrace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,21 @@ func TestStacktraceFrameContext(t *testing.T) {

func TestStacktraceUnsuccessfulContextifyShouldNotDropFrames(t *testing.T) {
frames := []Frame{{
Function: "fnName",
Module: "same",
Filename: "wat.go",
AbsPath: "this/doesnt/exist/wat.go",
Lineno: 1,
Colno: 2,
Function: "fnName",
Module: "same",
Filename: "wat.go",
AbsPath: "this/doesnt/exist/wat.go",
Lineno: 1,
Colno: 2,
}, {
Function: "fnNameFoo",
Module: "sameFoo",
Filename: "foo.go",
AbsPath: "this/doesnt/exist/foo.go",
Lineno: 3,
Colno: 5,
Function: "fnNameFoo",
Module: "sameFoo",
Filename: "foo.go",
AbsPath: "this/doesnt/exist/foo.go",
Lineno: 3,
Colno: 5,
}}

contextifiedFrames := contextifyFrames(frames)
assertEqual(t, len(contextifiedFrames), len(frames))
}
Expand Down

0 comments on commit 946f336

Please sign in to comment.