From: Jeff Halter Date: Thu, 20 Apr 2023 00:21:18 +0000 (-0700) Subject: Ran 'golangci-lint run -E gocritic,whitespace --fix' 🤞 X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/commitdiff_plain/aeb97482e923b5c441dd59e3ca4a7e275ac2b4c2 Ran 'golangci-lint run -E gocritic,whitespace --fix' 🤞 --- diff --git a/cmd/mobius-hotline-client/main.go b/cmd/mobius-hotline-client/main.go index 33100bf..72b581b 100644 --- a/cmd/mobius-hotline-client/main.go +++ b/cmd/mobius-hotline-client/main.go @@ -74,7 +74,6 @@ func main() { client := hotline.NewUIClient(*configDir, logger) client.DebugBuf = db client.UI.Start() - } func newZapCore(level zapcore.Level, syncer zapcore.WriteSyncer) zapcore.Core { diff --git a/cmd/mobius-hotline-server/main.go b/cmd/mobius-hotline-server/main.go index 4fa28c2..c5eea27 100644 --- a/cmd/mobius-hotline-server/main.go +++ b/cmd/mobius-hotline-server/main.go @@ -87,7 +87,6 @@ func main() { logger.Fatal(err) } logger.Infow("Config dir initialized at " + *configDir) - } else { logger.Infow("Existing config dir found. Skipping initialization.") } @@ -232,7 +231,6 @@ func copyDir(src, dst string) error { } f.Close() } - } return nil diff --git a/hotline/client.go b/hotline/client.go index fa204e2..3598a00 100644 --- a/hotline/client.go +++ b/hotline/client.go @@ -317,7 +317,6 @@ func handleGetFileNameList(c *Client, t *Transaction) (res []Transaction, err er node.SetReference(&fn) root.AddChild(node) } - } centerFlex := tview.NewFlex(). diff --git a/hotline/file_store.go b/hotline/file_store.go index 3c46fae..1525e2e 100644 --- a/hotline/file_store.go +++ b/hotline/file_store.go @@ -80,7 +80,6 @@ func (mfs *MockFileStore) Stat(name string) (os.FileInfo, error) { args := mfs.Called(name) if args.Get(0) == nil { return nil, args.Error(1) - } return args.Get(0).(os.FileInfo), args.Error(1) } diff --git a/hotline/files.go b/hotline/files.go index 1eeef59..9c3efe2 100644 --- a/hotline/files.go +++ b/hotline/files.go @@ -78,14 +78,13 @@ func getFileNameList(path string, ignoreList []string) (fields []Field, err erro } binary.BigEndian.PutUint32(fnwi.FileSize[:], c) - copy(fnwi.Type[:], []byte("fldr")[:]) - copy(fnwi.Creator[:], fileCreator[:]) + copy(fnwi.Type[:], []byte("fldr")) + copy(fnwi.Creator[:], fileCreator) } else { binary.BigEndian.PutUint32(fnwi.FileSize[:], uint32(rFile.Size())) - copy(fnwi.Type[:], []byte(fileTypeFromFilename(rFile.Name()).TypeCode)[:]) - copy(fnwi.Creator[:], []byte(fileTypeFromFilename(rFile.Name()).CreatorCode)[:]) + copy(fnwi.Type[:], []byte(fileTypeFromFilename(rFile.Name()).TypeCode)) + copy(fnwi.Creator[:], []byte(fileTypeFromFilename(rFile.Name()).CreatorCode)) } - } else if file.IsDir() { dir, err := os.ReadDir(filepath.Join(path, file.Name())) if err != nil { @@ -100,8 +99,8 @@ func getFileNameList(path string, ignoreList []string) (fields []Field, err erro } binary.BigEndian.PutUint32(fnwi.FileSize[:], c) - copy(fnwi.Type[:], []byte("fldr")[:]) - copy(fnwi.Creator[:], fileCreator[:]) + copy(fnwi.Type[:], []byte("fldr")) + copy(fnwi.Creator[:], fileCreator) } else { // the Hotline protocol does not support fileWrapper sizes > 4GiB due to the 4 byte field size, so skip them if fileInfo.Size() > 4294967296 { @@ -113,16 +112,16 @@ func getFileNameList(path string, ignoreList []string) (fields []Field, err erro return nil, err } - copy(fnwi.FileSize[:], hlFile.totalSize()[:]) - copy(fnwi.Type[:], hlFile.ffo.FlatFileInformationFork.TypeSignature[:]) - copy(fnwi.Creator[:], hlFile.ffo.FlatFileInformationFork.CreatorSignature[:]) + copy(fnwi.FileSize[:], hlFile.totalSize()) + copy(fnwi.Type[:], hlFile.ffo.FlatFileInformationFork.TypeSignature) + copy(fnwi.Creator[:], hlFile.ffo.FlatFileInformationFork.CreatorSignature) } strippedName := strings.Replace(file.Name(), ".incomplete", "", -1) nameSize := make([]byte, 2) binary.BigEndian.PutUint16(nameSize, uint16(len(strippedName))) - copy(fnwi.NameSize[:], nameSize[:]) + copy(fnwi.NameSize[:], nameSize) fnwi.name = []byte(strippedName) diff --git a/hotline/flattened_file_object.go b/hotline/flattened_file_object.go index 63a189a..c57de19 100644 --- a/hotline/flattened_file_object.go +++ b/hotline/flattened_file_object.go @@ -110,7 +110,7 @@ func (ffo *flattenedFileObject) TransferSize(offset int64) []byte { resForkSize := binary.BigEndian.Uint32(ffo.FlatFileResForkHeader.DataSize[:]) size := make([]byte, 4) - binary.BigEndian.PutUint32(size[:], dataSize+resForkSize+uint32(payloadSize)-uint32(offset)) + binary.BigEndian.PutUint32(size, dataSize+resForkSize+uint32(payloadSize)-uint32(offset)) return size } diff --git a/hotline/server.go b/hotline/server.go index 4b36cf6..500087a 100644 --- a/hotline/server.go +++ b/hotline/server.go @@ -105,7 +105,6 @@ func (s *Server) ListenAndServe(ctx context.Context, cancelRoot context.CancelFu ln, err := net.Listen("tcp", fmt.Sprintf("%s:%v", "", s.Port+1)) if err != nil { s.Logger.Fatal(err) - } s.Logger.Fatal(s.ServeFileTransfers(ctx, ln)) @@ -740,7 +739,7 @@ func (s *Server) NewPrivateChat(cc *ClientConn) []byte { randID := make([]byte, 4) rand.Read(randID) - data := binary.BigEndian.Uint32(randID[:]) + data := binary.BigEndian.Uint32(randID) s.PrivateChats[data] = &PrivateChat{ ClientConn: make(map[uint16]*ClientConn), diff --git a/hotline/transaction_handlers.go b/hotline/transaction_handlers.go index 813d25c..137b2a0 100644 --- a/hotline/transaction_handlers.go +++ b/hotline/transaction_handlers.go @@ -808,7 +808,7 @@ func HandleUpdateUser(cc *ClientConn, t *Transaction) (res []Transaction, err er } newAccess := accessBitmap{} - copy(newAccess[:], getField(FieldUserAccess, &subFields).Data[:]) + copy(newAccess[:], getField(FieldUserAccess, &subFields).Data) // Prevent account from creating new account with greater permission for i := 0; i < 64; i++ { @@ -846,7 +846,7 @@ func HandleNewUser(cc *ClientConn, t *Transaction) (res []Transaction, err error } newAccess := accessBitmap{} - copy(newAccess[:], t.GetField(FieldUserAccess).Data[:]) + copy(newAccess[:], t.GetField(FieldUserAccess).Data) // Prevent account from creating new account with greater permission for i := 0; i < 64; i++ { @@ -1605,7 +1605,6 @@ func HandleUploadFile(cc *ClientConn, t *Transaction) (res []Transaction, err er // client has requested to resume a partially transferred file if transferOptions != nil { - fileInfo, err := cc.Server.FS.Stat(fullFilePath + incompleteFileSuffix) if err != nil { return res, err diff --git a/hotline/transaction_handlers_test.go b/hotline/transaction_handlers_test.go index 751590e..ff1a53c 100644 --- a/hotline/transaction_handlers_test.go +++ b/hotline/transaction_handlers_test.go @@ -1056,7 +1056,6 @@ func TestHandleNewFolder(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - gotRes, err := HandleNewFolder(tt.args.cc, tt.args.t) if (err != nil) != tt.wantErr { t.Errorf("HandleNewFolder() error = %v, wantErr %v", err, tt.wantErr) @@ -1175,7 +1174,6 @@ func TestHandleUploadFile(t *testing.T) { } tranAssertEqual(t, tt.wantRes, gotRes) - }) } } @@ -3781,7 +3779,6 @@ func TestHandleGetNewsArtNameList(t *testing.T) { return } tranAssertEqual(t, tt.wantRes, gotRes) - }) } } @@ -3942,7 +3939,7 @@ func TestHandleNewNewsFldr(t *testing.T) { // }, // }, // wantErr: assert.Error, - //}, + // }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/hotline/ui.go b/hotline/ui.go index 45c452c..a60aad2 100644 --- a/hotline/ui.go +++ b/hotline/ui.go @@ -350,7 +350,6 @@ func (ui *UI) renderServerUI() *tview.Flex { // Post news if event.Key() == tcell.KeyCtrlP { - newsFlex := tview.NewFlex() newsFlex.SetBorderPadding(0, 0, 1, 1) newsPostTextArea := tview.NewTextView()