AugurProject/augur-core

View on GitHub
source/libraries/ContractInterfacesGenerator.ts

Summary

Maintainability
B
6 hrs
Test Coverage

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

    private contractInterfacesTemplate(contracts: CompilerOutputContracts) {
        const contractInterfaces: Array<string> = [];

        // We add Controlled first to let other contracts inherit from it
        contractInterfaces.push(this.contractInterfaceTemplate("Controlled", contracts["Controlled.sol"]["Controlled"].abi));
Severity: Major
Found in source/libraries/ContractInterfacesGenerator.ts - About 2 hrs to fix

    Function getTsTypeFromPrimitive has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private getTsTypeFromPrimitive(abiType: Primitive) {
            switch(abiType) {
                case 'uint8':
                case 'uint64':
                case 'uint256':
    Severity: Minor
    Found in source/libraries/ContractInterfacesGenerator.ts - About 1 hr to fix

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

          private contractInterfacesTemplate(contracts: CompilerOutputContracts) {
              const contractInterfaces: Array<string> = [];
      
              // We add Controlled first to let other contracts inherit from it
              contractInterfaces.push(this.contractInterfaceTemplate("Controlled", contracts["Controlled.sol"]["Controlled"].abi));
      Severity: Minor
      Found in source/libraries/ContractInterfacesGenerator.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 localMethodTemplate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          private localMethodTemplate(abiFunction: AbiFunction) {
              const argNames: String = this.getArgNamesString(abiFunction);
              const params: String = this.getParamsString(abiFunction);
              const options: String = `{ sender?: string${abiFunction.payable ? ", attachedEth?: BN" : ""} }`;
              const returnType: String = (abiFunction.outputs[0] !== undefined) ? this.getTsTypeFromPrimitive(abiFunction.outputs[0].type) : "void";
      Severity: Minor
      Found in source/libraries/ContractInterfacesGenerator.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 contractInterfaceTemplate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          private contractInterfaceTemplate(contractName: String, contractAbi: Abi) {
              const contractMethods: Array<String> = [];
      
              // Typescript doesn't allow the same name for a function. We only have one existing case for function overloading in a class and it has the same signature, so this is ok at the moment.
              const seen: Set<string> = new Set();
      Severity: Minor
      Found in source/libraries/ContractInterfacesGenerator.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

      Avoid too many return statements within this function.
      Open

                      return 'Array<string>';
      Severity: Major
      Found in source/libraries/ContractInterfacesGenerator.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                        return 'Array<BN>';
        Severity: Major
        Found in source/libraries/ContractInterfacesGenerator.ts - About 30 mins to fix

          There are no issues that match your filters.

          Category
          Status