jon48/webtrees-lib

View on GitHub
app/Module/Sosa/Services/SosaStatisticsService.php

Summary

Maintainability
D
1 day
Test Coverage

File SosaStatisticsService.php has 358 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * webtrees-lib: MyArtJaub library for webtrees
 *
Severity: Minor
Found in app/Module/Sosa/Services/SosaStatisticsService.php - About 4 hrs to fix

    Method pedigreeCollapseByGenerationData has 110 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function pedigreeCollapseByGenerationData(): array
        {
            if (!$this->isPdoSupported()) {
                return [];
            }
    Severity: Major
    Found in app/Module/Sosa/Services/SosaStatisticsService.php - About 4 hrs to fix

      The class SosaStatisticsService has 13 public methods. Consider refactoring SosaStatisticsService to keep number of public methods under 10.
      Open

      class SosaStatisticsService
      {
          private UserInterface $user;
          private Tree $tree;
      
      

      TooManyPublicMethods

      Since: 0.1

      A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      Example

      Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

      Method generationDepthStatsAtGeneration has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function generationDepthStatsAtGeneration(int $gen): Collection
          {
              if (!$this->isPdoSupported()) {
                  return collect();
              }
      Severity: Minor
      Found in app/Module/Sosa/Services/SosaStatisticsService.php - About 1 hr to fix

        Method topMultipleAncestorsWithNoTies has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function topMultipleAncestorsWithNoTies(int $limit): Collection
            {
                $table_prefix = DB::connection()->getTablePrefix();
                $multiple_ancestors = DB::table('maj_sosa AS sosa')
                    ->select('sosa.majs_i_id AS sosa_i_id')
        Severity: Minor
        Found in app/Module/Sosa/Services/SosaStatisticsService.php - About 1 hr to fix

          Method ancestorsDispersionForGeneration has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function ancestorsDispersionForGeneration(int $gen): Collection
              {
                  if (!$this->isPdoSupported()) {
                      return collect();
                  }
          Severity: Minor
          Found in app/Module/Sosa/Services/SosaStatisticsService.php - About 1 hr to fix

            The method pedigreeCollapseByGenerationData() has 135 lines of code. Current threshold is set to 100. Avoid really long methods.
            Open

                public function pedigreeCollapseByGenerationData(): array
                {
                    if (!$this->isPdoSupported()) {
                        return [];
                    }

            Avoid excessively long variable names like $root_ancestors_contributions. Keep variable name length under 20.
            Open

                    $root_ancestors_contributions = DB::table('maj_sosa AS sosa')

            LongVariable

            Since: 0.2

            Detects when a field, formal or local variable is declared with a long name.

            Example

            class Something {
                protected $reallyLongIntName = -3; // VIOLATION - Field
                public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                    $otherReallyLongName = -5; // VIOLATION - Local
                    for ($interestingIntIndex = 0; // VIOLATION - For
                         $interestingIntIndex < 10;
                         $interestingIntIndex++ ) {
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#longvariable

            Avoid excessively long variable names like $missing_ancestors_by_gen. Keep variable name length under 20.
            Open

                    $missing_ancestors_by_gen = DB::table('maj_sosa AS sosa')

            LongVariable

            Since: 0.2

            Detects when a field, formal or local variable is declared with a long name.

            Example

            class Something {
                protected $reallyLongIntName = -3; // VIOLATION - Field
                public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                    $otherReallyLongName = -5; // VIOLATION - Local
                    for ($interestingIntIndex = 0; // VIOLATION - For
                         $interestingIntIndex < 10;
                         $interestingIntIndex++ ) {
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#longvariable

            Avoid excessively long variable names like $consolidated_ancestors_branches. Keep variable name length under 20.
            Open

                    $consolidated_ancestors_branches = DB::table('maj_sosa')

            LongVariable

            Since: 0.2

            Detects when a field, formal or local variable is declared with a long name.

            Example

            class Something {
                protected $reallyLongIntName = -3; // VIOLATION - Field
                public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                    $otherReallyLongName = -5; // VIOLATION - Local
                    for ($interestingIntIndex = 0; // VIOLATION - For
                         $interestingIntIndex < 10;
                         $interestingIntIndex++ ) {
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#longvariable

            Avoid excessively long variable names like $ancestors_contributions_sum. Keep variable name length under 20.
            Open

                    $ancestors_contributions_sum = DB::connection()->query()

            LongVariable

            Since: 0.2

            Detects when a field, formal or local variable is declared with a long name.

            Example

            class Something {
                protected $reallyLongIntName = -3; // VIOLATION - Field
                public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                    $otherReallyLongName = -5; // VIOLATION - Local
                    for ($interestingIntIndex = 0; // VIOLATION - For
                         $interestingIntIndex < 10;
                         $interestingIntIndex++ ) {
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#longvariable

            Avoid excessively long variable names like $known_ancestors_contributions. Keep variable name length under 20.
            Open

                    $known_ancestors_contributions = DB::table('maj_sosa AS sosa')

            LongVariable

            Since: 0.2

            Detects when a field, formal or local variable is declared with a long name.

            Example

            class Something {
                protected $reallyLongIntName = -3; // VIOLATION - Field
                public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                    $otherReallyLongName = -5; // VIOLATION - Local
                    for ($interestingIntIndex = 0; // VIOLATION - For
                         $interestingIntIndex < 10;
                         $interestingIntIndex++ ) {
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#longvariable

            There are no issues that match your filters.

            Category
            Status