diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 0000000..72349ee --- /dev/null +++ b/.deepsource.toml @@ -0,0 +1,28 @@ +version = 1 + +exclude_patterns = [ + "vendor/**" +] + +[[analyzers]] +name = "go" +enabled = true + + [analyzers.meta] + import_paths = ["github.com/ankitdobhal/goreplay"] + +[[analyzers]] +name = "docker" +enabled = true + +[[analyzers]] +name = "ruby" +enabled = true + +[[analyzers]] +name = "javascript" +enabled = true + + [analyzers.meta] + environment = ["nodejs"] + diff --git a/capture/sock_linux.go b/capture/sock_linux.go index 2aba8ee..24c5840 100644 --- a/capture/sock_linux.go +++ b/capture/sock_linux.go @@ -197,7 +197,7 @@ func (sock *SockRaw) GetSnapLen() int { func (sock *SockRaw) SetBPFFilter(expr string) error { sock.mu.Lock() defer sock.mu.Unlock() - if len(expr) == 0 { + if expr == "" { return unix.SetsockoptInt(sock.fd, unix.SOL_SOCKET, unix.SO_DETACH_FILTER, 0) } filter, err := pcap.CompileBPFFilter(layers.LinkTypeEthernet, sock.snaplen, expr) diff --git a/gor.go b/gor.go index 07e5474..18fa6c8 100644 --- a/gor.go +++ b/gor.go @@ -31,7 +31,7 @@ func loggingMiddleware(next http.Handler) http.Handler { } func main() { - if len(os.Getenv("GOMAXPROCS")) == 0 { + if os.Getenv("GOMAXPROCS") == "" { runtime.GOMAXPROCS(runtime.NumCPU() * 2) } diff --git a/input_file.go b/input_file.go index 36b72f1..681680a 100644 --- a/input_file.go +++ b/input_file.go @@ -162,11 +162,10 @@ func (i *FileInput) init() (err error) { for _, c := range resp.Contents { matches = append(matches, "s3://"+bucket+"/"+(*c.Key)) } - } else { - if matches, err = filepath.Glob(i.path); err != nil { + } else if matches, err = filepath.Glob(i.path); err != nil{ Debug(0, "[INPUT-FILE] Wrong file pattern", i.path, err) return - } + } if len(matches) == 0 { diff --git a/input_file_test.go b/input_file_test.go index 7f92eff..fac5e01 100644 --- a/input_file_test.go +++ b/input_file_test.go @@ -29,10 +29,9 @@ func TestInputFileWithGET(t *testing.T) { // The read request should match the original request if err != nil { t.Error(err) - } else { - if !expectedCaptureFile.PayloadsEqual(readPayloads) { + } else if !expectedCaptureFile.PayloadsEqual(readPayloads){ t.Error("Request read back from file should match") - } + } } @@ -53,10 +52,9 @@ func TestInputFileWithPayloadLargerThan64Kb(t *testing.T) { // The read request should match the original request if err != nil { t.Error(err) - } else { - if !expectedCaptureFile.PayloadsEqual(readPayloads) { + } else if !expectedCaptureFile.PayloadsEqual(readPayloads){ t.Error("Request read back from file should match") - } + } } @@ -82,10 +80,9 @@ func TestInputFileWithGETAndPOST(t *testing.T) { // The read requests should match the original request if err != nil { t.Error(err) - } else { - if !expectedCaptureFile.PayloadsEqual(readPayloads) { + } else if !expectedCaptureFile.PayloadsEqual(readPayloads){ t.Error("Request read back from file should match") - } + } } diff --git a/proto/proto.go b/proto/proto.go index d4b3847..6d46f1a 100644 --- a/proto/proto.go +++ b/proto/proto.go @@ -355,7 +355,7 @@ func HasResponseTitle(payload []byte) bool { return false } // only validate status codes mentioned in rfc2616. - if len(http.StatusText(status)) == 0 { + if http.StatusText(status) == "" { return false } // handle cases from #875