betagouv/service-national-universel

View on GitHub
admin/src/components/PaginationServerDriven.tsx

Summary

Maintainability
B
6 hrs
Test Coverage

Function PaginationServerDriven has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

export default function PaginationServerDriven({ currentPageNumber, setCurrentPageNumber, itemsCountTotal, itemsCountOnCurrentPage, size = 10, setSize }: Props) {
  const displayedPages = 3;
  const itemsCountMax = 10000;
  let itemCountToDisplay = 0;
  if (itemsCountTotal > itemsCountMax) itemCountToDisplay = itemsCountMax;
Severity: Minor
Found in admin/src/components/PaginationServerDriven.tsx - About 5 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 PageButton has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

function PageButton({ page, setCurrentPageNumber, active, lastPage, isLast = false }) {
  const getClass = () => {
    const classTab: string[] = [];
    active ? classTab.push("font-bold bg-gray-100 text-gray-900") : classTab.push("font-normal"); // la page est active
    page !== lastPage && !isLast ? classTab.push("border-r border-solid border-gray-200") : null; // page par defaut
Severity: Minor
Found in admin/src/components/PaginationServerDriven.tsx - About 55 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

There are no issues that match your filters.

Category
Status