trufflesuite/truffle

View on GitHub

Showing 1,401 of 1,401 total issues

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

export const [isAbiValue, isAbiErrorResult, isAbiResult, abiGuards] =
  valueAndResultTypeGuardHelper<
    Format.Values.AbiValue,
    Format.Errors.AbiErrorResult,
    Format.Values.AbiResult
packages/codec-components/src/utils/type-guards/value-and-result/elementary.ts on lines 15..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 87.

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

      (sources, functions) => breakpoint => {
        let adjustedBreakpoint;
        if (breakpoint.node === undefined) {
          let line = breakpoint.line;
          if (line < 0) {
Severity: Minor
Found in packages/debugger/lib/controller/selectors/index.js - About 2 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

Function getProcessedInstructionsForBinary has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  getProcessedInstructionsForBinary: function (sources, binary, sourceMap) {
    if (!sources || !binary) {
      return [];
    }
    debug("sourceMap: %O", sourceMap);
Severity: Major
Found in packages/source-map-utils/index.js - About 2 hrs to fix

    Function constructor has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      constructor(
        projectEncoder: ProjectEncoder,
        compilation: Codec.Compilations.Compilation,
        contract: Codec.Compilations.Contract,
        artifact?: Artifact
    Severity: Major
    Found in packages/encoder/lib/encoders.ts - About 2 hrs to fix

      Function constructor has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        constructor(
          compilations: Compilations.Compilation[],
          provider: Provider,
          ensSettings?: DecoderTypes.EnsSettings,
          selectorDirectory?: DecoderTypes.SelectorDirectorySettings
      Severity: Major
      Found in packages/decoder/lib/decoders.ts - About 2 hrs to fix

        Function decodeTransactionBySelector has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private async decodeTransactionBySelector(
            transaction: DecoderTypes.Transaction,
            data: Uint8Array, //this is redundant but included for convenience
            additionalContexts: Contexts.Contexts,
            context: Contexts.Context | null
        Severity: Major
        Found in packages/decoder/lib/decoders.ts - About 2 hrs to fix

          Function file has 64 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function file(options: RequireOptions) {
            const sourceFilePath = path.resolve(options.file);
          
            expectOptions(options, ["file"]);
          
          
          Severity: Major
          Found in packages/require/lib/index.ts - About 2 hrs to fix

            File index.js has 273 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            const debug = require("debug")("compile-vyper");
            const path = require("path");
            const exec = require("child_process").exec;
            const fs = require("fs");
            const colors = require("colors");
            Severity: Minor
            Found in packages/compile-vyper/index.js - About 2 hrs to fix

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

                    decoding.kind === "function" &&
                    (decoding.abi.name === "aggregate" ||
                      decoding.abi.name === "blockAndAggregate") &&
                    decoding.abi.inputs.length === 1 &&
                    decoding.abi.inputs[0].type === "tuple[]" &&
              Severity: Major
              Found in packages/decoder/lib/decoders.ts and 1 other location - About 2 hrs to fix
              packages/decoder/lib/decoders.ts on lines 1242..1247

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

              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

                    decoding.kind === "function" &&
                    (decoding.abi.name === "tryAggregate" ||
                      decoding.abi.name === "tryBlockAndAggregate") &&
                    decoding.abi.inputs.length === 2 &&
                    decoding.abi.inputs[0].type === "bool" &&
              Severity: Major
              Found in packages/decoder/lib/decoders.ts and 1 other location - About 2 hrs to fix
              packages/decoder/lib/decoders.ts on lines 1072..1077

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

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

                printInstruction(locations = this.locationPrintouts) {
                  const instruction = this.session.view(sourcemapping.current.instruction);
                  const instructions = this.session.view(sourcemapping.current.instructions);
                  const step = this.session.view(trace.step);
                  const traceIndex = this.session.view(trace.index);
              Severity: Major
              Found in packages/core/lib/debug/printer.js - About 2 hrs to fix

                Function editedLines has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  const editedLines = source.contents.split("\n").map((line, index) => {
                    if (line.length === 0) {
                      return line;
                    }
                    const { start, end } = sourceRange;

                  File index.js has 271 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import debugModule from "debug";
                  const debug = debugModule("debugger:txlog:selectors");
                  
                  import { createSelectorTree, createLeaf } from "reselect-tree";
                  
                  
                  Severity: Minor
                  Found in packages/debugger/lib/txlog/selectors/index.js - About 2 hrs to fix

                    ContractInstanceDecoder has 23 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    export class ContractInstanceDecoder {
                      private providerAdapter: ProviderAdapter;
                    
                      private compilation: Compilations.Compilation;
                      private contract: Compilations.Contract;
                    Severity: Minor
                    Found in packages/decoder/lib/decoders.ts - About 2 hrs to fix

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

                              (Codec.Ast.Utils.typeClass(baseExpression) === "array" &&
                                (Codec.Ast.Utils.isReference(node)
                                  ? Codec.Ast.Utils.referenceType(baseExpression) !== "storage"
                                  : !Codec.Ast.Utils.isMapping(node)))
                      Severity: Major
                      Found in packages/debugger/lib/data/sagas/index.js and 1 other location - About 2 hrs to fix
                      packages/debugger/lib/data/sagas/index.js on lines 661..664

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

                      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

                              Codec.Ast.Utils.typeClass(baseExpression) !== "struct" ||
                              (Codec.Ast.Utils.isReference(node)
                                ? Codec.Ast.Utils.referenceType(baseExpression) !== "storage"
                                : !Codec.Ast.Utils.isMapping(node))
                      Severity: Major
                      Found in packages/debugger/lib/data/sagas/index.js and 1 other location - About 2 hrs to fix
                      packages/debugger/lib/data/sagas/index.js on lines 525..528

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

                      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

                        resolveDependencyPath(importPath: string, dependencyPath: string) {
                          if (
                            !(dependencyPath.startsWith("./") || dependencyPath.startsWith("../"))
                          ) {
                            //if it's *not* a relative path, return it unchanged
                      Severity: Major
                      Found in packages/resolver/lib/sources/npm.ts and 1 other location - About 2 hrs to fix
                      packages/resolver/lib/sources/globalnpm.ts on lines 77..86

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

                      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

                        resolveDependencyPath(importPath: string, dependencyPath: string) {
                          if (
                            !(dependencyPath.startsWith("./") || dependencyPath.startsWith("../"))
                          ) {
                            //if it's *not* a relative path, return it unchanged
                      Severity: Major
                      Found in packages/resolver/lib/sources/globalnpm.ts and 1 other location - About 2 hrs to fix
                      packages/resolver/lib/sources/npm.ts on lines 87..96

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

                      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

                      export async function forArtifactAt(
                        artifact: Artifact,
                        address: string,
                        settings: EncoderSettings = {}
                      ): Promise<ContractInstanceEncoder> {
                      Severity: Major
                      Found in packages/encoder/lib/index.ts and 1 other location - About 2 hrs to fix
                      packages/decoder/lib/index.ts on lines 335..343

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

                      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

                      export async function forContractAt(
                        contract: ContractConstructorObject,
                        address: string,
                        settings: DecoderSettings = {}
                      ): Promise<ContractInstanceDecoder> {
                      Severity: Major
                      Found in packages/decoder/lib/index.ts and 1 other location - About 2 hrs to fix
                      packages/encoder/lib/index.ts on lines 333..341

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

                      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