fisharebest/webtrees

View on GitHub
app/Module/InteractiveTree/TreeView.php

Summary

Maintainability
D
1 day
Test Coverage

Function drawPerson has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    private function drawPerson(Individual $person, int $gen, int $state, Family|null $pfamily, string $line, bool $isRoot): string
    {
        if ($gen < 0) {
            return '';
        }
Severity: Minor
Found in app/Module/InteractiveTree/TreeView.php - 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

Method drawPerson has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function drawPerson(Individual $person, int $gen, int $state, Family|null $pfamily, string $line, bool $isRoot): string
    {
        if ($gen < 0) {
            return '';
        }
Severity: Major
Found in app/Module/InteractiveTree/TreeView.php - About 3 hrs to fix

    Function drawChildren has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        private function drawChildren(Collection $familyList, int $gen = 1, bool $ajax = false): string
        {
            $html          = '';
            $children2draw = [];
            $f2load        = [];
    Severity: Minor
    Found in app/Module/InteractiveTree/TreeView.php - 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

    Method drawChildren has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function drawChildren(Collection $familyList, int $gen = 1, bool $ajax = false): string
        {
            $html          = '';
            $children2draw = [];
            $f2load        = [];
    Severity: Minor
    Found in app/Module/InteractiveTree/TreeView.php - About 1 hr to fix

      Function getIndividuals has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getIndividuals(Tree $tree, string $request): string
          {
              $json_requests = explode(';', $request);
              $r             = [];
      
      
      Severity: Minor
      Found in app/Module/InteractiveTree/TreeView.php - 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

      Method drawPerson has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          private function drawPerson(Individual $person, int $gen, int $state, Family|null $pfamily, string $line, bool $isRoot): string
      Severity: Minor
      Found in app/Module/InteractiveTree/TreeView.php - About 45 mins to fix

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

            private function drawPersonName(Individual $individual, string $dashed): string
            {
                $family = $individual->childFamilies()->first();
                if ($family) {
                    $family_name = strip_tags($family->fullName());
        Severity: Minor
        Found in app/Module/InteractiveTree/TreeView.php - 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

        There are no issues that match your filters.

        Category
        Status