trufflesuite/truffle

View on GitHub

Showing 685 of 1,401 total issues

Function configureManagedGanache has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function configureManagedGanache(config, networkConfig, mnemonic) {
  const host = getFirstDefinedValue(
    networkConfig.host,
    "127.0.0.1" // Use as default host
  );
Severity: Major
Found in packages/core/lib/configAdapter.js - About 2 hrs to fix

    Function link has a Cognitive Complexity of 18 (exceeds 5 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: Minor
    Found in packages/deployer/src/linker.js - 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 exports has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = async function (options) {
      const Config = require("@truffle/config");
      const OS = require("os");
    
      const log = options.logger
    Severity: Minor
    Found in packages/core/lib/commands/config/run.js - 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 parse has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    const parse = function (args) {
      if (args.length === 0) {
        return null;
      }
    
    
    Severity: Minor
    Found in packages/core/lib/commands/config/run.js - 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 resolve has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

      async resolve(importPath: string) {
        if (importPath === `truffle${path.sep}DeployedAddresses.sol`) {
          const sourceFiles = await findContracts(this.options.contracts_directory);
    
          const buildDirFiles: string[] = fse.existsSync(
    Severity: Minor
    Found in packages/resolver/lib/sources/truffle/index.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 file has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    export function file(options: RequireOptions) {
      const sourceFilePath = path.resolve(options.file);
    
      expectOptions(options, ["file"]);
    
    
    Severity: Minor
    Found in packages/require/lib/index.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 deploy has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      deploy: function (constructorABI) {
        const constructor = this;
        const web3 = constructor.web3;
    
        return function () {
    Severity: Major
    Found in packages/contract/lib/execute.js - About 2 hrs to fix

      Consider simplifying this complex logical expression.
      Open

              if (start !== undefined && length !== undefined) {
                //node-based (well, source-range-based) breakpoint
                return (
                  sourceId === currentSourceId &&
                  start === currentStart &&
      Severity: Critical
      Found in packages/debugger/lib/controller/sagas/index.js - About 2 hrs to fix

        Consider simplifying this complex logical expression.
        Open

            if (
              decoding.kind === "function" &&
              (decoding.abi.name === "tryAggregate" ||
                decoding.abi.name === "tryBlockAndAggregate") &&
              decoding.abi.inputs.length === 2 &&
        Severity: Critical
        Found in packages/decoder/lib/decoders.ts - About 2 hrs to fix

          ProjectEncoder has 22 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export class ProjectEncoder {
            private provider: Provider | null;
            private ens: any | null; //any should be ENS, sorry >_>
            private registryAddress: string | undefined = undefined;
            private ensCache: ENSCache = {};
          Severity: Minor
          Found in packages/encoder/lib/encoders.ts - About 2 hrs to fix

            Function MenuButton has 58 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function MenuButton(): JSX.Element {
              const { connect } = useConnect({ connector: new InjectedConnector() });
              const { disconnect } = useDisconnect();
              const { isConnected } = useAccount();
              const {

              File vyper-json.js has 262 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              const debug = require("debug")("compile-vyper:vyper-json");
              const execSync = require("child_process").execSync;
              const path = require("path");
              const semver = require("semver");
              const Common = require("@truffle/compile-common");
              Severity: Minor
              Found in packages/compile-vyper/vyper-json.js - About 2 hrs to fix

                Function PromiEvent has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function PromiEvent(justPromise, bugger = undefined, isDeploy = false) {
                  const { resolve, reject, eventEmitter } = new Web3PromiEvent(justPromise);
                
                  const originalStackTrace = new Error().stack;
                
                
                Severity: Major
                Found in packages/contract/lib/promievent.js - About 2 hrs to fix

                  Function Menu has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const Menu = (props: Props) => {
                    const { config, db, project, onDone } = props;
                    const [mode, setMode] = useState<"wait" | ModeName<MenuModes>>("wait");
                  
                    const handleSelect = ({ value }) => {
                  Severity: Major
                  Found in packages/db-kit/src/cli/menu/Menu.tsx - About 2 hrs to fix

                    Function EtherScanApiKeyPrompt has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function EtherScanApiKeyPrompt() {
                      const { classes } = useStyles();
                    
                      const [etherscanApiKey, setEtherscanApiKey, removeEtherscanApiKey] =
                        useLocalStorage({

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

                              (scopes, scope, pointer, sourceId, language) => {
                                let variables = {};
                                if (scope !== undefined) {
                                  let cur =
                                    scope.id !== undefined ? scope.id : makePath(sourceId, pointer);
                      Severity: Minor
                      Found in packages/debugger/lib/data/selectors/index.js - 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 getUserDefinedGlobals has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                        getUserDefinedGlobals({ accounts, interfaceAdapter, web3 }) {
                          // exit if feature should be disabled
                          if (this.options["require-none"]) return;
                      
                          // exit if no hydrate options are set
                      Severity: Minor
                      Found in packages/core/lib/console.js - 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 normalizeSourcePath has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export const normalizeSourcePath = (url = defaultPath) => {
                        // Process filepath resolution
                        //
                        if (url.startsWith(".") || url.startsWith("/") || url.startsWith("~")) {
                          debug({ in: url, out: path.normalize(url) });
                      Severity: Minor
                      Found in packages/box/box.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 constructSlot has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                        private async constructSlot(
                          variable: number | string,
                          ...indices: unknown[]
                        ): Promise<{ slot?: Storage.Slot; type?: Format.Types.Type }> {
                          //base case: we need to locate the variable and its definition
                      Severity: Minor
                      Found in packages/decoder/lib/decoders.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 init has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                        public async init(): Promise<void> {
                          this.contractCode = Conversion.toHexString(
                            await this.getCode(
                              this.contractAddress,
                              await this.providerAdapter.getBlockNumber() //not "latest" because regularized
                      Severity: Minor
                      Found in packages/decoder/lib/decoders.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

                      Severity
                      Category
                      Status
                      Source
                      Language