Showing 512 of 512 total issues
Identical blocks of code found in 3 locations. Consider refactoring. Open
func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derivedAddresses map[string]generator.AccountInfo, mnemonic *string) (*settings.Settings, error) {
chatKeyString := derivedAddresses[pathDefaultChat].PublicKey
defaultSettings := &settings.Settings{}
defaultSettings.KeyUID = generatedAccountInfo.KeyUID
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 536.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
HopL2OptimismBridgeSession
has 53 methods (exceeds 21 allowed). Consider refactoring. Open
type HopL2OptimismBridgeSession struct {
Contract *HopL2OptimismBridge // Generic contract binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
File messenger_handlers.go
has 1120 lines of code (exceeds 900 allowed). Consider refactoring. Open
//nolint
// Code generated by generate_handlers.go. DO NOT EDIT.
// source: generate_handlers.go
package protocol
File sync_device_test.go
has 1116 lines of code (exceeds 900 allowed). Consider refactoring. Open
package pairing
import (
"context"
"encoding/json"
ClientWithFallback
has 52 methods (exceeds 21 allowed). Consider refactoring. Open
type ClientWithFallback struct {
ChainID uint64
main *ethclient.Client
fallback *ethclient.Client
mainLimiter *RPCRpsLimiter
sqlitePersistence
has 52 methods (exceeds 21 allowed). Consider refactoring. Open
func (db sqlitePersistence) saveProfileShowcasePreferencesClock(tx *sql.Tx, clock uint64) error {
_, err := tx.Exec(upsertProfileShowcasePreferencesQuery, clock, clock)
return err
}
HopL2ArbitrumBridgeSession
has 51 methods (exceeds 21 allowed). Consider refactoring. Open
type HopL2ArbitrumBridgeSession struct {
Contract *HopL2ArbitrumBridge // Generic contract binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
File messenger_mention.go
has 1102 lines of code (exceeds 900 allowed). Consider refactoring. Open
package protocol
// this is a reimplementation of the mention feature in status-react
// reference implementation: https://github.com/status-im/status-react/blob/972347963498fc4a2bb8f85541e79ed0541698da/src/status_im/chat/models/mentions.cljs#L1
import (
HopL1HopBridgeSession
has 49 methods (exceeds 21 allowed). Consider refactoring. Open
type HopL1HopBridgeSession struct {
Contract *HopL1HopBridge // Generic contract binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
Database
has 49 methods (exceeds 21 allowed). Consider refactoring. Open
type Database struct {
settings.DatabaseSettingsManager
*notificationssettings.NotificationsSettings
*walletsettings.WalletSettings
db *sql.DB
StatusNode
has 49 methods (exceeds 21 allowed). Consider refactoring. Open
func (b *StatusNode) initServices(config *params.NodeConfig, mediaServer *server.MediaServer) error {
accountsFeed := &event.Feed{}
settingsFeed := &event.Feed{}
accDB, err := accounts.NewDB(b.appDB)
if err != nil {
File handlers.go
has 1082 lines of code (exceeds 900 allowed). Consider refactoring. Open
package server
import (
"bytes"
"database/sql"
File commands_sequential.go
has 1076 lines of code (exceeds 900 allowed). Consider refactoring. Open
package transfer
import (
"context"
"math/big"
HopL1Erc20BridgeSession
has 46 methods (exceeds 21 allowed). Consider refactoring. Open
type HopL1Erc20BridgeSession struct {
Contract *HopL1Erc20Bridge // Generic contract binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
gethWakuV2Wrapper
has 46 methods (exceeds 21 allowed). Consider refactoring. Open
type gethWakuV2Wrapper struct {
waku *wakuv2.Waku
}
GethWakuWrapper
has 46 methods (exceeds 21 allowed). Consider refactoring. Open
type GethWakuWrapper struct {
waku *waku.Waku
}
HopL1EthBridgeSession
has 45 methods (exceeds 21 allowed). Consider refactoring. Open
type HopL1EthBridgeSession struct {
Contract *HopL1EthBridge // Generic contract binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
TestClient
has 45 methods (exceeds 21 allowed). Consider refactoring. Open
type TestClient struct {
t *testing.T
// [][block, newBalance, nonceDiff]
balances map[common.Address][][]int
outgoingERC20Transfers map[common.Address][]testERC20Transfer
File messenger_contacts.go
has 1065 lines of code (exceeds 900 allowed). Consider refactoring. Open
package protocol
import (
"context"
"crypto/ecdsa"
MessengerSuite
has 44 methods (exceeds 21 allowed). Consider refactoring. Open
type MessengerSuite struct {
MessengerBaseTestSuite
}