fisharebest/webtrees

View on GitHub

Showing 1,726 of 2,403 total issues

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

    public function getBlock(Tree $tree, int $block_id, string $context, array $config = []): string
    {
        $old_language = I18N::languageTag();

        $sendmail = (bool) $this->getBlockSetting($block_id, 'sendmail', '1');
Severity: Minor
Found in app/Module/ReviewChangesModule.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

Function editLinesToGedcom has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

    public function editLinesToGedcom(string $record_type, array $levels, array $tags, array $values, bool $append = true): string
    {
        // Assert all arrays are the same size.
        $count = count($levels);
        assert($count > 0);
Severity: Minor
Found in app/Services/GedcomEditService.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

Function docStartHandler has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

    protected function docStartHandler(array $attrs): void
    {
        $this->parser = $this->xml_parser;

        // Custom page width
Severity: Minor
Found in app/Report/ReportParserGenerate.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

Function usersLoggedInQuery has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

    private function usersLoggedInQuery(string $type): string
    {
        $content   = '';
        $anonymous = 0;
        $logged_in = [];
Severity: Minor
Found in app/Statistics/Repository/UserRepository.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 censusPlaces has 129 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function censusPlaces(string $locale): array
    {
        switch ($locale) {
            case 'cs':
                return [
Severity: Major
Found in app/Census/Census.php - About 5 hrs to fix

    Function getStepFamilyLabel has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getStepFamilyLabel(Family $step_family): string
        {
            foreach ($this->childFamilies() as $family) {
                if ($family !== $step_family) {
                    // Must be a step-family
    Severity: Minor
    Found in app/Individual.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

    FamilyDatesRepository has 38 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class FamilyDatesRepository implements FamilyDatesRepositoryInterface
    {
        /**
         * Sorting directions.
         */
    Severity: Minor
    Found in app/Statistics/Repository/FamilyDatesRepository.php - About 5 hrs to fix

      Function getCalendarEvents has a Cognitive Complexity of 33 (exceeds 5 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: Minor
      Found in app/Services/CalendarService.php - About 4 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 handle has 121 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function handle(ServerRequestInterface $request): ResponseInterface
          {
              $this->layout = 'layouts/ajax';
      
              $tree = Validator::attributes($request)->tree();
      Severity: Major
      Found in app/Http/RequestHandlers/GedcomLoad.php - About 4 hrs to fix

        SearchService has 37 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class SearchService
        {
            // Do not attempt to show search results larger than this/
            protected const MAX_SEARCH_RESULTS = 5000;
        
        
        Severity: Minor
        Found in app/Services/SearchService.php - About 4 hrs to fix

          Relationship has 37 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Relationship
          {
              // The basic components of a relationship.
              // These strings are needed for compatibility with the legacy algorithm.
              // Once that has been replaced, it may be more efficient to use integers here.
          Severity: Minor
          Found in app/Relationship.php - About 4 hrs to fix

            Function getPersonNameStartHandler has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function getPersonNameStartHandler(array $attrs): void
                {
                    $id    = '';
                    $match = [];
                    if (empty($attrs['id'])) {
            Severity: Minor
            Found in app/Report/ReportParserGenerate.php - About 4 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 upgrade has 118 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function upgrade(): void
                {
                    // It is simpler to create a new table than to update the existing one.
            
                    if (!DB::schema()->hasTable('place_location')) {
            Severity: Major
            Found in app/Schema/Migration44.php - About 4 hrs to fix

              File I18N.php has 361 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

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

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

                    public function handle(ServerRequestInterface $request): ResponseInterface
                    {
                        $this->layout = 'layouts/ajax';
                
                        $tree = Validator::attributes($request)->tree();
                Severity: Minor
                Found in app/Http/RequestHandlers/GedcomLoad.php - About 4 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 31 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function handle(ServerRequestInterface $request): ResponseInterface
                    {
                        $source  = Validator::parsedBody($request)->isInArray(['client', 'server'])->string('source');
                        $options = Validator::parsedBody($request)->isInArray(['add', 'addupdate', 'update'])->string('options');
                
                
                Severity: Minor
                Found in app/Http/RequestHandlers/MapDataImportAction.php - About 4 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 addAncestors has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function addAncestors(array &$list, string $pid, bool $children = false, int $generations = -1): void
                    {
                        $genlist                = [$pid];
                        $list[$pid]->generation = 1;
                        while (count($genlist) > 0) {
                Severity: Minor
                Found in app/Report/ReportParserGenerate.php - About 4 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 getAllNames has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function getAllNames(): array
                    {
                        if ($this->getAllNames === []) {
                            // Check the script used by each name, so we can match cyrillic with cyrillic, greek with greek, etc.
                            $husb_names = [];
                Severity: Minor
                Found in app/Family.php - About 4 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 FanChartModule.php has 355 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

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

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

                      public function historicEventsAll(): Collection
                      {
                          switch (I18N::languageTag()) {
                              case 'fr':
                              case 'fr-CA':
                  Severity: Major
                  Found in app/Module/FrenchHistory.php - About 4 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language