fisharebest/webtrees

View on GitHub

Showing 1,726 of 2,403 total issues

Function canShowRecord has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    private function canShowRecord(int $access_level): bool
    {
        // This setting would better be called "$ENABLE_PRIVACY"
        if (!$this->tree->getPreference('HIDE_LIVE_PEOPLE')) {
            return true;
Severity: Minor
Found in app/GedcomRecord.php - About 1 hr 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 starredName has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    private static function starredName(string $textSpan, string $direction): string
    {
        // To avoid a TCPDF bug that mixes up the word order, insert those <u> and </u> tags
        // only when page and span directions are identical.
        if ($direction === strtoupper(I18N::direction())) {
Severity: Minor
Found in app/Report/RightToLeftSupport.php - About 1 hr 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 alphabet has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function alphabet(): array
    {
        return [
            UTF8::CYRILLIC_CAPITAL_LETTER_A,
            UTF8::CYRILLIC_CAPITAL_LETTER_BE,
Severity: Minor
Found in app/Module/LanguageUkranian.php - About 1 hr to fix

    Method alphabet has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function alphabet(): array
        {
            return [
                UTF8::CYRILLIC_CAPITAL_LETTER_A,
                UTF8::CYRILLIC_CAPITAL_LETTER_BE,
    Severity: Minor
    Found in app/Module/LanguageKazhak.php - About 1 hr to fix

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

          public function getBlock(Tree $tree, int $block_id, string $context, array $config = []): string
          {
              $statistics = Registry::container()->get(Statistics::class);
              $num        = $this->getBlockSetting($block_id, 'num', self::DEFAULT_NUMBER);
              $infoStyle  = $this->getBlockSetting($block_id, 'infoStyle', self::DEFAULT_STYLE);
      Severity: Minor
      Found in app/Module/TopGivenNamesModule.php - About 1 hr to fix

        Method alphabet has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function alphabet(): array
            {
                return [
                    UTF8::CYRILLIC_CAPITAL_LETTER_A,
                    UTF8::CYRILLIC_CAPITAL_LETTER_BE,
        Severity: Minor
        Found in app/Module/LanguageTatar.php - About 1 hr to fix

          Method alphabet has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function alphabet(): array
              {
                  return [
                      'А',
                      'Б',
          Severity: Minor
          Found in app/Module/LanguageRussian.php - About 1 hr to fix

            Method handle has 35 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: Minor
            Found in app/Http/RequestHandlers/EditFactPage.php - About 1 hr to fix

              Method mediaObjectInfo has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function mediaObjectInfo(Media $media): string
                  {
                      $element = Registry::elementFactory()->make('NOTE:CONC');
                      $html    = '<a href="' . e($media->url()) . '" title="' . e($media->tree()->title()) . '">' . $media->fullName() . '</a>';
              
              
              Severity: Minor
              Found in app/Http/RequestHandlers/ManageMediaData.php - About 1 hr to fix

                Method handle has 35 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();
                
                
                Severity: Minor
                Found in app/Http/RequestHandlers/MediaFileThumbnail.php - About 1 hr to fix

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

                      public function columns(): array
                      {
                          return [
                              new CensusColumnFullName($this, 'Name', 'Name of each person in family, household or institution'),
                              new CensusColumnNull($this, 'Sec/Twp', 'Place of Abode (Section or Township)'),
                  Severity: Minor
                  Found in app/Census/CensusOfCanada1921.php - About 1 hr to fix

                    Method textScript has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static function textScript(string $string): string
                        {
                            $string = strip_tags($string); // otherwise HTML tags show up as latin
                            $string = html_entity_decode($string, ENT_QUOTES, 'UTF-8'); // otherwise HTML entities show up as latin
                            $string = str_replace([
                    Severity: Minor
                    Found in app/I18N.php - About 1 hr to fix

                      Method facts has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function facts(
                              array $filter = [],
                              bool $sort = false,
                              int|null $access_level = null,
                              bool $ignore_deleted = false
                      Severity: Minor
                      Found in app/GedcomRecord.php - About 1 hr to fix

                        Method addAncestors has 35 lines of code (exceeds 25 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 1 hr to fix

                          Method connect has 11 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                                  #[SensitiveParameter]
                                  string $driver,
                                  #[SensitiveParameter]
                                  string $host,
                                  #[SensitiveParameter]
                          Severity: Major
                          Found in app/DB.php - About 1 hr to fix

                            Method alphabet has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function alphabet(): array
                                {
                                    return [
                                        'A',
                                        'B',
                            Severity: Minor
                            Found in app/Module/LanguageEstonian.php - About 1 hr to fix

                              Method alphabet has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function alphabet(): array
                                  {
                                      return [
                                          'A',
                                          'B',
                              Severity: Minor
                              Found in app/Module/LanguagePolish.php - About 1 hr to fix

                                Method alphabet has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function alphabet(): array
                                    {
                                        return [
                                            UTF8::CYRILLIC_CAPITAL_LETTER_A,
                                            UTF8::CYRILLIC_CAPITAL_LETTER_BE,
                                Severity: Minor
                                Found in app/Module/LanguageBulgarian.php - About 1 hr to fix

                                  Method postAdminEditAction has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function postAdminEditAction(ServerRequestInterface $request): ResponseInterface
                                      {
                                          $block_id    = Validator::queryParams($request)->integer('block_id', 0);
                                          $body        = Validator::parsedBody($request)->string('body');
                                          $header      = Validator::parsedBody($request)->string('header');
                                  Severity: Minor
                                  Found in app/Module/FrequentlyAskedQuestionsModule.php - About 1 hr to fix

                                    Method alphabet has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        public function alphabet(): array
                                        {
                                            return [
                                                UTF8::ARABIC_LETTER_ALEF,
                                                UTF8::ARABIC_LETTER_BEH,
                                    Severity: Minor
                                    Found in app/Module/LanguageArabic.php - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language