kleros/kleros-v2

View on GitHub
web/src/pages/Cases/CasesFetcher.tsx

Summary

Maintainability
A
3 hrs
Test Coverage

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

const calculateStats = (
  isCourtFilter: boolean,
  courtData: CourtDetailsQuery["court"],
  counters: CounterQuery["counter"],
  filter?: Dispute_Filter
Severity: Minor
Found in web/src/pages/Cases/CasesFetcher.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 CasesFetcher has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const CasesFetcher: React.FC = () => {
  const { page, order, filter } = useParams();
  const location = useRootPath();
  const navigate = useNavigate();
  const isDesktop = useIsDesktop();
Severity: Minor
Found in web/src/pages/Cases/CasesFetcher.tsx - About 1 hr to fix

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

const CasesFetcher: React.FC = () => {
  const { page, order, filter } = useParams();
  const location = useRootPath();
  const navigate = useNavigate();
  const isDesktop = useIsDesktop();
Severity: Minor
Found in web/src/pages/Cases/CasesFetcher.tsx - 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

Multiple variable declarations in the same statement are forbidden
Open

  let totalCases: number, ruledCases: number;
Severity: Minor
Found in web/src/pages/Cases/CasesFetcher.tsx by tslint

Rule: one-variable-per-declaration

Disallows multiple variable definitions in the same declaration statement.

Config

One argument may be optionally provided:

  • ignore-for-loop allows multiple variable definitions in a for loop declaration.
Examples
"one-variable-per-declaration": true
"one-variable-per-declaration": true,ignore-for-loop
Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "enum": [
      "ignore-for-loop"
    ]
  },
  "minLength": 0,
  "maxLength": 1
}

For more information see this page.

Missing radix parameter
Open

  const pageNumber = parseInt(page ?? "1");
Severity: Minor
Found in web/src/pages/Cases/CasesFetcher.tsx by tslint

Rule: radix

Requires the radix parameter to be specified when calling parseInt.

Rationale

From MDN:

Always specify this parameter to eliminate reader confusion and to guarantee predictable behavior. Different implementations produce different results when a radix is not specified, usually defaulting the value to 10.

Config

Not configurable.

Examples
"radix": true

For more information see this page.

There are no issues that match your filters.

Category
Status