fisharebest/webtrees

View on GitHub

Showing 1,726 of 2,403 total issues

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

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

        protected function ifStartHandler(array $attrs): void
        {
            if ($this->process_ifs > 0) {
                $this->process_ifs++;
    
    
    Severity: Major
    Found in app/Report/ReportParserGenerate.php - About 2 hrs to fix

      Function label has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function label(): string
          {
              if (str_ends_with($this->tag(), ':NOTE') && preg_match('/^@' . Gedcom::REGEX_XREF . '@$/', $this->value())) {
                  return I18N::translate('Shared note');
              }
      Severity: Minor
      Found in app/Fact.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 fromUtf8 has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function fromUtf8(string $text): string
          {
              $out = '';
              $len = strlen($text);
      
      
      Severity: Minor
      Found in app/Encodings/AbstractUTF16Encoding.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 detect has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function detect(string $header): EncodingInterface|null
          {
              $utf_bom = [
                  '/^' . UTF8::BYTE_ORDER_MARK . '/'    => UTF8::NAME,
                  '/^' . UTF16BE::BYTE_ORDER_MARK . '/' => UTF16BE::NAME,
      Severity: Minor
      Found in app/Factories/EncodingFactory.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 cleanFiles has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function cleanFiles(FilesystemOperator $filesystem, Collection $folders_to_clean, Collection $files_to_keep): void
          {
              foreach ($folders_to_clean as $folder_to_clean) {
                  try {
                      foreach ($filesystem->listContents($folder_to_clean, FilesystemReader::LIST_DEEP) as $path) {
      Severity: Minor
      Found in app/Services/UpgradeService.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 handle has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function handle(ServerRequestInterface $request): ResponseInterface
          {
              $parent_id = $request->getAttribute('parent_id');
      
              if ($parent_id === null) {
      Severity: Minor
      Found in app/Http/RequestHandlers/MapDataExportCSV.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 process has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
          {
              // Fatal errors.  We may be out of memory, so do not create any variables.
              register_shutdown_function(static function (): void {
                  if (error_get_last() !== null && error_get_last()['type'] & E_ERROR) {
      Severity: Minor
      Found in app/Http/Middleware/HandleExceptions.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 startElement has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function startElement($parser, string $name, array $attrs): void
          {
              $newattrs = [];
      
              foreach ($attrs as $key => $value) {
      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

      Function significantIndividual has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function significantIndividual(UserInterface $user, string $xref = ''): Individual
          {
              if ($xref === '') {
                  $individual = null;
              } else {
      Severity: Minor
      Found in app/Tree.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 handle has 52 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: Major
      Found in app/Module/BranchesListModule.php - About 2 hrs to fix

        Method all has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function all(): Collection
            {
                return Registry::cache()->array()->remember('all-trees', static function (): Collection {
                    // All trees
                    $query = DB::table('gedcom')
        Severity: Major
        Found in app/Services/TreeService.php - About 2 hrs to fix

          Method queryRecords has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function queryRecords(): Collection
              {
                  $male = DB::table('dates as married')
                      ->select([
                          new Expression('AVG(' . DB::prefix('married.d_julianday2') . ' - ' . DB::prefix('birth.d_julianday1') . ' - 182.5) / 365.25 AS age'),
          Severity: Major
          Found in app/Statistics/Google/ChartMarriageAge.php - About 2 hrs to fix

            Method gedcomStartHandler has 52 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function gedcomStartHandler(array $attrs): void
                {
                    if ($this->process_gedcoms > 0) {
                        $this->process_gedcoms++;
            
            
            Severity: Major
            Found in app/Report/ReportParserGenerate.php - About 2 hrs to fix

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

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

                Method isRelated has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private static function isRelated(Individual $target, int $distance): bool
                    {
                        static $cache = null;
                
                        $user_individual = Registry::individualFactory()->make($target->tree->getUserPreference(Auth::user(), UserInterface::PREF_TREE_ACCOUNT_XREF), $target->tree);
                Severity: Major
                Found in app/Individual.php - About 2 hrs to fix

                  Method upgrade has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function upgrade(): void
                      {
                          // These tables were created by webtrees 1.x, and may not exist if we first installed webtrees 2.x
                          DB::schema()->dropIfExists('site_access_rule');
                          DB::schema()->dropIfExists('next_id');
                  Severity: Major
                  Found in app/Schema/Migration37.php - About 2 hrs to fix

                    Method updateFact has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function updateFact(string $fact_id, string $gedcom, bool $update_chan): void
                        {
                            // Not all record types allow a CHAN event.
                            $update_chan = $update_chan && in_array(static::RECORD_TYPE, Gedcom::RECORDS_WITH_CHAN, true);
                    
                    
                    Severity: Major
                    Found in app/GedcomRecord.php - About 2 hrs to fix

                      Method handle has 50 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/Module/MediaListModule.php - About 2 hrs to fix

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

                            public function leafletJsTileLayers(): array
                            {
                                $api_key = $this->getPreference('api_key');
                        
                                if ($api_key === '') {
                        Severity: Minor
                        Found in app/Module/BingMaps.php - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language