kleros/kleros-v2

View on GitHub

feat(subgraph/web): time travel query refactor
#1939

kemuru wants to merge fix/time-travel-query-refactor into dev
Failed
14 issues to fix.

Showing 20 of 20 total issues

File KlerosCore.ts has 254 lines of code (exceeds 250 allowed). Consider refactoring.
New

import {
KlerosCore,
AppealDecision,
DisputeCreation,
DisputeKitCreated,
Severity: Minor
Found in subgraph/core/src/KlerosCore.ts - About 2 hrs to fix

Function updateCourtCumulativeMetric has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
New

export function updateCourtCumulativeMetric(courtId: string, delta: BigInt, timestamp: BigInt, metric: string): void {
// Load or create the current CourtCounter (ID: courtId-0)
let currentCounter = CourtCounter.load(courtId + "-0");
if (!currentCounter) {
currentCounter = new CourtCounter(courtId + "-0");
Severity: Minor
Found in subgraph/core/src/datapoint.ts - About 25 mins to fix

Function updateCourtStateVariable has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
New

export function updateCourtStateVariable(courtId: string, newValue: BigInt, timestamp: BigInt, variable: string): void {
// Load or create the current CourtCounter (ID: courtId-0)
let currentCounter = CourtCounter.load(courtId + "-0");
if (!currentCounter) {
currentCounter = new CourtCounter(courtId + "-0");
Severity: Minor
Found in subgraph/core/src/datapoint.ts - About 45 mins to fix

Function updateCourtCumulativeMetric has 32 lines of code (exceeds 25 allowed). Consider refactoring.
New

export function updateCourtCumulativeMetric(courtId: string, delta: BigInt, timestamp: BigInt, metric: string): void {
// Load or create the current CourtCounter (ID: courtId-0)
let currentCounter = CourtCounter.load(courtId + "-0");
if (!currentCounter) {
currentCounter = new CourtCounter(courtId + "-0");
Severity: Minor
Found in subgraph/core/src/datapoint.ts - About 1 hr to fix

Function updateCourtStateVariable has 30 lines of code (exceeds 25 allowed). Consider refactoring.
New

export function updateCourtStateVariable(courtId: string, newValue: BigInt, timestamp: BigInt, variable: string): void {
// Load or create the current CourtCounter (ID: courtId-0)
let currentCounter = CourtCounter.load(courtId + "-0");
if (!currentCounter) {
currentCounter = new CourtCounter(courtId + "-0");
Severity: Minor
Found in subgraph/core/src/datapoint.ts - About 1 hr to fix

Function addTreeValuesWithDiff has 35 lines of code (exceeds 25 allowed). Consider refactoring.
New

const addTreeValuesWithDiff = (presentCourt: Court, pastCourt: CourtCounter | undefined): CourtWithTree => {
const presentCourtWithTree = addTreeValues(presentCourt);
 
if (!pastCourt) {
console.warn(`Missing snapshot for court ${presentCourt.id}, falling back to live`);
Severity: Minor
Found in web/src/hooks/queries/useHomePageBlockQuery.ts - About 1 hr to fix

Similar blocks of code found in 2 locations. Consider refactoring.
New

if (!currentCounter) {
currentCounter = new CourtCounter(courtId + "-0");
currentCounter.court = courtId;
currentCounter.numberDisputes = ZERO;
currentCounter.numberVotes = ZERO;
Severity: Major
Found in subgraph/core/src/datapoint.ts and 1 other location - About 1 hr to fix
subgraph/core/src/datapoint.ts on lines 137..149

Similar blocks of code found in 2 locations. Consider refactoring.
New

if (!currentCounter) {
currentCounter = new CourtCounter(courtId + "-0");
currentCounter.court = courtId;
currentCounter.numberDisputes = ZERO;
currentCounter.numberVotes = ZERO;
Severity: Major
Found in subgraph/core/src/datapoint.ts and 1 other location - About 1 hr to fix
subgraph/core/src/datapoint.ts on lines 99..106

Similar blocks of code found in 2 locations. Consider refactoring.
New

if (metric === "numberDisputes") {
currentCounter.numberDisputes = currentCounter.numberDisputes.plus(delta);
} else if (metric === "numberVotes") {
currentCounter.numberVotes = currentCounter.numberVotes.plus(delta);
}
Severity: Major
Found in subgraph/core/src/datapoint.ts and 1 other location - About 1 hr to fix
subgraph/core/src/datapoint.ts on lines 126..130

Similar blocks of code found in 2 locations. Consider refactoring.
New

if (metric === "numberDisputes") {
dailyCounter.numberDisputes = dailyCounter.numberDisputes.plus(delta);
} else if (metric === "numberVotes") {
dailyCounter.numberVotes = dailyCounter.numberVotes.plus(delta);
}
Severity: Major
Found in subgraph/core/src/datapoint.ts and 1 other location - About 1 hr to fix
subgraph/core/src/datapoint.ts on lines 107..111

Identifier 'dayID' is never reassigned; use 'const' instead of 'let'.
New

let dayID = timestamp.toI32() / 86400; // Seconds to days
Severity: Minor
Found in subgraph/core/src/datapoint.ts by tslint

Identifier 'dayStartTimestamp' is never reassigned; use 'const' instead of 'let'.
New

let dayStartTimestamp = dayID * 86400;
Severity: Minor
Found in subgraph/core/src/datapoint.ts by tslint

Identifier 'dayID' is never reassigned; use 'const' instead of 'let'.
New

let dayID = timestamp.toI32() / 86400;
Severity: Minor
Found in subgraph/core/src/datapoint.ts by tslint

Identifier 'dayStartTimestamp' is never reassigned; use 'const' instead of 'let'.
New

let dayStartTimestamp = dayID * 86400;
Severity: Minor
Found in subgraph/core/src/datapoint.ts by tslint

unused expression, expected an assignment or function call
Fixed

Severity: Minor
Found in web/src/hooks/queries/useHomePageBlockQuery.ts by tslint

unused expression, expected an assignment or function call
Fixed

Severity: Minor
Found in web/src/hooks/queries/useHomePageBlockQuery.ts by tslint

statements are not aligned
Fixed

Severity: Minor
Found in web/src/hooks/queries/useHomePageBlockQuery.ts by tslint

Missing semicolon
Fixed

Severity: Minor
Found in web/src/hooks/queries/useHomePageBlockQuery.ts by tslint

Missing semicolon
Fixed

Severity: Minor
Found in web/src/hooks/queries/useHomePageBlockQuery.ts by tslint

Unnecessary semicolon
Fixed

Severity: Minor
Found in web/src/hooks/queries/useHomePageBlockQuery.ts by tslint

There are no issues that match your filters.

Category
Status