trufflesuite/truffle

View on GitHub

Showing 685 of 1,401 total issues

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

export function* callstackAndCodexSaga() {
  if (yield select(evm.current.step.isExceptionalHalting)) {
    //let's handle this case first so we can be sure everything else is *not*
    //an exceptional halt
    debug("exceptional halt!");
Severity: Minor
Found in packages/debugger/lib/evm/sagas/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 exports has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = async function (options) {
  const OS = require("os");
  const { promisify } = require("util");
  const loadConfig = require("../../loadConfig");
  const { Environment } = require("@truffle/environment");
Severity: Minor
Found in packages/core/lib/commands/debug/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 exports has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = async function (config) {
  const debugLog = debug.extend("guard");
  // only check if deploying on MAINNET
  // NOTE: this includes Ethereum Classic as well as Ethereum as they're only
  // distinguishable by checking their chainIds, 2 and 1 respectively.
Severity: Minor
Found in packages/core/lib/commands/migrate/runMigrations.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 collectAllocationInfo has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

export function collectAllocationInfo(
  compilations: Compilations.Compilation[]
): ContextAndAllocationInfo {
  let contexts: Contexts.Contexts = {};
  let deployedContexts: Contexts.Contexts = {};
Severity: Minor
Found in packages/codec/lib/abi-data/allocate/utils.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 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 _deploy has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  async _deploy(
    options: Config,
    context: MigrationContext,
    deployer: DeployerInterface,
    resolver: ResolverIntercept,
Severity: Minor
Found in packages/migrate/src/Migration.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 Stack has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

function Stack(): JSX.Element | null {
  const { classes } = useStyles();
  const {
    state: {
      debugger: { session }
Severity: Minor
Found in packages/dashboard/src/components/composed/Debugger/Stack.tsx - 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 callstackAndCodexSaga has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function* callstackAndCodexSaga() {
  if (yield select(evm.current.step.isExceptionalHalting)) {
    //let's handle this case first so we can be sure everything else is *not*
    //an exceptional halt
    debug("exceptional halt!");
Severity: Major
Found in packages/debugger/lib/evm/sagas/index.js - About 2 hrs to fix

    Function testConnection has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      testConnection: function (options) {
        let networkCheckTimeout, networkType;
        const { networks, network } = options;
        if (networks && networks[network]) {
          networkCheckTimeout =
    Severity: Major
    Found in packages/provider/index.js - About 2 hrs to fix

      Function getUserDefinedGlobals has 52 lines of code (exceeds 25 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: Major
      Found in packages/core/lib/console.js - About 2 hrs to fix

        Function generateReport has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function generateReport(rawStack, location, status, message) {
          //step 1: process combined frames
          let callstack = [];
          //we're doing a C-style loop here!
          //because we want to skip some items <grin>
        Severity: Major
        Found in packages/debugger/lib/stacktrace/selectors/index.js - About 2 hrs to fix

          Function exports has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = async function (options) {
            const Config = require("@truffle/config");
            const TruffleError = require("@truffle/error");
            const WorkflowCompile = require("@truffle/workflow-compile").default;
            const CodeUtils = require("@truffle/code-utils");
          Severity: Major
          Found in packages/core/lib/commands/opcode/run.js - About 2 hrs to fix

            Function evalAndPrintExpression has 51 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async evalAndPrintExpression(raw, indent, suppress) {
                let variables = await this.session.variables({ indicateUnknown: true });
            
                //if we're just dealing with a single variable, handle that case
                //separately (so that we can do things in a better way for that
            Severity: Major
            Found in packages/core/lib/debug/printer.js - About 2 hrs to fix

              File index.js has 251 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import debugModule from "debug";
              const debug = debugModule("debugger:stacktrace:selectors");
              
              import { createSelectorTree, createLeaf } from "reselect-tree";
              
              
              Severity: Minor
              Found in packages/debugger/lib/stacktrace/selectors/index.js - About 2 hrs to fix

                Function decodeReturnValue has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function* decodeReturnValue() {
                  const userDefinedTypes = yield select(data.views.userDefinedTypes);
                  const state = yield select(data.next.state); //next state has the return data
                  const allocations = yield select(data.info.allocations);
                  const contexts = yield select(data.views.contexts);
                Severity: Minor
                Found in packages/debugger/lib/data/sagas/index.js - About 2 hrs to fix

                  Consider simplifying this complex logical expression.
                  Open

                      } else if (
                        decoding.kind === "function" &&
                        decoding.abi.name === "aggregate3Value" &&
                        decoding.abi.inputs.length === 1 &&
                        decoding.abi.inputs[0].type === "tuple[]" &&
                  Severity: Critical
                  Found in packages/decoder/lib/decoders.ts - About 2 hrs to fix

                    Function resolvers has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      get resolvers(): IResolvers<any, Context<C>> {
                        const log = debug.extend(`${this.resource}:resolvers`);
                        log("Generating...");
                    
                        // setup loggers for specific resolvers
                    Severity: Minor
                    Found in packages/db/src/meta/graph/schema.ts - About 2 hrs to fix

                      Function begin has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export function* begin() {
                        const pointer = yield select(txlog.current.pointer);
                        const newPointer = yield select(txlog.current.nextActionPointer);
                        const origin = yield select(txlog.transaction.origin);
                        debug("origin: %o", pointer);
                      Severity: Minor
                      Found in packages/debugger/lib/txlog/sagas/index.js - About 1 hr to fix

                        Function recordAllocations has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function* recordAllocations() {
                          const contracts = yield select(data.views.contractAllocationInfo);
                          const referenceDeclarations = yield select(data.views.referenceDeclarations);
                          const userDefinedTypesByCompilation = yield select(
                            data.views.userDefinedTypesByCompilation
                        Severity: Minor
                        Found in packages/debugger/lib/data/sagas/index.js - About 1 hr to fix

                          Function processDeploymentError has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            async processDeploymentError(data) {
                              const error = data.estimateError || data.error;
                          
                              data.reason = data.error ? data.error.reason : null;
                          
                          
                          Severity: Minor
                          Found in packages/events/defaultSubscribers/migrate/Reporter.js - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language