fisharebest/webtrees

View on GitHub

Showing 1,726 of 2,403 total issues

File Tree.php has 334 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * webtrees: online genealogy
 * Copyright (C) 2023 webtrees development team
Severity: Minor
Found in app/Tree.php - About 4 hrs to fix

    Consider simplifying this complex logical expression.
    Open

                            if ($linked === null) {
                                $message  = I18N::translate('%s does not exist.', e($xref1));
                                $errors[] = $this->lineError($tree, $record->type, $record->xref, $line_number, $line, $message, $tag . '-' . $xref1);
                            } elseif ($element instanceof XrefFamily && $linked->type !== Family::RECORD_TYPE) {
                                $message  = $this->linkErrorMessage($tree, $xref1, $linked->type, Family::RECORD_TYPE);
    Severity: Critical
    Found in app/Http/RequestHandlers/CheckTree.php - About 4 hrs to fix

      HtmlRenderer has 32 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class HtmlRenderer extends AbstractRenderer
      {
          // Cell padding
          public float $cPadding = 2;
      
      
      Severity: Minor
      Found in app/Report/HtmlRenderer.php - About 4 hrs to fix

        Method handle has 99 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function handle(ServerRequestInterface $request): ResponseInterface
            {
                $this->checkRegistrationAllowed();
        
                $tree     = Validator::attributes($request)->treeOptional();
        Severity: Major
        Found in app/Http/RequestHandlers/RegisterAction.php - About 3 hrs to fix

          Method chart has 98 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function chart(Individual $individual1, Individual $individual2, int $recursion, int $ancestors): ResponseInterface
              {
                  $tree = $individual1->tree();
          
                  $max_recursion = (int) $tree->getPreference('RELATIONSHIP_RECURSION', static::DEFAULT_RECURSION);
          Severity: Major
          Found in app/Module/RelationshipsChartModule.php - About 3 hrs to fix

            Method textBoxStartHandler has 98 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function textBoxStartHandler(array $attrs): void
                {
                    // string Background color code
                    $bgcolor = '';
                    if (!empty($attrs['bgcolor'])) {
            Severity: Major
            Found in app/Report/ReportParserGenerate.php - About 3 hrs to fix

              Function getEventsList has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getEventsList(int $jd1, int $jd2, string $events, bool $only_living, string $sort_by, Tree $tree): Collection
                  {
                      $found_facts = [];
                      $facts       = new Collection();
              
              
              Severity: Minor
              Found in app/Services/CalendarService.php - About 3 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 render has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function render($renderer): void
                  {
                      $temptext = str_replace('#PAGENUM#', (string) $renderer->tcpdf->PageNo(), $this->text);
                      // underline «title» part of Source item
                      $temptext = str_replace([
              Severity: Minor
              Found in app/Report/ReportPdfCell.php - About 3 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 extractNamesFromFacts has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function extractNamesFromFacts(int $level, string $fact_type, Collection $facts): void
                  {
                      $sublevel    = $level + 1;
                      $subsublevel = $sublevel + 1;
                      foreach ($facts as $fact) {
              Severity: Minor
              Found in app/GedcomRecord.php - About 3 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

              File CheckTree.php has 329 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              
              /**
               * webtrees: online genealogy
               * Copyright (C) 2023 webtrees development team
              Severity: Minor
              Found in app/Http/RequestHandlers/CheckTree.php - About 3 hrs to fix

                Method getAnniversaryEvents has 97 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getAnniversaryEvents(int $jd, string $facts, Tree $tree, string $filterof = '', string $filtersx = ''): array
                    {
                        $found_facts = [];
                
                        $anniversaries = [
                Severity: Major
                Found in app/Services/CalendarService.php - About 3 hrs to fix

                  Method relativesStartHandler has 95 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function relativesStartHandler(array $attrs): void
                      {
                          $this->process_repeats++;
                          if ($this->process_repeats > 1) {
                              return;
                  Severity: Major
                  Found in app/Report/ReportParserGenerate.php - About 3 hrs to fix

                    Method format has 94 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function format(string $format, string $qualifier = ''): string
                        {
                            // Dates can include additional punctuation and symbols. e.g.
                            // %F %j, %Y
                            // %Y. %F %d.
                    Severity: Major
                    Found in app/Date/AbstractCalendarDate.php - About 3 hrs to fix

                      Function chart has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function chart(Tree $tree, array $xrefs, int $scale): ResponseInterface
                          {
                              /** @var Individual[] $individuals */
                              $individuals = array_map(static fn (string $xref): Individual|null => Registry::individualFactory()->make($xref, $tree), $xrefs);
                      
                      
                      Severity: Minor
                      Found in app/Module/TimelineChartModule.php - About 3 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 handle has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function handle(ServerRequestInterface $request): ResponseInterface
                          {
                              $tree = Validator::attributes($request)->tree();
                      
                              $query = Validator::queryParams($request)->string('query', '');
                      Severity: Minor
                      Found in app/Http/RequestHandlers/SearchGeneralPage.php - About 3 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 run has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function run(): void
                          {
                              // Setting up the styles
                              echo '<style>';
                              echo '#bodydiv { font: 10px sans-serif;}';
                      Severity: Minor
                      Found in app/Report/HtmlRenderer.php - About 3 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 cellStartHandler has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function cellStartHandler(array $attrs): void
                          {
                              // string The text alignment of the text in this box.
                              $align = $attrs['align'] ?? '';
                              // RTL supported left/right alignment
                      Severity: Minor
                      Found in app/Report/ReportParserGenerate.php - About 3 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 listEndHandler has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function listEndHandler(): void
                          {
                              $this->process_repeats--;
                              if ($this->process_repeats > 0) {
                                  return;
                      Severity: Minor
                      Found in app/Report/ReportParserGenerate.php - About 3 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 render has 92 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function render($renderer): void
                          {
                              $temptext = str_replace('#PAGENUM#', (string) $renderer->tcpdf->PageNo(), $this->text);
                              // underline «title» part of Source item
                              $temptext = str_replace([
                      Severity: Major
                      Found in app/Report/ReportPdfCell.php - About 3 hrs to fix

                        Method handle has 91 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function handle(ServerRequestInterface $request): ResponseInterface
                            {
                                $tree  = Validator::attributes($request)->tree();
                                $xref1 = Validator::parsedBody($request)->isXref()->string('xref1');
                                $xref2 = Validator::parsedBody($request)->isXref()->string('xref2');
                        Severity: Major
                        Found in app/Http/RequestHandlers/MergeFactsAction.php - About 3 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language