packages/client-sync/src/index.ts
File index.ts
has 253 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
// Copyright 2017-2019 @polkadot/client-sync authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Config } from '@polkadot/client/types';
Function queueBlocks
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public queueBlocks (peer: PeerInterface, { blocks, id }: BlockResponse): void {
const request = this.blockRequests.get(peer.id);
const bestNumber = this.chain.blocks.bestNumber.get();
this.blockRequests.delete(peer.id);
Function queueBlocks
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
public queueBlocks (peer: PeerInterface, { blocks, id }: BlockResponse): void {
const request = this.blockRequests.get(peer.id);
const bestNumber = this.chain.blocks.bestNumber.get();
this.blockRequests.delete(peer.id);
- 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
Function blocksFromNumber
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
private blocksFromNumber (count: number, from: BN, to: Hash | null, increment: BN): Uint8Array[] {
const best = this.chain.blocks.bestNumber.get();
const blocks: Uint8Array[] = [];
let current = from;
- 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"