fisharebest/webtrees

View on GitHub

Showing 1,726 of 2,403 total issues

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

    public function getWidth($renderer): array
    {
        // Setup the style name, a font must be selected to calculate the width
        $renderer->setCurrentStyle('footnotenum');

Severity: Major
Found in app/Report/ReportPdfFootnote.php - About 2 hrs to fix

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

        private function commonGivenQuery(string $sex, string $type, bool $show_tot, int $threshold, int $maxtoshow)
        {
            $query = DB::table('name')
                ->join('individuals', static function (JoinClause $join): void {
                    $join
    Severity: Major
    Found in app/Statistics/Repository/IndividualRepository.php - About 2 hrs to fix

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

          protected function docStartHandler(array $attrs): void
          {
              $this->parser = $this->xml_parser;
      
              // Custom page width
      Severity: Major
      Found in app/Report/ReportParserGenerate.php - About 2 hrs to fix

        Method make has 66 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function make(string $date): AbstractCalendarDate
            {
                // Valid calendar escape specified? - use it
                if (preg_match('/^(@#D(?:GREGORIAN|JULIAN|HEBREW|HIJRI|JALALI|FRENCH R|ROMAN)+@) ?(.*)/', $date, $match)) {
                    $cal  = $match[1];
        Severity: Major
        Found in app/Factories/CalendarDateFactory.php - About 2 hrs to fix

          Method getCalendarEvents has 66 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getCalendarEvents(int $jd1, int $jd2, string $facts, Tree $tree, string $filterof = '', string $filtersx = ''): array
              {
                  // Events that start or end during the period
                  $query = DB::table('dates')
                      ->where('d_file', '=', $tree->id())
          Severity: Major
          Found in app/Services/CalendarService.php - About 2 hrs to fix

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

                public function getWidth($renderer): array
                {
                    // Setup the style name, a font must be selected to calculate the width
                    if ($renderer->getCurrentStyle() !== $this->styleName) {
                        $renderer->setCurrentStyle($this->styleName);
            Severity: Major
            Found in app/Report/ReportHtmlText.php - About 2 hrs to fix

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

                  public function getWidth($renderer): array
                  {
                      // Setup the style name, a font must be selected to calculate the width
                      if ($renderer->getCurrentStyle() !== $this->styleName) {
                          $renderer->setCurrentStyle($this->styleName);
              Severity: Major
              Found in app/Report/ReportPdfText.php - About 2 hrs to fix

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

                    public function handle(ServerRequestInterface $request): ResponseInterface
                    {
                        $ignore_facts = [
                            'INDI:NAME',
                            'INDI:SEX',
                Severity: Major
                Found in app/Http/RequestHandlers/FixLevel0MediaData.php - About 2 hrs to fix

                  Method createMediaObject has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function createMediaObject(string $gedcom, Tree $tree): string
                      {
                          preg_match('/\n\d FILE (.+)/', $gedcom, $match);
                          $file = $match[1] ?? '';
                  
                  
                  Severity: Major
                  Found in app/Services/GedcomImportService.php - About 2 hrs to fix

                    Method repeatTagEndHandler has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

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

                      Function paginateQuery has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                      Open

                          private function paginateQuery(Builder $query, Closure $row_mapper, Closure $row_filter, int $offset, int $limit): Collection
                          {
                              $collection = new Collection();
                      
                              foreach ($query->cursor() as $row) {
                      Severity: Minor
                      Found in app/Services/SearchService.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 factsStartHandler has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function factsStartHandler(array $attrs): void
                          {
                              $this->process_repeats++;
                              if ($this->process_repeats > 1) {
                                  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 historicEventsAll has 64 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/NewZealandPrimeMinisters.php - About 2 hrs to fix

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

                            public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
                            {
                                $ua      = Validator::serverParams($request)->string('HTTP_USER_AGENT', '');
                                $ip      = Validator::attributes($request)->string('client-ip');
                                $address = IPFactory::parseAddressString($ip);
                        Severity: Major
                        Found in app/Http/Middleware/BadBotBlocker.php - About 2 hrs to fix

                          Method webtreesSubTags has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private function webtreesSubTags(): array
                              {
                                  return [
                                      'FAM'              => [['_UID', '0:M']],
                                      'FAM:*:SOUR:DATA'  => [['TEXT', '0:1']],
                          Severity: Major
                          Found in app/Gedcom.php - About 2 hrs to fix

                            Method gedcomValueStartHandler has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                protected function gedcomValueStartHandler(array $attrs): void
                                {
                                    $id    = '';
                                    $match = [];
                                    if (preg_match('/0 @(.+)@/', $this->gedrec, $match)) {
                            Severity: Major
                            Found in app/Report/ReportParserGenerate.php - About 2 hrs to fix

                              File GedcomL.php has 273 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

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

                                Method chart has 63 lines of code (exceeds 25 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: Major
                                Found in app/Module/TimelineChartModule.php - About 2 hrs to fix

                                  Method handle has 63 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();
                                          $style       = Validator::attributes($request)->isInArrayKeys($this->styles())->string('style');
                                  Severity: Major
                                  Found in app/Module/AncestorsChartModule.php - About 2 hrs to fix

                                    Method getGedcomValue has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        private function getGedcomValue(string $tag, int $level, string $gedrec): string
                                        {
                                            if ($gedrec === '') {
                                                return '';
                                            }
                                    Severity: Major
                                    Found in app/Report/ReportParserGenerate.php - About 2 hrs to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language