fisharebest/webtrees

View on GitHub

Showing 1,726 of 2,403 total issues

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

    public function commonCountriesList(): string
    {
        $countries = DB::table('places')
            ->join('placelinks', static function (JoinClause $join): void {
                $join
Severity: Minor
Found in app/Statistics/Repository/PlaceRepository.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 render has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public function render($renderer, bool $attrib = true): void
    {
        // Set up the style
        if ($renderer->getCurrentStyle() !== $this->styleName) {
            $renderer->setCurrentStyle($this->styleName);
Severity: Minor
Found in app/Report/ReportHtmlText.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 setVarStartHandler has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    protected function setVarStartHandler(array $attrs): void
    {
        if (empty($attrs['name'])) {
            throw new DomainException('REPORT ERROR var: The attribute "name" is missing or not set in the XML file');
        }
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 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function historicEventsAll(): Collection
    {
        switch (I18N::languageTag()) {
            case 'nl':
                return new Collection([
Severity: Major
Found in app/Module/LowCountriesRulers.php - About 2 hrs to fix

    Method handle has 56 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');
            $fact_id  = Validator::attributes($request)->string('fact_id');
    Severity: Major
    Found in app/Http/RequestHandlers/EditMediaFileAction.php - About 2 hrs to fix

      Method render has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function render($renderer): void
          {
              static $lastpicbottom, $lastpicpage, $lastpicleft, $lastpicright;
      
              // Check for a pagebreak first
      Severity: Major
      Found in app/Report/ReportPdfImage.php - About 2 hrs to fix

        Method usersLoggedInQuery has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function usersLoggedInQuery(string $type): string
            {
                $content   = '';
                $anonymous = 0;
                $logged_in = [];
        Severity: Major
        Found in app/Statistics/Repository/UserRepository.php - About 2 hrs to fix

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

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

            Method historicEventsAll has 55 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/USPresidents.php - About 2 hrs to fix

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

                  public function handle(ServerRequestInterface $request): ResponseInterface
                  {
                      $parent_id = $request->getAttribute('parent_id');
              
                      if ($parent_id === null) {
              Severity: Major
              Found in app/Http/RequestHandlers/MapDataExportGeoJson.php - About 2 hrs to fix

                File Registry.php has 258 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

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

                  Validator has 21 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class Validator
                  {
                      /** @var array<int|string|Tree|UserInterface|array<int|string>> */
                      private array $parameters;
                  
                  
                  Severity: Minor
                  Found in app/Validator.php - About 2 hrs to fix

                    ModuleService has 21 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class ModuleService
                    {
                        // Components are pieces of user-facing functionality, are managed together in the control panel.
                        private const COMPONENTS = [
                            ModuleAnalyticsInterface::class,
                    Severity: Minor
                    Found in app/Services/ModuleService.php - About 2 hrs to fix

                      Method getMapData has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function getMapData(ServerRequestInterface $request): array
                          {
                              $facts = $this->getPedigreeMapFacts($request, $this->chart_service);
                      
                              $geojson = [
                      Severity: Major
                      Found in app/Module/PedigreeMapModule.php - About 2 hrs to fix

                        Method leafletJsTileLayers has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

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

                          Method tags has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function tags(): array
                              {
                                  return [
                                      'FAM:*:_EVN'       => new CustomElement('Event number'),
                                      'FAM:CHIL:_FREL'   => new CustomElement(I18N::translate('Relationship to father')),
                          Severity: Major
                          Found in app/CustomTags/BrothersKeeper.php - About 2 hrs to fix

                            Method postDownloadAction has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function postDownloadAction(ServerRequestInterface $request): ResponseInterface
                                {
                                    $tree = Validator::attributes($request)->tree();
                            
                                    if (Auth::isAdmin()) {
                            Severity: Major
                            Found in app/Module/ClippingsCartModule.php - About 2 hrs to fix

                              Method handle has 53 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();
                                      $aliases    = Validator::queryParams($request)->boolean('aliases', false);
                              Severity: Major
                              Found in app/Http/RequestHandlers/UnconnectedPage.php - About 2 hrs to fix

                                Method searchIndividualsPhonetic has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function searchIndividualsPhonetic(string $soundex, string $lastname, string $firstname, string $place, array $search_trees): Collection
                                    {
                                        switch ($soundex) {
                                            default:
                                            case 'Russell':
                                Severity: Major
                                Found in app/Services/SearchService.php - About 2 hrs to fix

                                  Method columns has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function columns(): array
                                      {
                                          return [
                                              new CensusColumnFullName($this, 'Name', 'Name of head of family'),
                                              new CensusColumnNull($this, 'M0', 'Free white males 0-5 years'),
                                  Severity: Major
                                  Found in app/Census/CensusOfUnitedStates1830.php - About 2 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language