kleros/kleros-v2

View on GitHub
subgraph/core/src/datapoint.ts

Summary

Maintainability
A
25 mins
Test Coverage

Function getNewValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function getNewValue(currentVar: string, targetVar: string, delta: BigInt, counter: Entity | null): Value {
  if (currentVar === targetVar) {
    return !counter ? Value.fromBigInt(delta) : Value.fromBigInt(counter.get(currentVar)!.toBigInt().plus(delta));
  } else {
    return !counter ? Value.fromBigInt(ZERO) : counter.get(currentVar)!;
Severity: Minor
Found in subgraph/core/src/datapoint.ts - About 25 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

Expected a 'for-of' loop instead of a 'for' loop with this simple iteration
Open

  for (let i = 0; i < VARIABLES.length; i++) {
Severity: Minor
Found in subgraph/core/src/datapoint.ts by tslint

Rule: prefer-for-of

Recommends a 'for-of' loop over a standard 'for' loop if the index is only used to access the array being iterated.

Rationale

A for(... of ...) loop is easier to implement and read when the index is not needed.

Config

Not configurable.

Examples
"prefer-for-of": true

For more information see this page.

There are no issues that match your filters.

Category
Status