trufflesuite/truffle

View on GitHub

Showing 685 of 1,401 total issues

Function exports has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = Contract => ({
  configureNetwork({ networkType, provider } = {}) {
    // otherwise use existing value as default (at most one of these)
    networkType = networkType || this.networkType;
    provider = provider || this.currentProvider;
Severity: Minor
Found in packages/contract/lib/contract/constructorMethods.js - About 1 day 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 updateTransactionLogSaga has 203 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function* updateTransactionLogSaga() {
  const pointer = yield select(txlog.current.pointer); //log pointer, not AST pointer
  const step = yield select(txlog.current.step);
  if (yield select(txlog.current.isHalting)) {
    //note that we process this case first so that it overrides the others!
Severity: Major
Found in packages/debugger/lib/txlog/sagas/index.js - About 1 day to fix

    Function normalize has 201 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static normalize(compilations) {
        let contexts = [];
        let sources = {
          user: {}, //by compilation
          internal: {} //by context
    Severity: Major
    Found in packages/debugger/lib/session/index.js - About 1 day to fix

      Function Debugger has 196 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function Debugger(): JSX.Element {
        const { classes } = useStyles();
        const [inputValue, setInputValue] = useInputState("");
        const [sessionUpdated, { increment: sessionTick }] = useCounter();
        const {
      Severity: Major
      Found in packages/dashboard/src/components/composed/Debugger/index.tsx - About 7 hrs to fix

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

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

          Function createStepSelectors has 187 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function createStepSelectors(step, state = null) {
            let base = {
              /**
               * .trace
               *
          Severity: Major
          Found in packages/debugger/lib/evm/selectors/index.js - About 7 hrs to fix

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

            import debugModule from "debug";
            const debug = debugModule("debugger:session");
            
            import * as Abi from "@truffle/abi-utils";
            import * as Codec from "@truffle/codec";
            Severity: Minor
            Found in packages/debugger/lib/session/index.js - About 7 hrs to fix

              Function isDesignatedInvalid has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
              Open

                isDesignatedInvalid: function (
                  instructions,
                  index,
                  overlapFunctions,
                  node = undefined
              Severity: Minor
              Found in packages/source-map-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

              Function printReturnValue has 154 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async printReturnValue() {
                  //note: when printing revert messages, this will do so in a somewhat
                  //different way than printRevertMessage does
                  const inspectOptions = {
                    colors: true,
              Severity: Major
              Found in packages/core/lib/debug/printer.js - About 6 hrs to fix

                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

                  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

                          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

                              Function steps has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                              Open

                                steps(kind, data) {
                                  const self = this;
                                  const reporter = self.reporter;
                                  const valueUnit = data.valueUnit || "ETH";
                              
                              
                              Severity: Minor
                              Found in packages/events/defaultSubscribers/migrate/Messages.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

                              Severity
                              Category
                              Status
                              Source
                              Language