Showing 829 of 829 total issues
Method Store.ApplyGenesis
has 5 return statements (exceeds 4 allowed). Open
func (s *Store) ApplyGenesis(g *genesis.Genesis, genesisAtropos hash.Event, appHash common.Hash) error {
if g == nil {
return fmt.Errorf("genesis config shouldn't be nil")
}
if len(g.Alloc.Validators) == 0 {
Method EventHeaderData.UnmarshalBinary
has 5 return statements (exceeds 4 allowed). Open
func (e *EventHeaderData) UnmarshalBinary(raw []byte) (err error) {
defer func() {
if r := recover(); r != nil {
err = ErrInvalidEncoding
}
Method PublicTransactionPoolAPI.GetTransactionReceipt
has 5 return statements (exceeds 4 allowed). Open
func (s *PublicTransactionPoolAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error) {
tx, blockNumber, index, err := s.b.GetTransaction(ctx, hash)
if tx == nil || err != nil {
return nil, err
}
Method Helper.AddSection
has 5 return statements (exceeds 4 allowed). Open
func (d *Helper) AddSection(name, after string) error {
if name == "" {
return nil
}
Method SyncedPool.checkDbsSynced
has 5 return statements (exceeds 4 allowed). Open
func (p *SyncedPool) checkDbsSynced() error {
p.Lock()
defer p.Unlock()
var (
Method txList.Filter
has 5 return statements (exceeds 4 allowed). Open
func (l *txList) Filter(costLimit *big.Int, gasLimit uint64) (types.Transactions, types.Transactions) {
// If all transactions are below the threshold, short circuit
if l.costcap.Cmp(costLimit) <= 0 && l.gascap <= gasLimit {
return nil, nil
}
Function parseFakeGen
has 5 return statements (exceeds 4 allowed). Open
func parseFakeGen(s string) (num int, vaccs genesis.VAccounts, err error) {
var i64 uint64
parts := strings.SplitN(s, "/", 2)
if len(parts) != 2 {
Method Index.Push
has 5 return statements (exceeds 4 allowed). Open
func (tt *Index) Push(recs ...*types.Log) error {
for _, rec := range recs {
if len(rec.Topics) > MaxCount {
return ErrTooManyTopics
}
Function exportEvents
has 5 return statements (exceeds 4 allowed). Open
func exportEvents(ctx *cli.Context) error {
if len(ctx.Args()) < 1 {
utils.Fatalf("This command requires an argument.")
}
Function writeTo
has 5 return statements (exceeds 4 allowed). Open
func writeTo(parent string, t *ast.Table, w io.Writer) (err error) {
var fullName string
if parent != "" {
fullName = parent + "." + t.Name
} else {
Method PublicTransactionPoolAPI.GetTransactionByHash
has 5 return statements (exceeds 4 allowed). Open
func (s *PublicTransactionPoolAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) (*RPCTransaction, error) {
// Try to return an already finalized transaction
tx, blockNumber, index, err := s.b.GetTransaction(ctx, hash)
if err != nil {
return nil, err
Method Helper.getKVData
has 5 return statements (exceeds 4 allowed). Open
func (d *Helper) getKVData(name, sectionName string) (*ast.KeyValue, *ast.Table, error) {
sect, err := d.FindSection(sectionName)
if err != nil {
return nil, nil, err
}
Method Emitter.maxGasPowerToUse
has 5 return statements (exceeds 4 allowed). Open
func (em *Emitter) maxGasPowerToUse(e *inter.Event) uint64 {
// No txs in epoch tail, because tail events are unlikely to confirm
{
if em.isEpochTail(e) {
return 0
Method PublicFilterAPI.Logs
has 5 return statements (exceeds 4 allowed). Open
func (api *PublicFilterAPI) Logs(ctx context.Context, crit FilterCriteria) (*rpc.Subscription, error) {
notifier, supported := rpc.NotifierFromContext(ctx)
if !supported {
return &rpc.Subscription{}, rpc.ErrNotificationsUnsupported
}
Method Emitter.isAllowedToEmit
has 5 return statements (exceeds 4 allowed). Open
func (em *Emitter) isAllowedToEmit(e *inter.Event, selfParent *inter.EventHeaderData) bool {
passedTime := e.ClaimedTime.Time().Sub(em.prevEmittedTime)
// Slow down emitting if power is low
{
threshold := em.config.NoTxsThreshold
Method EthAPIBackend.GetFullEventID
has 5 return statements (exceeds 4 allowed). Open
func (b *EthAPIBackend) GetFullEventID(shortEventID string) (hash.Event, error) {
s := strings.Split(shortEventID, ":")
if len(s) == 1 {
// it's a full hash
return hash.HexToEventHash(shortEventID), nil
Method Emitter.createEvent
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (em *Emitter) createEvent(poolTxs map[common.Address]types.Transactions) *inter.Event {
if em.myStakerID == 0 {
// not a validator
return nil
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Similar blocks of code found in 4 locations. Consider refactoring. Open
func (_Contract *ContractSession) LockedStakes(arg0 *big.Int) (struct {
FromEpoch *big.Int
EndTime *big.Int
Duration *big.Int
}, error) {
- 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 105.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
func (_Contract *ContractTransactor) PrepareToWithdrawDelegationPartial(opts *bind.TransactOpts, wrID *big.Int, toStakerID *big.Int, amount *big.Int) (*types.Transaction, error) {
return _Contract.contract.Transact(opts, "prepareToWithdrawDelegationPartial", wrID, toStakerID, amount)
}
- 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 105.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
func (_Contract *ContractTransactor) PrepareToWithdrawDelegationPartial(opts *bind.TransactOpts, wrID *big.Int, toStakerID *big.Int, amount *big.Int) (*types.Transaction, error) {
return _Contract.contract.Transact(opts, "prepareToWithdrawDelegationPartial", wrID, toStakerID, amount)
}
- 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 105.
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