packages/debugger/lib/txlog/sagas/index.js
Function updateTransactionLogSaga
has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring. Open
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!
- Read upRead up
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
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!
File index.js
has 301 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import debugModule from "debug";
const debug = debugModule("debugger:txlog:sagas");
import { put, takeEvery, select } from "redux-saga/effects";
import { prefixName } from "lib/helpers";
Function begin
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
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);
Function callKind
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
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
- Read upRead up
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
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
Avoid deeply nested control flow statements. Open
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 {
Avoid deeply nested control flow statements. Open
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);
Avoid deeply nested control flow statements. Open
Open
if (instant) {
const status = yield select(txlog.current.returnStatus);
debug("instacreate: %o %o", pointer, newPointer);
yield put(
actions.instantCreate(