trufflesuite/truffle

View on GitHub

Showing 1,401 of 1,401 total issues

File run.ts has 421 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { zeroLinkReferences, formatLinkReferences } from "./shims";
import debugModule from "debug";
const debug = debugModule("compile:run");
import OS = require("os");
import semver from "semver";
Severity: Minor
Found in packages/compile-solidity/src/run.ts - About 6 hrs to fix

    Function formatStacktrace has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

      formatStacktrace: function (stacktrace, indent = 2) {
        //get message or panic code from stacktrace
        const { message, panic, custom } = stacktrace[0];
        //we want to print inner to outer, so first, let's
        //reverse
    Severity: Minor
    Found in packages/debug-utils/index.js - About 6 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

    export const { FunctionExternalValueInfoInvalid } = createCodecComponent(
      "FunctionExternalValueInfoInvalid",
      ({ contract, selector }: Format.Values.FunctionExternalValueInfoInvalid) => {
        const { prefix, content } = useInjectedNode();
        return (
    packages/codec-components/src/react/components/codec/format.values.function-external-value-info-unknown.tsx on lines 8..22

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

    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 const { FunctionExternalValueInfoUnknown } = createCodecComponent(
      "FunctionExternalValueInfoUnknown",
      ({ contract, selector }: Format.Values.FunctionExternalValueInfoUnknown) => {
        const { prefix, content } = useInjectedNode();
        return (
    packages/codec-components/src/react/components/codec/format.values.function-external-value-info-invalid.tsx on lines 8..22

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

    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

      {
        type: "codec-interface",
        name: "EventDecoding",
        content: (
          <>
    Severity: Major
    Found in packages/codec-components/src/docs/content.tsx and 1 other location - About 6 hrs to fix
    packages/codec-components/src/docs/content.tsx on lines 102..116

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

    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

      {
        type: "codec-interface",
        name: "MessageDecoding",
        content: (
          <>
    Severity: Major
    Found in packages/codec-components/src/docs/content.tsx and 1 other location - About 6 hrs to fix
    packages/codec-components/src/docs/content.tsx on lines 71..85

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

    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

      getTransaction: (web3: Web3Shim) => {
        const _oldTransactionFormatter =
          // @ts-ignore
          web3.eth.getTransaction.method.outputFormatter;
    
    
    Severity: Major
    Found in packages/interface-adapter/lib/shim/overloads/ethereum.ts and 1 other location - About 5 hrs to fix
    packages/interface-adapter/lib/shim/overloads/ethereum.ts on lines 62..83

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

    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

      getTransactionReceipt: (web3: Web3Shim) => {
        const _oldTransactionReceiptFormatter =
          // @ts-ignore
          web3.eth.getTransactionReceipt.method.outputFormatter;
    
    
    Severity: Major
    Found in packages/interface-adapter/lib/shim/overloads/ethereum.ts and 1 other location - About 5 hrs to fix
    packages/interface-adapter/lib/shim/overloads/ethereum.ts on lines 41..60

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

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

    export const resourceProcessorsForDefinitions = <C extends Collections>(
      definitions: Definitions<C>
    ): ResourceProcessors<C> => {
      const names = <N extends CollectionName<C>>(collectionName: N) => {
        const { mutable } = definitions[collectionName];
    Severity: Major
    Found in packages/db/src/meta/process/resources.ts - About 5 hrs to fix

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

      const debug = require("debug")("source-map-utils");
      const CodeUtils = require("@truffle/code-utils");
      const Codec = require("@truffle/codec");
      const Web3Utils = require("web3-utils");
      const jsonpointer = require("json-pointer");
      Severity: Minor
      Found in packages/source-map-utils/index.js - About 5 hrs to fix

        File reducers.js has 401 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import debugModule from "debug";
        const debug = debugModule("debugger:txlog:reducers");
        
        import { combineReducers } from "redux";
        
        
        Severity: Minor
        Found in packages/debugger/lib/txlog/reducers.js - About 5 hrs to fix

          File configDefaults.ts has 400 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import * as path from "path";
          import Provider from "@truffle/provider";
          import TruffleConfig from "./";
          
          export const getInitialConfig = ({
          Severity: Minor
          Found in packages/config/src/configDefaults.ts - About 5 hrs to fix

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

              @validStates([State.Active])
              async *declare({ identifier, message }: Options.Declare) {
                const parent = this;
            
                const child = new ValueResolutionController({
            Severity: Major
            Found in packages/preserve/lib/control/controllers/StepsController.ts and 1 other location - About 5 hrs to fix
            packages/preserve/lib/control/controllers/ValueResolutionController.ts on lines 63..81

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

            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

              "ask": (enable, disable) => ({
                ...baseNotification,
                title: "Help improve Truffle",
                message: (
                  <Stack>
            Severity: Major
            Found in packages/dashboard/src/utils/notifications/analytics.tsx and 1 other location - About 5 hrs to fix
            packages/dashboard/src/utils/notifications/analytics.tsx on lines 44..68

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

            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

              @validStates([State.Active])
              async *extend({ identifier, message }: Options.Extend) {
                const parent = this;
            
                const child = new ValueResolutionController({
            packages/preserve/lib/control/controllers/StepsController.ts on lines 92..110

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

            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

              "ask-again": (enable, disable) => ({
                ...baseNotification,
                title: "Telemetry is currently disabled",
                message: (
                  <Stack>
            Severity: Major
            Found in packages/dashboard/src/utils/notifications/analytics.tsx and 1 other location - About 5 hrs to fix
            packages/dashboard/src/utils/notifications/analytics.tsx on lines 18..43

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

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

            module.exports = async function (options) {
              const debug = require("debug")("core:commands:call");
              const fs = require("fs");
              const util = require("util");
              const { Environment } = require("@truffle/environment");
            Severity: Minor
            Found in packages/core/lib/commands/call/run.js - About 5 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 typeStringWithoutLocation has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
            Open

            export function typeStringWithoutLocation(dataType: Format.Types.Type): string {
              switch (dataType.typeClass) {
                case "uint":
                  return dataType.typeHint || `uint${dataType.bits}`;
                case "int":
            Severity: Minor
            Found in packages/codec-components/src/utils/codec.ts - About 5 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

            File arbitrary.ts has 394 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import * as fc from "fast-check";
            import { camelCase, pascalCase } from "change-case";
            import wordLists from "./wordLists";
            import type * as Types from "./types";
            
            
            Severity: Minor
            Found in packages/abi-utils/lib/arbitrary.ts - About 5 hrs to fix

              File errors.ts has 394 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /**
               * Contains the types for error and `ErrorResult` objects.
               * @category Main Format
               *
               * @packageDocumentation
              Severity: Minor
              Found in packages/codec/lib/format/errors.ts - About 5 hrs to fix
                Severity
                Category
                Status
                Source
                Language