fisharebest/webtrees

View on GitHub

Showing 1,726 of 2,403 total issues

Method myPlot has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function myPlot(
        string $chart_title,
        array $x_axis,
        string $x_axis_title,
        array $ydata,
Severity: Major
Found in app/Module/StatisticsChartModule.php - About 2 hrs to fix

    Method getCloseRelationship has 71 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function getCloseRelationship(Individual $individual1, Individual $individual2, int $maxlength = 4): array
        {
            if ($individual1 === $individual2) {
                return [$individual1];
            }
    Severity: Major
    Found in app/Services/RelationshipService.php - About 2 hrs to fix

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

          public function handle(ServerRequestInterface $request): ResponseInterface
          {
              $user           = Validator::attributes($request)->user();
              $user_id        = Validator::parsedBody($request)->integer('user_id');
              $username       = Validator::parsedBody($request)->string('username');
      Severity: Major
      Found in app/Http/RequestHandlers/UserEditAction.php - About 2 hrs to fix

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

            public function handle(ServerRequestInterface $request): ResponseInterface
            {
                $user = Validator::attributes($request)->user();
        
                $languages = $this->module_service->findByInterface(ModuleLanguageInterface::class, true)
        Severity: Major
        Found in app/Http/RequestHandlers/UserListData.php - About 2 hrs to fix

          File Relationship.php has 285 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

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

            Method getDescendantsHtml has 70 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function getDescendantsHtml(Tree $tree, array $individuals, array $ancestors, string $surname, bool $soundex_dm, bool $soundex_std, Individual $individual, Family|null $parents = null): string
                {
                    $module = $this->module_service
                        ->findByComponent(ModuleChartInterface::class, $tree, Auth::user())
                        ->first(static fn (ModuleInterface $module) => $module instanceof RelationshipsChartModule);
            Severity: Major
            Found in app/Module/BranchesListModule.php - About 2 hrs to fix

              File treeview.js has 282 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /**
               * webtrees: online genealogy
               * Copyright (C) 2023 webtrees development team
               * This program is free software: you can redistribute it and/or modify
               * it under the terms of the GNU General Public License as published by
              Severity: Minor
              Found in resources/js/treeview.js - About 2 hrs to fix

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

                    public function handle(ServerRequestInterface $request): ResponseInterface
                    {
                        $tree  = Validator::attributes($request)->tree();
                        $user  = Validator::attributes($request)->user();
                        $scale = Validator::attributes($request)->isBetween(self::MINIMUM_SCALE, self::MAXIMUM_SCALE)->integer('scale');
                Severity: Major
                Found in app/Module/TimelineChartModule.php - About 2 hrs to fix

                  Function getBlock has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function getBlock(Tree $tree, int $block_id, string $context, array $config = []): string
                      {
                          $PEDIGREE_ROOT_ID = $tree->getPreference('PEDIGREE_ROOT_ID');
                          $gedcomid         = $tree->getUserPreference(Auth::user(), UserInterface::PREF_TREE_ACCOUNT_XREF);
                          $default_xref     = $gedcomid ?: $PEDIGREE_ROOT_ID;
                  Severity: Minor
                  Found in app/Module/ChartsBlockModule.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

                  Function insertMissingLevels has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function insertMissingLevels(Tree $tree, string $tag, string $gedcom, bool $include_hidden): string
                      {
                          $next_level = substr_count($tag, ':') + 1;
                          $factory    = Registry::elementFactory();
                          $subtags    = $factory->make($tag)->subtags();
                  Severity: Minor
                  Found in app/Services/GedcomEditService.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

                  Function lineStartHandler has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function lineStartHandler(array $attrs): void
                      {
                          // Start horizontal position, current position (default)
                          $x1 = ReportBaseElement::CURRENT_POSITION;
                          if (isset($attrs['x1'])) {
                  Severity: Minor
                  Found in app/Report/ReportParserGenerate.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

                  Function repeatTagEndHandler has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

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

                      public function leafletJsTileLayers(): array
                      {
                          $api_key = $this->getPreference('api_key');
                  
                          return [
                  Severity: Major
                  Found in app/Module/MapBox.php - About 2 hrs to fix

                    Function calGenerateSelectorContent has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      function calGenerateSelectorContent (dateFieldId, dateDivId, date) {
                        let i, j;
                        let content = '<table border="1"><tr>';
                        content += '<td><select class="form-select" id="' + dateFieldId + '_daySelect" onchange="return webtrees.calUpdateCalendar(\'' + dateFieldId + '\', \'' + dateDivId + '\');">';
                        for (i = 1; i < 32; i++) {
                    Severity: Major
                    Found in resources/js/webtrees.js - About 2 hrs to fix

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

                          public function handle(ServerRequestInterface $request): ResponseInterface
                          {
                              $tree  = Validator::attributes($request)->tree();
                              $user  = Validator::attributes($request)->user();
                              $xrefs = Validator::queryParams($request)->string('xrefs', '');
                      Severity: Major
                      Found in app/Module/LifespansChartModule.php - About 2 hrs to fix

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

                            public function handle(ServerRequestInterface $request): ResponseInterface
                            {
                                $tree     = Validator::attributes($request)->tree();
                                $view     = Validator::attributes($request)->isInArray(['day', 'month', 'year'])->string('view');
                                $cal      = Validator::queryParams($request)->string('cal', '');
                        Severity: Major
                        Found in app/Http/RequestHandlers/CalendarPage.php - About 2 hrs to fix

                          Method run has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function run(): void
                              {
                                  // Setting up the styles
                                  echo '<style>';
                                  echo '#bodydiv { font: 10px sans-serif;}';
                          Severity: Major
                          Found in app/Report/HtmlRenderer.php - About 2 hrs to fix

                            Method relativesEndHandler has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                protected function relativesEndHandler(): void
                                {
                                    $this->process_repeats--;
                                    if ($this->process_repeats > 0) {
                                        return;
                            Severity: Major
                            Found in app/Report/ReportParserGenerate.php - About 2 hrs to fix

                              Method isDead has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function isDead(): bool
                                  {
                                      $MAX_ALIVE_AGE = (int) $this->tree->getPreference('MAX_ALIVE_AGE');
                                      $today_jd      = Registry::timestampFactory()->now()->julianDay();
                              
                              
                              Severity: Major
                              Found in app/Individual.php - About 2 hrs to fix

                                Method getWidth has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function getWidth($renderer): array
                                    {
                                        // Setup the style name
                                        $renderer->setCurrentStyle('footnotenum');
                                
                                
                                Severity: Major
                                Found in app/Report/ReportHtmlFootnote.php - About 2 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language