trufflesuite/truffle

View on GitHub

Showing 685 of 1,401 total issues

Function iterate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  *iterate({ inputs }) {
    for (const [compilationIndex, { sources, contracts }] of inputs.entries()) {
      for (const [sourceIndex, source] of sources.entries()) {
        yield {
          input: source,
Severity: Minor
Found in packages/db/src/project/loadCompile/sources.ts - 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 interpretCallInAggregate has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  private async interpretCallInAggregate(
    callResult: Format.Values.StructResult | Format.Values.TupleResult,
    transaction: DecoderTypes.Transaction,
    additionalContexts: Contexts.Contexts = {},
    additionalAllocations?: {
Severity: Major
Found in packages/decoder/lib/decoders.ts - About 2 hrs to fix

    Function isUsableCompilation has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      isUsableCompilation: function (compilation) {
        //check #1: is the source order reliable?
        if (compilation.unreliableSourceOrder) {
          debug("unreliable source order");
          return false;
    Severity: Major
    Found in packages/debug-utils/index.js - About 2 hrs to fix

      Function parseParameterListWithRemainder has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function parseParameterListWithRemainder(parameterList: string): {
        parameters: Parameter[];
        remaining: string;
      } {
        if (parameterList === "") {
      Severity: Major
      Found in packages/abi-utils/lib/parse.ts - About 2 hrs to fix

        Function save has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public async save<N extends CollectionName<C>, T>(
            collectionName: N,
            records: (Record<T> | undefined)[],
            options: { overwrite?: boolean } = {}
          ): Promise<(SavedRecord<T> | undefined)[]> {
        Severity: Major
        Found in packages/db/src/meta/pouch/adapters/base.ts - About 2 hrs to fix

          File index.tsx has 260 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { useState, useEffect } from "react";
          import { Input, Button, Header, Grid, createStyles } from "@mantine/core";
          import { useInputState, useCounter, useLocalStorage } from "@mantine/hooks";
          import Controls from "src/components/composed/Debugger/Controls";
          import Sources from "src/components/composed/Debugger/Sources";
          Severity: Minor
          Found in packages/dashboard/src/components/composed/Debugger/index.tsx - About 2 hrs to fix

            File run.js has 259 lines of code (exceeds 250 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 2 hrs to fix

              Function decodeCall has 55 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function* decodeCall(decodeCurrent = false) {
                const isCall = yield select(data.current.isCall);
                const isCreate = yield select(data.current.isCreate);
                if (!isCall && !isCreate && !decodeCurrent) {
                  return null;
              Severity: Major
              Found in packages/debugger/lib/data/sagas/index.js - About 2 hrs to fix

                Function decode has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function* decode(definition, ref, compilationId) {
                  const userDefinedTypes = yield select(data.views.userDefinedTypes);
                  const state = yield select(data.current.state);
                  const mappingKeys = yield select(data.views.mappingKeys);
                  const allocations = yield select(data.info.allocations);
                Severity: Major
                Found in packages/debugger/lib/data/sagas/index.js - About 2 hrs to fix

                  Function parseQuotesAndEscapes has 55 lines of code (exceeds 25 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: Major
                  Found in packages/core/lib/command-utils.js - About 2 hrs to fix

                    Function sourcesWithDependencies has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      async sourcesWithDependencies({
                        paths,
                        options
                      }: SourcesWithDependenciesArgs) {
                        if (options.compilers.solc.version === "pragma") {
                    Severity: Major
                    Found in packages/compile-solidity/src/index.ts - About 2 hrs to fix

                      File adapter.ts has 258 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import debugModule from "debug";
                      const debug = debugModule("decoder:adapter");
                      import type { BlockSpecifier } from "@truffle/codec";
                      import type BN from "bn.js";
                      import type {
                      Severity: Minor
                      Found in packages/encoder/lib/adapter.ts - About 2 hrs to fix

                        File VersionRange.ts has 257 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import debugModule from "debug";
                        const debug = debugModule("compile:compilerSupplier");
                        
                        import requireFromString from "require-from-string";
                        
                        

                          Function _ has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                        ...Object.entries(scopes).map(([id, scope]) => {
                                          let definition = inlined[id].definition;
                                          if (definition.nodeType === "ContractDefinition") {
                                            //contract definition case: process inheritance
                                            debug("contract id %d", id);
                          Severity: Major
                          Found in packages/debugger/lib/data/selectors/index.js - About 2 hrs to fix

                            Function start has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              start: async function (context, web3Error) {
                                const constructor = this;
                                let currentBlock = override.defaultMaxBlocks;
                            
                                // Reject after attempting to get reason string if we shouldn't be waiting.
                            Severity: Major
                            Found in packages/contract/lib/override.js - About 2 hrs to fix

                              Function link has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                link: async function (library, destinations, deployer) {
                                  let eventArgs;
                                  let libraryName = library.contractName;
                                  if (libraryName == null && library.constructor) {
                                    //allow for the possibility that library is an instance rather
                              Severity: Major
                              Found in packages/deployer/src/linker.js - About 2 hrs to fix

                                Function exports has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                module.exports = async options => {
                                  const { Develop } = require("@truffle/environment");
                                  const Config = require("@truffle/config");
                                
                                  const config = Config.detect(options);
                                Severity: Major
                                Found in packages/core/lib/commands/develop/run.js - About 2 hrs to fix

                                  Function decodeVariable has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    private async decodeVariable(
                                      variable: Storage.Allocate.StateVariableAllocation,
                                      block: RegularizedBlockSpecifier
                                    ): Promise<DecoderTypes.StateVariable> {
                                      const info: Codec.Evm.EvmInfo = {
                                  Severity: Major
                                  Found in packages/decoder/lib/decoders.ts - About 2 hrs to fix

                                    Function process has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    export function* process(options: {
                                      networks: (Pick<Resource<"networks">, "id" | "historicBlock"> | undefined)[];
                                      settings?: {
                                        disableIndex?: boolean;
                                      };
                                    Severity: Major
                                    Found in packages/db/src/network/load/networkGenealogies.ts - About 2 hrs to fix

                                      File webpack.config.js has 254 lines of code (exceeds 250 allowed). Consider refactoring.
                                      Open

                                      const path = require("path");
                                      const CopyWebpackPlugin = require("copy-webpack-plugin");
                                      const { CleanWebpackPlugin } = require("clean-webpack-plugin");
                                      const webpack = require("webpack");
                                      const pkg = require("./package.json");
                                      Severity: Minor
                                      Found in packages/truffle/webpack.config.js - About 2 hrs to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language