]> Sergey Matveev's repositories - btrtrc.git/commitdiff
fixed code quality issues using DeepSource
authorShubhendra Singh Chauhan <withshubh@gmail.com>
Sat, 16 Jan 2021 10:59:36 +0000 (16:29 +0530)
committerMatt Joiner <anacrolix@gmail.com>
Sat, 30 Jan 2021 04:23:49 +0000 (15:23 +1100)
* Added .deepsource.toml

* Removed empty default in select

* Removed unnecessary use of slice

* Fixed check for empty string

.deepsource.toml [new file with mode: 0644]
fs/torrentfs.go
mse/mse.go
mse/mse_test.go
webtorrent/tracker_client.go

diff --git a/.deepsource.toml b/.deepsource.toml
new file mode 100644 (file)
index 0000000..6c68e6d
--- /dev/null
@@ -0,0 +1,11 @@
+version = 1
+
+test_patterns = ["**/*_test.go"]
+
+[[analyzers]]
+name = "go"
+enabled = true
+
+  [analyzers.meta]
+  import_paths = ["github.com/anacrolix/torrent"]
+  
index 0b3b7a91f1421f3068f03e1d9dd34cb6bdf6602c..aedab1af68d5d216883ffd244bbc93ab5dc9908e 100644 (file)
@@ -60,14 +60,14 @@ var (
 )
 
 func isSubPath(parent, child string) bool {
-       if len(parent) == 0 {
+       if parent == "" {
                return len(child) > 0
        }
        if !strings.HasPrefix(child, parent) {
                return false
        }
        extra := child[len(parent):]
-       if len(extra) == 0 {
+       if extra == "" {
                return false
        }
        // Not just a file with more stuff on the end.
index d4a0368e11c9bc718844fc214447f2a7b3e49b29..a2f2d1d90eff349b557d249acda94ba272064093 100644 (file)
@@ -133,7 +133,7 @@ func (cr *cipherWriter) Write(b []byte) (n int, err error) {
                        return ret
                }
        }()
-       cr.c.XORKeyStream(be[:], b)
+       cr.c.XORKeyStream(be, b)
        n, err = cr.w.Write(be[:len(b)])
        if n != len(b) {
                // The cipher will have advanced beyond the callers stream position.
index b10ca8f92a4b980bba4fa41d2c4a1757ed453858..f13c259f6c19f9c4bb400ae0ed0951fb86305a62 100644 (file)
@@ -87,7 +87,7 @@ func handshakeTest(t testing.TB, ia []byte, aData, bData string, cryptoProvides
                go b.Write([]byte(bData))
                // Need to be exact here, as there are several reads, and net.Pipe is most synchronous.
                msg := make([]byte, len(ia)+len(aData))
-               n, _ := io.ReadFull(b, msg[:])
+               n, _ := io.ReadFull(b, msg)
                if n != len(msg) {
                        t.FailNow()
                }
index 0fe980c7a21c77b3ae11ad9f89f6c2f2ed353099..004825c8e572558f1adf1538caaa93dd8df9f8a4 100644 (file)
@@ -92,7 +92,7 @@ func (tc *TrackerClient) doWebsocket() error {
                                }
                        case <-closeChan:
                                return
-                       default:
+
                        }
                }
        }()