fisharebest/webtrees

View on GitHub

Showing 1,726 of 2,403 total issues

Method addName has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function addName(string $type, string $value, string $gedcom): void
    {
        ////////////////////////////////////////////////////////////////////////////
        // Extract the structured name parts - use for "sortable" names and indexes
        ////////////////////////////////////////////////////////////////////////////
Severity: Major
Found in app/Individual.php - About 2 hrs to fix

    Method calculateRelationships has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function calculateRelationships(
            Individual $individual1,
            Individual $individual2,
            int $recursion,
            bool $ancestor = false
    Severity: Major
    Found in app/Module/RelationshipsChartModule.php - About 2 hrs to fix

      Method handle has 59 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();
              $xref        = Validator::attributes($request)->isXref()->string('xref');
      Severity: Major
      Found in app/Module/DescendancyChartModule.php - About 2 hrs to fix

        Method duplicateRecords has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function duplicateRecords(Tree $tree): array
            {
                // We can't do any reasonable checks using MySQL.
                // Will need to wait for a "repositories" table.
                $repositories = [];
        Severity: Major
        Found in app/Services/AdminService.php - About 2 hrs to fix

          Method commonCountriesList has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function commonCountriesList(): string
              {
                  $countries = DB::table('places')
                      ->join('placelinks', static function (JoinClause $join): void {
                          $join
          Severity: Major
          Found in app/Statistics/Repository/PlaceRepository.php - About 2 hrs to fix

            File ManageMediaData.php has 264 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/ManageMediaData.php - About 2 hrs to fix

              Consider simplifying this complex logical expression.
              Open

                                      if ($hd->day === 30 && $hd->month === 2 && $hd->year !== 0 && $hd1->daysInMonth() < 30) {
                                          // 30 CSH - Last day in CSH
                                          $jd_yahrtzeit = $jewish_calendar->ymdToJd($today->year, 3, 1) - 1;
                                      } elseif ($hd->day === 30 && $hd->month === 3 && $hd->year !== 0 && $hd1->daysInMonth() < 30) {
                                          // 30 KSL - Last day in KSL
              Severity: Critical
              Found in app/Module/YahrzeitModule.php - About 2 hrs to fix

                Timestamp has 22 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class Timestamp implements TimestampInterface
                {
                    private CarbonImmutable $carbon;
                
                    public function __construct(int $timestamp, string $timezone, string $locale)
                Severity: Minor
                Found in app/Timestamp.php - About 2 hrs to fix

                  Consider simplifying this complex logical expression.
                  Open

                          if (($this->process_footnote || $name === 'Footnote') && ($this->process_ifs === 0 || $name === 'if') && ($this->process_gedcoms === 0 || $name === 'Gedcom') && ($this->process_repeats === 0 || $name === 'Facts' || $name === 'RepeatTag' || $name === 'List' || $name === 'Relatives')) {
                              $method = $name . 'EndHandler';
                  
                              if (method_exists($this, $method)) {
                                  $this->{$method}();
                  Severity: Critical
                  Found in app/Report/ReportParserGenerate.php - About 2 hrs to fix

                    MediaRepository has 22 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class MediaRepository implements MediaRepositoryInterface
                    {
                        private ColorService $color_service;
                    
                        private Tree $tree;
                    Severity: Minor
                    Found in app/Statistics/Repository/MediaRepository.php - About 2 hrs to fix

                      Method historicEventsAll has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function historicEventsAll(): Collection
                          {
                              switch (I18N::languageTag()) {
                                  case 'en-AU':
                                  case 'en-GB':
                      Severity: Major
                      Found in app/Module/BritishMonarchs.php - About 2 hrs to fix

                        Method getBlock has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function getBlock(Tree $tree, int $block_id, string $context, array $config = []): string
                            {
                                $days      = (int) $this->getBlockSetting($block_id, 'days', self::DEFAULT_DAYS);
                                $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', self::DEFAULT_INFO_STYLE);
                                $sortStyle = $this->getBlockSetting($block_id, 'sortStyle', self::DEFAULT_SORT_STYLE);
                        Severity: Major
                        Found in app/Module/RecentChangesModule.php - About 2 hrs to fix

                          Method handle has 58 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();
                                  $place_id = Validator::attributes($request)->integer('place_id', 0);
                          Severity: Major
                          Found in app/Module/PlaceHierarchyListModule.php - About 2 hrs to fix

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

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

                              Method handle has 57 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();
                                      $xref        = Validator::attributes($request)->isXref()->string('xref');
                              Severity: Major
                              Found in app/Module/PedigreeChartModule.php - About 2 hrs to fix

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

                                    public function handle(ServerRequestInterface $request): ResponseInterface
                                    {
                                        $tree       = Validator::attributes($request)->tree();
                                        $ip         = Validator::attributes($request)->string('client-ip');
                                        $base_url   = Validator::attributes($request)->string('base_url');
                                Severity: Major
                                Found in app/Http/RequestHandlers/ContactAction.php - About 2 hrs to fix

                                  Method process has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
                                      {
                                          // Ugly URLs store the path in a query parameter.
                                          $url_route = Validator::queryParams($request)->string('route', '');
                                  
                                  
                                  Severity: Major
                                  Found in app/Http/Middleware/Router.php - About 2 hrs to fix

                                    Method repeatTagStartHandler has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        protected function repeatTagStartHandler(array $attrs): void
                                        {
                                            $this->process_repeats++;
                                            if ($this->process_repeats > 1) {
                                                return;
                                    Severity: Major
                                    Found in app/Report/ReportParserGenerate.php - About 2 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

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

                                          public function handle(ServerRequestInterface $request): ResponseInterface
                                          {
                                              $fact_id   = Validator::parsedBody($request)->string('fact_id');
                                              $indi_xref = Validator::parsedBody($request)->isXref()->string('indi_xref');
                                              $obje_xref = Validator::parsedBody($request)->isXref()->string('obje_xref');
                                      Severity: Minor
                                      Found in app/Http/RequestHandlers/FixLevel0MediaAction.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

                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language