jon48/webtrees-lib

View on GitHub

Showing 758 of 758 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        try {
            $this->geoview_data_service->update($new_view);
            FlashMessages::addMessage(
                I18N::translate('The geographical dispersion analysis view has been successfully updated.'),
                'success'
app/Module/GeoDispersion/Http/RequestHandlers/MapAdapterEditAction.php on lines 97..112

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 136.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        try {
            $this->mapadapter_data_service->update($new_map_adapter);
            FlashMessages::addMessage(
                I18N::translate('The map configuration has been successfully updated.'),
                'success'
app/Module/GeoDispersion/Http/RequestHandlers/GeoAnalysisViewEditAction.php on lines 98..113

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 136.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function buildLineages has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function buildLineages(): ?Collection
    {
        $indis = $this->patrolineage_module->individuals(
            $this->tree,
            $this->surname,
Severity: Minor
Found in app/Module/PatronymicLineage/Model/LineageBuilder.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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    public function loadRoutes(Map $router): void
    {
        $router->attach('', '', static function (Map $router): void {

            $router->attach('', '/module-maj/lineages', static function (Map $router): void {
Severity: Major
Found in app/Module/PatronymicLineage/PatronymicLineageModule.php and 1 other location - About 2 hrs to fix
app/Module/MiscExtensions/MiscExtensionsModule.php on lines 83..96

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 131.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    public function loadRoutes(Map $router): void
    {
        $router->attach('', '', static function (Map $router): void {

            $router->attach('', '/module-maj/misc', static function (Map $router): void {
Severity: Major
Found in app/Module/MiscExtensions/MiscExtensionsModule.php and 1 other location - About 2 hrs to fix
app/Module/PatronymicLineage/PatronymicLineageModule.php on lines 70..83

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 131.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    public function handle(ServerRequestInterface $request): ResponseInterface
    {
        if ($this->module === null) {
            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
        }
Severity: Major
Found in app/Module/AdminTasks/Http/RequestHandlers/TasksList.php - About 2 hrs to fix

    Method buildLineage has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function buildLineage(LineageNode $node): LineageNode
        {
            $indi_surname = '';
    
            $indi_node = $node->individual();
    Severity: Major
    Found in app/Module/PatronymicLineage/Model/LineageBuilder.php - About 2 hrs to fix

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

              if ($this->mapadapter_data_service->delete($map_adapter) > 0) {
                  FlashMessages::addMessage(
                      I18N::translate('The map configuration has been successfully deleted.'),
                      'success'
                  );
      app/Module/AdminTasks/Http/RequestHandlers/TaskStatusAction.php on lines 78..92
      app/Module/GeoDispersion/Http/RequestHandlers/GeoAnalysisViewDeleteAction.php on lines 76..90

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 128.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

              if ($this->taskschedules_service->update($task_schedule) > 0) {
                  FlashMessages::addMessage(
                      I18N::translate('The scheduled task has been successfully updated.'),
                      'success'
                  );
      app/Module/GeoDispersion/Http/RequestHandlers/GeoAnalysisViewDeleteAction.php on lines 76..90
      app/Module/GeoDispersion/Http/RequestHandlers/MapAdapterDeleteAction.php on lines 76..90

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 128.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

              if ($this->geoview_data_service->delete($view) > 0) {
                  FlashMessages::addMessage(
                      I18N::translate('The geographical dispersion analysis view has been successfully deleted.'),
                      'success'
                  );
      app/Module/AdminTasks/Http/RequestHandlers/TaskStatusAction.php on lines 78..92
      app/Module/GeoDispersion/Http/RequestHandlers/MapAdapterDeleteAction.php on lines 76..90

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 128.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

          private function getLineageRootIndividual(Individual $indi): ?Individual
          {
              $child_families = $indi->childFamilies();
              if ($this->used_indis->get($indi->xref(), false) !== false) {
                  return null;
      Severity: Minor
      Found in app/Module/PatronymicLineage/Model/LineageBuilder.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 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function handle(ServerRequestInterface $request): ResponseInterface
          {
              $tree = Validator::attributes($request)->tree();
      
              if ($this->module === null) {
      Severity: Minor
      Found in app/Module/GeoDispersion/Http/RequestHandlers/MapAdapterAddAction.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();
        
                if ($this->module === null) {

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  $list_ancestors = $list_ancestors
                      ->filter(function (stdClass $value) use ($tree): bool {
                          $indi = Registry::individualFactory()->make($value->majs_i_id, $tree);
                          return $indi !== null && $indi->canShowName();
                      })
          app/Module/Sosa/Http/RequestHandlers/AncestorsListFamily.php on lines 91..99

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 121.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  $list_families = $list_families
                      ->filter(function (stdClass $value) use ($tree): bool {
                          $fam = Registry::familyFactory()->make($value->f_id, $tree);
                          return $fam !== null && $fam->canShow();
                      })
          Severity: Major
          Found in app/Module/Sosa/Http/RequestHandlers/AncestorsListFamily.php and 1 other location - About 2 hrs to fix
          app/Module/Sosa/Http/RequestHandlers/AncestorsListIndividual.php on lines 91..99

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 121.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Method insertOrUpdate has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function insertOrUpdate(Tree $tree, UserInterface $user, array $sosa_records): void
              {
                  $mass_update = DB::connection()->getDriverName() === 'mysql';
          
                  $bindings_placeholders = $bindings_values = [];
          Severity: Minor
          Found in app/Module/Sosa/Services/SosaRecordsService.php - About 1 hr to fix

            Function run has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                public function run(TaskSchedule $task_schedule, $force = false): void
                {
                    /** @var TaskSchedule $task_schedule */
                    $task_schedule = DB::table('maj_admintasks')
                        ->select()
            Severity: Minor
            Found in app/Module/AdminTasks/Services/TaskScheduleService.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 label has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                public function label(string $context): string
                {
                    $context_label = Registry::elementFactory()->make($context)->label();
            
                    if ($this->factHasPreciseDate()) {
            Severity: Minor
            Found in app/Module/IsSourced/Data/FactSourceStatus.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 featuresIndex has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function featuresIndex(): ?array
                {
                    $cacheKey = $this->cacheKey();
                    if ($cacheKey === null) {
                        return null;
            Severity: Minor
            Found in app/Module/GeoDispersion/PlaceMappers/CoordinatesPlaceMapper.php - About 1 hr to fix

              Method getMenu has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getMenu(Tree $tree): ?Menu
                  {
                      $menu = new Menu(I18N::translate('Sosa Statistics'));
                      $menu->setClass('menu-maj-sosa');
                      $menu->setSubmenus([
              Severity: Minor
              Found in app/Module/Sosa/SosaModule.php - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language