trufflesuite/truffle

View on GitHub
packages/compile-solidity/src/compilerSupplier/loadingStrategies/VersionRange.ts

Summary

Maintainability
C
7 hrs
Test Coverage

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 getSolcFromCacheOrUrl has 36 lines of code (exceeds 25 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) {

      Function list has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async list(index = 0) {
          if (index >= this.config.compilerRoots!.length) {
            throw new Error(
              `Failed to fetch the list of Solidity compilers from the following ` +
                `sources: ${this.config.compilerRoots}. Make sure you are connected ` +

        Function getAndCacheSolcByUrl has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async getAndCacheSolcByUrl(fileName: string, index: number) {
            const { events, compilerRoots } = this.config;
            const url = `${compilerRoots![index].replace(/\/+$/, "")}/${fileName}`;
            events.emit("downloadCompiler:start", {
              attemptNumber: index + 1

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

          There are no issues that match your filters.

          Category
          Status