trufflesuite/truffle

View on GitHub

Showing 1,401 of 1,401 total issues

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

    while (result.done === false) {
      let request = result.value;
      let response: Uint8Array;
      switch (request.type) {
        case "code":
Severity: Major
Found in packages/decoder/lib/decoders.ts and 2 other locations - About 4 hrs to fix
packages/decoder/lib/decoders.ts on lines 521..534
packages/decoder/lib/decoders.ts on lines 636..649

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

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 parseQuotesAndEscapes has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

function parseQuotesAndEscapes(args, escapeCharacters = "\\") {
  const quoteCharacters = "\"'"; //note we will handle the two quote types differently
  let argArray = [];
  let currentArg = "";
  let currentQuote = undefined;
Severity: Minor
Found in packages/core/lib/command-utils.js - About 4 hrs 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

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

      if (this.session.view(session.status.loaded)) {
        const errorIndex = this.session.view(
          stacktrace.current.innerErrorIndex
        );
        if (errorIndex !== null) {
Severity: Major
Found in packages/core/lib/debug/interpreter.js and 1 other location - About 4 hrs to fix
packages/core/lib/debug/interpreter.js on lines 439..460

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

          if (!this.session.view(evm.current.step.isExceptionalHalting)) {
            const errorIndex = this.session.view(
              stacktrace.current.innerErrorIndex
            );
            if (errorIndex !== null) {
Severity: Major
Found in packages/core/lib/debug/interpreter.js and 1 other location - About 4 hrs to fix
packages/core/lib/debug/interpreter.js on lines 472..490

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

File etherscan.ts has 335 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import debugModule from "debug";
const debug = debugModule("source-fetcher:etherscan");
// untyped import since no @types/web3-utils exists
const Web3Utils = require("web3-utils");

Severity: Minor
Found in packages/source-fetcher/lib/etherscan.ts - About 4 hrs to fix

    data has 32 functions (exceeds 20 allowed). Consider refactoring.
    Open

      current: {
        /**
         * data.current.state
         */
        state: {
    Severity: Minor
    Found in packages/debugger/lib/data/selectors/index.js - About 4 hrs to fix

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

              switch (errorNode.nodeType) {
                case "RevertStatement":
                  //I don't think this case should happen, but I'm including it
                  //for extra certainty
                  errorNode = errorNode.errorCall;
      Severity: Major
      Found in packages/debugger/lib/data/selectors/index.js and 1 other location - About 4 hrs to fix
      packages/debugger/lib/data/selectors/index.js on lines 1251..1270

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

      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

              switch (eventNode.nodeType) {
                case "EmitStatement":
                  //I don't think this case should happen, but I'm including it
                  //for extra certainty
                  eventNode = eventNode.eventCall;
      Severity: Major
      Found in packages/debugger/lib/data/selectors/index.js and 1 other location - About 4 hrs to fix
      packages/debugger/lib/data/selectors/index.js on lines 1217..1236

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

      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 3 locations. Consider refactoring.
      Open

        export const configure = <C extends Config>(
          options: Options<C>
        ): (<I extends Base.Input<Batch<C>>, O extends Base.Output<Batch<C>>>(
          inputs: Base.Inputs<Batch<C>, I>
        ) => Process<Base.Outputs<Batch<C>, I & O>>) =>
      Severity: Major
      Found in packages/db/src/project/loadCompile/batch.ts and 2 other locations - About 3 hrs to fix
      packages/db/src/project/loadCompile/batch.ts on lines 60..102
      packages/db/src/project/loadMigrate/batch.ts on lines 89..174

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

      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 3 locations. Consider refactoring.
      Open

        export const configure = <C extends Config>(
          options: Options<C>
        ): (<I extends Base.Input<Batch<C>>, O extends Base.Output<Batch<C>>>(
          inputs: Base.Inputs<Batch<C>, I>
        ) => Process<Base.Outputs<Batch<C>, I & O>>) =>
      Severity: Major
      Found in packages/db/src/project/loadCompile/batch.ts and 2 other locations - About 3 hrs to fix
      packages/db/src/project/loadCompile/batch.ts on lines 133..185
      packages/db/src/project/loadMigrate/batch.ts on lines 89..174

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

      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 3 locations. Consider refactoring.
      Open

      export const configure = <C extends Config>(
        options: Options<C>
      ): (<I extends Base.Input<Batch<C>>, O extends Base.Output<Batch<C>>>(
        inputs: Base.Inputs<Batch<C>, I>
      ) => Process<Base.Outputs<Batch<C>, I & O>>) =>
      Severity: Major
      Found in packages/db/src/project/loadMigrate/batch.ts and 2 other locations - About 3 hrs to fix
      packages/db/src/project/loadCompile/batch.ts on lines 60..102
      packages/db/src/project/loadCompile/batch.ts on lines 133..185

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

      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 constructSlot has 97 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private async constructSlot(
          variable: number | string,
          ...indices: unknown[]
        ): Promise<{ slot?: Storage.Slot; type?: Format.Types.Type }> {
          //base case: we need to locate the variable and its definition
      Severity: Major
      Found in packages/decoder/lib/decoders.ts - About 3 hrs to fix

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

          async resolve(importPath: string) {
            if (importPath === `truffle${path.sep}DeployedAddresses.sol`) {
              const sourceFiles = await findContracts(this.options.contracts_directory);
        
              const buildDirFiles: string[] = fse.existsSync(
        Severity: Major
        Found in packages/resolver/lib/sources/truffle/index.ts - About 3 hrs to fix

          Function errors has 94 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            errors(kind, data) {
              const prefix = " *** Deployment Failed ***\n\n";
          
              const kinds = {
                migrateErr: () =>
          Severity: Major
          Found in packages/events/defaultSubscribers/migrate/Messages.js - About 3 hrs to fix

            Function parseParameterListWithRemainder has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
            Open

            function parseParameterListWithRemainder(parameterList: string): {
              parameters: Parameter[];
              remaining: string;
            } {
              if (parameterList === "") {
            Severity: Minor
            Found in packages/abi-utils/lib/parse.ts - About 3 hrs 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

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

              compilations: {
                resource: DataModel.Compilation;
                input: DataModel.CompilationInput;
                idFields: ["compiler", "sources"];
                names: {
            Severity: Major
            Found in packages/db/src/resources/types.ts and 4 other locations - About 3 hrs to fix
            packages/db/src/resources/types.ts on lines 13..25
            packages/db/src/resources/types.ts on lines 26..38
            packages/db/src/resources/types.ts on lines 79..91
            packages/db/src/resources/types.ts on lines 133..145

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

            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 5 locations. Consider refactoring.
            Open

              nameRecords: {
                resource: DataModel.NameRecord;
                input: DataModel.NameRecordInput;
                idFields: ["resource", "previous"];
                names: {
            Severity: Major
            Found in packages/db/src/resources/types.ts and 4 other locations - About 3 hrs to fix
            packages/db/src/resources/types.ts on lines 13..25
            packages/db/src/resources/types.ts on lines 26..38
            packages/db/src/resources/types.ts on lines 39..51
            packages/db/src/resources/types.ts on lines 133..145

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

            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 5 locations. Consider refactoring.
            Open

              sources: {
                resource: DataModel.Source;
                input: DataModel.SourceInput;
                idFields: ["contents", "sourcePath"];
                names: {
            Severity: Major
            Found in packages/db/src/resources/types.ts and 4 other locations - About 3 hrs to fix
            packages/db/src/resources/types.ts on lines 26..38
            packages/db/src/resources/types.ts on lines 39..51
            packages/db/src/resources/types.ts on lines 79..91
            packages/db/src/resources/types.ts on lines 133..145

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

            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 5 locations. Consider refactoring.
            Open

              bytecodes: {
                resource: DataModel.Bytecode;
                input: DataModel.BytecodeInput;
                idFields: ["bytes", "linkReferences"];
                names: {
            Severity: Major
            Found in packages/db/src/resources/types.ts and 4 other locations - About 3 hrs to fix
            packages/db/src/resources/types.ts on lines 13..25
            packages/db/src/resources/types.ts on lines 39..51
            packages/db/src/resources/types.ts on lines 79..91
            packages/db/src/resources/types.ts on lines 133..145

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

            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 5 locations. Consider refactoring.
            Open

              networkGenealogies: {
                resource: DataModel.NetworkGenealogy;
                input: DataModel.NetworkGenealogyInput;
                idFields: ["ancestor", "descendant"];
                names: {
            Severity: Major
            Found in packages/db/src/resources/types.ts and 4 other locations - About 3 hrs to fix
            packages/db/src/resources/types.ts on lines 13..25
            packages/db/src/resources/types.ts on lines 26..38
            packages/db/src/resources/types.ts on lines 39..51
            packages/db/src/resources/types.ts on lines 79..91

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

            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

            Severity
            Category
            Status
            Source
            Language