Skip to content

Commit 0cdb33e

Browse files
withshubhanacrolix
authored andcommitted
fixed code quality issues using DeepSource
* Added .deepsource.toml * Removed empty default in select * Removed unnecessary use of slice * Fixed check for empty string
1 parent f5915ad commit 0cdb33e

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

.deepsource.toml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version = 1
2+
3+
test_patterns = ["**/*_test.go"]
4+
5+
[[analyzers]]
6+
name = "go"
7+
enabled = true
8+
9+
[analyzers.meta]
10+
import_paths = ["github.com/anacrolix/torrent"]
11+

fs/torrentfs.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ var (
6060
)
6161

6262
func isSubPath(parent, child string) bool {
63-
if len(parent) == 0 {
63+
if parent == "" {
6464
return len(child) > 0
6565
}
6666
if !strings.HasPrefix(child, parent) {
6767
return false
6868
}
6969
extra := child[len(parent):]
70-
if len(extra) == 0 {
70+
if extra == "" {
7171
return false
7272
}
7373
// Not just a file with more stuff on the end.

mse/mse.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func (cr *cipherWriter) Write(b []byte) (n int, err error) {
133133
return ret
134134
}
135135
}()
136-
cr.c.XORKeyStream(be[:], b)
136+
cr.c.XORKeyStream(be, b)
137137
n, err = cr.w.Write(be[:len(b)])
138138
if n != len(b) {
139139
// The cipher will have advanced beyond the callers stream position.

mse/mse_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func handshakeTest(t testing.TB, ia []byte, aData, bData string, cryptoProvides
8787
go b.Write([]byte(bData))
8888
// Need to be exact here, as there are several reads, and net.Pipe is most synchronous.
8989
msg := make([]byte, len(ia)+len(aData))
90-
n, _ := io.ReadFull(b, msg[:])
90+
n, _ := io.ReadFull(b, msg)
9191
if n != len(msg) {
9292
t.FailNow()
9393
}

webtorrent/tracker_client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (tc *TrackerClient) doWebsocket() error {
9292
}
9393
case <-closeChan:
9494
return
95-
default:
95+
9696
}
9797
}
9898
}()

0 commit comments

Comments
 (0)