trufflesuite/truffle

View on GitHub

Showing 1,401 of 1,401 total issues

Avoid deeply nested control flow statements.
Open

          if (!(name in fn)) {
            //don't overwrite anything!
            fn[name] = enumeration;
          }
Severity: Major
Found in packages/contract/lib/contract/bootstrap.js - About 45 mins to fix

    Function display has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      display: async function(config) {
        const networks = await this.deployed(config);
        const { networkNames, starNetworks } = Object.keys(networks)
          .sort()
          .reduce(
    Severity: Minor
    Found in packages/core/lib/networks.js - About 45 mins 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 parseKnownNetworks has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      async parseKnownNetworks(
        { networks, currentProvider, setNetwork, network_id },
        gasLimit
      ) {
        if (!networks && Object.keys(networks).length === 0) {
    Severity: Minor
    Found in packages/contract/lib/utils/index.js - About 45 mins 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

    Avoid deeply nested control flow statements.
    Open

            for (let index = 0; index < values.length; index++) {
              const { value } = values[index];
              const prefix = paddedPrefixes[index];
              const formatted = DebugUtils.formatValue(value, maxLength);
              this.config.logger.log(prefix + formatted);
    Severity: Major
    Found in packages/core/lib/debug/printer.js - About 45 mins to fix

      Function parsePrintoutLines has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        parsePrintoutLines(userArgs, currentLines) {
          let { beforeLines, afterLines } = currentLines;
          for (const argument of userArgs) {
            // ignore an option with length less than 2,such as a bare + or -
            if (argument.length < 2) continue;
      Severity: Minor
      Found in packages/core/lib/debug/interpreter.js - About 45 mins 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 constructor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        constructor(
          projectEncoder: ProjectEncoder,
          compilation: Codec.Compilations.Compilation,
          contract: Codec.Compilations.Contract,
          artifact?: Artifact
      Severity: Minor
      Found in packages/encoder/lib/encoders.ts - About 45 mins 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

      Avoid deeply nested control flow statements.
      Open

            if (name) {
              //case 12a: it has a name
              this.config.logger.log("Returned values:");
              this.config.logger.log(`${name}: ${prettyData}`);
            } else {
      Severity: Major
      Found in packages/core/lib/debug/printer.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    if (errorIndex !== null) {
                      const stepSpinner = new Spinner(
                        "core:debug:interpreter:step",
                        "Stepping..."
                      );
        Severity: Major
        Found in packages/core/lib/debug/interpreter.js - About 45 mins to fix

          Function setUpConfig has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            setUpConfig: config => {
              if (!config.resolver) {
                config.resolver = new Resolver(config);
              }
          
          
          Severity: Minor
          Found in packages/environment/environment.js - About 45 mins 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 connect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            connect: function ({ ipcOptions, solidityLogDisplayPrefix }) {
              const debugServer = debug("develop:ipc:server");
              const debugClient = debug("develop:ipc:client");
              const debugRPC = debug("develop:ganache");
              const ganacheColor = {
          Severity: Minor
          Found in packages/environment/develop.js - About 45 mins 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

          Avoid deeply nested control flow statements.
          Open

                  if (
                    matchingSources.some(shortSource =>
                      matchingSources.every(
                        source =>
                          typeof source.sourcePath !== "string" || //just ignore these I guess?
          Severity: Major
          Found in packages/core/lib/debug/interpreter.js - About 45 mins to fix

            Function getSolcFromCacheOrUrl has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              async getSolcFromCacheOrUrl(versionConstraint: string, index: number = 0) {
                // go through all sources (compilerRoots) trying to locate a
                // suitable version of the Solidity compiler
                const { compilerRoots, events } = this.config;
                if (!compilerRoots || compilerRoots.length === 0) {

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

              async compile(options) {
                const config = prepareConfig(options);
            
                if (config.events) config.events.emit("compile:start");
            
            
            Severity: Minor
            Found in packages/workflow-compile/src/index.ts - About 45 mins 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 getSortedFetcherConstructors has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            export function getSortedFetcherConstructors(
              userFetcherNames?: string[]
            ): FetcherConstructor[] {
              let sortedFetchers: FetcherConstructor[] = [];
              if (userFetcherNames) {
            Severity: Minor
            Found in packages/fetch-and-compile/lib/fetch.ts - About 45 mins 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 getSolcVersionFileName has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              getSolcVersionFileName(
                version: string,
                allVersions: SolidityCompilersList
              ): string | null {
                if (allVersions.releases[version]) return allVersions.releases[version];

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

              require(importPath: string, searchPath: string) {
                if (importPath.indexOf(".") === 0 || importPath.indexOf("/") === 0) {
                  return null;
                }
                const contractName = path.basename(importPath, ".sol");
            Severity: Minor
            Found in packages/resolver/lib/sources/npm.ts - About 45 mins 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 find has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              public async find<N extends CollectionName<C>>(
                collectionName: N,
                options: (Id.IdObject<C, N> | undefined)[] | PouchDB.Find.FindRequest<{}>
              ): Promise<(SavedInput<C, N> | undefined)[]> {
                const log = debug.extend(`${collectionName}:find`);
            Severity: Minor
            Found in packages/db/src/meta/pouch/workspace.ts - About 45 mins 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

            Avoid deeply nested control flow statements.
            Open

                        for (const [
                          generatedSourceIndex,
                          source
                        ] of generatedSources.entries()) {
                          yield {
            Severity: Major
            Found in packages/db/src/project/loadCompile/sources.ts - About 45 mins to fix

              Function resolve has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                      async resolve(
                        { id, resource, previous },
                        { limit, includeSelf = false },
                        { workspace }
                      ) {
              Severity: Minor
              Found in packages/db/src/resources/nameRecords.ts - About 45 mins 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 list has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                async list() {
                  const userSpecification = this.version;
              
                  let strategy: Docker | Native | Local | VersionRange | undefined;
                  const useDocker = this.docker;
              Severity: Minor
              Found in packages/compile-solidity/src/compilerSupplier/index.ts - About 45 mins 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