polkadot-js/tools

View on GitHub

Showing 16 of 16 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

function updateCurrent (header: Header): void {
  if (currentBlockNumber && header.number.eq(currentBlockNumber.toBn())) {
    return;
  }

Severity: Major
Found in packages/monitor-rpc/src/runcli.ts and 1 other location - About 4 hrs to fix
packages/json-serve/src/runcli.ts on lines 70..79

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 116.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

function onNewHead (header: Header): void {
  if (currentBlockNumber && header.number.eq(currentBlockNumber.toBn())) {
    return;
  }

Severity: Major
Found in packages/json-serve/src/runcli.ts and 1 other location - About 4 hrs to fix
packages/monitor-rpc/src/runcli.ts on lines 49..58

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 116.

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

Further Reading

Function main has 95 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function main (): Promise<number> {
  const [[regA, metaA, verA], [regB, metaB, verB]] = await Promise.all([getMetadata(ws1), getMetadata(ws2)]);
  const a = metaA.asLatest;
  const b = metaB.asLatest;

Severity: Major
Found in packages/metadata-cmp/src/runcli.ts - About 3 hrs to fix

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    const { port, ws } = yargs(hideBin(process.argv))
      .options({
        port: {
          default: 9099,
          description: 'The HTTP port to listen on',
    Severity: Major
    Found in packages/json-serve/src/runcli.ts and 1 other location - About 3 hrs to fix
    packages/monitor-rpc/src/runcli.ts on lines 20..34

    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 96.

    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

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    const { port, ws } = yargs(hideBin(process.argv))
      .options({
        port: {
          default: 9099,
          description: 'The HTTP port to listen on',
    Severity: Major
    Found in packages/monitor-rpc/src/runcli.ts and 1 other location - About 3 hrs to fix
    packages/json-serve/src/runcli.ts on lines 22..36

    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 96.

    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

    Further Reading

    Function logArray has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    function logArray (pad: number, title: string, pre: string, arr: string[], chunkSize: number) {
    Severity: Minor
    Found in packages/metadata-cmp/src/runcli.ts - About 35 mins to fix

      Function log has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function log (pad: number, title: string, pre: string, text: string, post?: string) {
      Severity: Minor
      Found in packages/metadata-cmp/src/runcli.ts - About 35 mins to fix

        Function cmdSubmit has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        export default async function cmdSubmit (account: string, blocks: number | undefined, endpoint = '', tx: string | undefined, [txName, ...params]: string[]): Promise<void> {
        Severity: Minor
        Found in packages/signer-cli/src/cmdSubmit.ts - About 35 mins to fix

          Function createLog has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          function createLog (pad: number, title: string, pre: string, text: string, post?: string): string {
          Severity: Minor
          Found in packages/metadata-cmp/src/runcli.ts - About 35 mins to fix

            Function cmdSendOffline has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            export default async function cmdSendOffline (account: string, blocks: number | undefined, endpoint = '', nonce: number | undefined | Index, [tx, ...params]: string[]): Promise<void> {
            Severity: Minor
            Found in packages/signer-cli/src/cmdSendOffline.ts - About 35 mins to fix

              Function cmdSendOffline has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              export default async function cmdSendOffline (account: string, blocks: number | undefined, endpoint = '', nonce: number | undefined | Index, [tx, ...params]: string[]): Promise<void> {
                const provider = new WsProvider(endpoint);
                const api = await ApiPromise.create({ provider });
                const options: Partial<SignerOptions> = { signer: new RawSigner() };
              
              
              Severity: Minor
              Found in packages/signer-cli/src/cmdSendOffline.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

              Identical blocks of code found in 4 locations. Consider refactoring.
              Open

              main().catch((error): void => {
                console.error(error);
              
                process.exit(1);
              });
              Severity: Major
              Found in packages/json-serve/src/runcli.ts and 3 other locations - About 35 mins to fix
              packages/api-cli/src/runcli.ts on lines 315..319
              packages/monitor-rpc/src/runcli.ts on lines 90..94
              packages/signer-cli/src/runcli.ts on lines 114..118

              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 46.

              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

              Further Reading

              Identical blocks of code found in 4 locations. Consider refactoring.
              Open

              main().catch((error): void => {
                console.error(error);
              
                process.exit(1);
              });
              Severity: Major
              Found in packages/signer-cli/src/runcli.ts and 3 other locations - About 35 mins to fix
              packages/api-cli/src/runcli.ts on lines 315..319
              packages/json-serve/src/runcli.ts on lines 127..131
              packages/monitor-rpc/src/runcli.ts on lines 90..94

              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 46.

              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

              Further Reading

              Identical blocks of code found in 4 locations. Consider refactoring.
              Open

              main().catch((error): void => {
                console.error(error);
              
                process.exit(1);
              });
              Severity: Major
              Found in packages/api-cli/src/runcli.ts and 3 other locations - About 35 mins to fix
              packages/json-serve/src/runcli.ts on lines 127..131
              packages/monitor-rpc/src/runcli.ts on lines 90..94
              packages/signer-cli/src/runcli.ts on lines 114..118

              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 46.

              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

              Further Reading

              Identical blocks of code found in 4 locations. Consider refactoring.
              Open

              main().catch((error): void => {
                console.error(error);
              
                process.exit(1);
              });
              Severity: Major
              Found in packages/monitor-rpc/src/runcli.ts and 3 other locations - About 35 mins to fix
              packages/api-cli/src/runcli.ts on lines 315..319
              packages/json-serve/src/runcli.ts on lines 127..131
              packages/signer-cli/src/runcli.ts on lines 114..118

              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 46.

              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

              Further Reading

              Function calculateAtOne has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function calculateAtOne (atOffset: number, test: string[], address: string): GeneratorCalculation {
                return {
                  count: test.reduce((count, c, index): number => {
                    if (index === count) {
                      count += (c === '?' || c === address.charAt(index + atOffset)) ? 1 : 0;
              Severity: Minor
              Found in packages/vanitygen/src/calculate.ts - About 25 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

              Severity
              Category
              Status
              Source
              Language