trufflesuite/truffle

View on GitHub
packages/debugger/lib/txlog/sagas/index.js

Summary

Maintainability
F
3 days
Test Coverage

Function updateTransactionLogSaga has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

function* updateTransactionLogSaga() {
  const pointer = yield select(txlog.current.pointer); //log pointer, not AST pointer
  const step = yield select(txlog.current.step);
  if (yield select(txlog.current.isHalting)) {
    //note that we process this case first so that it overrides the others!
Severity: Minor
Found in packages/debugger/lib/txlog/sagas/index.js - About 1 day 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 updateTransactionLogSaga has 203 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function* updateTransactionLogSaga() {
  const pointer = yield select(txlog.current.pointer); //log pointer, not AST pointer
  const step = yield select(txlog.current.step);
  if (yield select(txlog.current.isHalting)) {
    //note that we process this case first so that it overrides the others!
Severity: Major
Found in packages/debugger/lib/txlog/sagas/index.js - About 1 day to fix

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

    import debugModule from "debug";
    const debug = debugModule("debugger:txlog:sagas");
    
    import { put, takeEvery, select } from "redux-saga/effects";
    import { prefixName } from "lib/helpers";
    Severity: Minor
    Found in packages/debugger/lib/txlog/sagas/index.js - About 3 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 callKind has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        function callKind(context, calldata, instant) {
          if (context) {
            if (context.contractKind === "library") {
              return instant ? "message" : "library";
              //for an instant return, just get it out of the way and set it to
        Severity: Minor
        Found in packages/debugger/lib/txlog/sagas/index.js - About 1 hr 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 deeply nested control flow statements.
        Open

              if (!internal && astMatchesTxLog) {
                //in this case, we have to do decoding & fn identification
                const newPointer = yield select(txlog.current.internalReturnPointer);
                const outputAllocations = yield select(
                  txlog.current.outputParameterAllocations
        Severity: Major
        Found in packages/debugger/lib/txlog/sagas/index.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                  if (!(yield select(txlog.current.waitingForInternalCallToAbsorb))) {
                    const newPointer = yield select(txlog.current.nextActionPointer);
                    debug("internal call: %o %o", pointer, newPointer);
                    yield put(actions.internalCall(pointer, newPointer, step));
                  } else {
          Severity: Major
          Found in packages/debugger/lib/txlog/sagas/index.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

              } else if (yield select(txlog.current.isLog)) {
                const decoding = (yield* data.decodeLog())[0]; //just assume first decoding is correct
                //(note: because we know the event ID, there should typically only be one decoding)
                const rawInfo = yield select(txlog.current.rawEventInfo);
                const newPointer = yield select(txlog.current.nextActionPointer);
            Severity: Major
            Found in packages/debugger/lib/txlog/sagas/index.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                  if (instant) {
                    const status = yield select(txlog.current.returnStatus);
                    debug("instacreate: %o %o", pointer, newPointer);
                    yield put(
                      actions.instantCreate(
              Severity: Major
              Found in packages/debugger/lib/txlog/sagas/index.js - About 45 mins to fix

                There are no issues that match your filters.

                Category
                Status