trufflesuite/truffle

View on GitHub
packages/compile-solidity/src/run.ts

Summary

Maintainability
D
1 day
Test Coverage

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

    export async function run(
      rawSources: { [name: string]: string },
      options: Config,
      internalOptions: InternalOptions = {}
    ): Promise<Compilation | null> {
    Severity: Major
    Found in packages/compile-solidity/src/run.ts - About 2 hrs to fix

      Function repairOldContracts has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      function repairOldContracts(contracts: Contracts): Contracts {
        const contractNames = Object.values(contracts)
          .map(source => Object.keys(source))
          .flat();
        if (contractNames.some(name => name.includes(":"))) {
      Severity: Minor
      Found in packages/compile-solidity/src/run.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 repairOldContracts has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function repairOldContracts(contracts: Contracts): Contracts {
        const contractNames = Object.values(contracts)
          .map(source => Object.keys(source))
          .flat();
        if (contractNames.some(name => name.includes(":"))) {
      Severity: Minor
      Found in packages/compile-solidity/src/run.ts - About 1 hr to fix

        Function run has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        export async function run(
          rawSources: { [name: string]: string },
          options: Config,
          internalOptions: InternalOptions = {}
        ): Promise<Compilation | null> {
        Severity: Minor
        Found in packages/compile-solidity/src/run.ts - About 55 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 processAllSources has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        function processAllSources({
          sources,
          compilerOutput,
          originalSourcePaths,
          language
        Severity: Minor
        Found in packages/compile-solidity/src/run.ts - About 35 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 detectErrors has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function detectErrors({
          compilerOutput,
          options,
          solcVersion
        }: {
        Severity: Minor
        Found in packages/compile-solidity/src/run.ts - About 25 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 orderABI has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function orderABI({ abi, contractName, ast }) {
          if (!abi) {
            return []; //Yul doesn't return ABIs, but we require something
          }
        
        
        Severity: Minor
        Found in packages/compile-solidity/src/run.ts - About 25 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

        There are no issues that match your filters.

        Category
        Status