polkadot-js/client

View on GitHub
packages/client-sync/src/index.ts

Summary

Maintainability
B
4 hrs
Test Coverage

File index.ts has 253 lines of code (exceeds 250 allowed). Consider refactoring.
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';
Severity: Minor
Found in packages/client-sync/src/index.ts - About 2 hrs to fix

    Function queueBlocks has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    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);
    Severity: Minor
    Found in packages/client-sync/src/index.ts - About 1 hr to fix

      Function queueBlocks has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      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);
      Severity: Minor
      Found in packages/client-sync/src/index.ts - About 1 hr to fix

      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

        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;
      
      
      Severity: Minor
      Found in packages/client-sync/src/index.ts - About 35 mins to fix

      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

      There are no issues that match your filters.

      Category
      Status