ernestwisniewski/kbin

View on GitHub

Showing 464 of 573 total issues

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

<?php

// SPDX-FileCopyrightText: 2023 /kbin contributors <https://kbin.pub/>
//
// SPDX-License-Identifier: AGPL-3.0-only
Severity: Major
Found in src/Entity/EntryCommentCreatedNotification.php and 7 other locations - About 2 hrs to fix
src/Entity/EntryCommentDeletedNotification.php on lines 1..43
src/Entity/EntryCommentEditedNotification.php on lines 1..43
src/Entity/EntryCommentReplyNotification.php on lines 1..43
src/Entity/PostCommentCreatedNotification.php on lines 1..43
src/Entity/PostCommentDeletedNotification.php on lines 1..43
src/Entity/PostCommentEditedNotification.php on lines 1..43
src/Entity/PostCommentReplyNotification.php on lines 1..43

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 130.

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

    #[OA\Response(
        response: 200,
        description: 'Views by interval retrieved. These are not guaranteed to be continuous.',
        content: new OA\JsonContent(
            properties: [
src/Controller/Api/Instance/InstanceRetrieveStatsApi.php on lines 25..54
src/Controller/Api/OAuth2/Admin/RetrieveClientStatsApi.php on lines 25..54

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 130.

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 aggregateTotalStats has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    private function aggregateTotalStats(?Magazine $magazine): array
    {
        $conn = $this->getEntityManager()->getConnection();

        $results = [];
Severity: Minor
Found in src/Repository/StatsVotesRepository.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 __invoke has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public function __invoke(PagerfantaInterface $activity, $sortBy = 'hot'): array
    {
        $postsAndEntries = array_filter(
            $activity->getCurrentPageResults(),
            fn ($val) => $val instanceof Entry || $val instanceof Post
Severity: Minor
Found in src/Kbin/SubjectOverviewListCreate.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

File PostCommentsCreateApi.php has 267 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

// SPDX-FileCopyrightText: 2023 /kbin contributors <https://kbin.pub/>
//
// SPDX-License-Identifier: AGPL-3.0-only
Severity: Minor
Found in src/Controller/Api/Post/Comments/PostCommentsCreateApi.php - About 2 hrs to fix

    Method __invoke has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function __invoke(PagerfantaInterface $activity, $sortBy = 'hot'): array
        {
            $postsAndEntries = array_filter(
                $activity->getCurrentPageResults(),
                fn ($val) => $val instanceof Entry || $val instanceof Post
    Severity: Major
    Found in src/Kbin/SubjectOverviewListCreate.php - About 2 hrs to fix

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

      <?php
      
      declare(strict_types=1);
      
      namespace DoctrineMigrations;
      Severity: Major
      Found in migrations/Version20231110022525.php and 8 other locations - About 2 hrs to fix
      migrations/Version20220705184724.php on lines 1..36
      migrations/Version20220717101149.php on lines 1..38
      migrations/Version20220808150935.php on lines 1..38
      migrations/Version20221121125723.php on lines 1..38
      migrations/Version20221202114605.php on lines 1..38
      migrations/Version20221202140020.php on lines 1..36
      migrations/Version20230323160934.php on lines 1..38
      migrations/Version20230428130129.php on lines 1..38

      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 9 locations. Consider refactoring.
      Open

      <?php
      
      declare(strict_types=1);
      
      namespace DoctrineMigrations;
      Severity: Major
      Found in migrations/Version20230428130129.php and 8 other locations - About 2 hrs to fix
      migrations/Version20220705184724.php on lines 1..36
      migrations/Version20220717101149.php on lines 1..38
      migrations/Version20220808150935.php on lines 1..38
      migrations/Version20221121125723.php on lines 1..38
      migrations/Version20221202114605.php on lines 1..38
      migrations/Version20221202140020.php on lines 1..36
      migrations/Version20230323160934.php on lines 1..38
      migrations/Version20231110022525.php on lines 1..37

      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 9 locations. Consider refactoring.
      Open

      <?php
      
      declare(strict_types=1);
      
      namespace DoctrineMigrations;
      Severity: Major
      Found in migrations/Version20230323160934.php and 8 other locations - About 2 hrs to fix
      migrations/Version20220705184724.php on lines 1..36
      migrations/Version20220717101149.php on lines 1..38
      migrations/Version20220808150935.php on lines 1..38
      migrations/Version20221121125723.php on lines 1..38
      migrations/Version20221202114605.php on lines 1..38
      migrations/Version20221202140020.php on lines 1..36
      migrations/Version20230428130129.php on lines 1..38
      migrations/Version20231110022525.php on lines 1..37

      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

      Method serializeNotification has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function serializeNotification(Notification $dto)
          {
              $toReturn = [
                  'notificationId' => $dto->getId(),
                  'status' => $dto->status,
      Severity: Major
      Found in src/Controller/Api/Notification/NotificationBaseApi.php - About 2 hrs to fix

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

            public function findByObjectId(string $apId): ?array
            {
                $parsed = parse_url($apId);
                if ($parsed['host'] === $this->settingsManager->get('KBIN_DOMAIN')) {
                    $exploded = array_filter(explode('/', $parsed['path']));
        Severity: Major
        Found in src/Repository/ApActivityRepository.php - About 2 hrs to fix

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

          <?php
          
          // SPDX-FileCopyrightText: 2023 /kbin contributors <https://kbin.pub/>
          //
          // SPDX-License-Identifier: AGPL-3.0-only
          Severity: Major
          Found in src/Twig/Components/BoostComponent.php and 1 other location - About 2 hrs to fix
          src/Twig/Components/FavouriteComponent.php on lines 1..38

          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 126.

          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

          <?php
          
          // SPDX-FileCopyrightText: 2023 /kbin contributors <https://kbin.pub/>
          //
          // SPDX-License-Identifier: AGPL-3.0-only
          Severity: Major
          Found in src/Twig/Components/FavouriteComponent.php and 1 other location - About 2 hrs to fix
          src/Twig/Components/BoostComponent.php on lines 1..38

          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 126.

          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

          File PostCommentsRetrieveApi.php has 257 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          // SPDX-FileCopyrightText: 2023 /kbin contributors <https://kbin.pub/>
          //
          // SPDX-License-Identifier: AGPL-3.0-only
          Severity: Minor
          Found in src/Controller/Api/Post/Comments/PostCommentsRetrieveApi.php - About 2 hrs to fix

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

                public function findPeople(Magazine $magazine, ?bool $federated = false, $limit = 200): array
                {
                    $conn = $this->_em->getConnection();
                    $sql = '
                    (SELECT count(id), user_id FROM entry WHERE magazine_id = :magazineId GROUP BY user_id ORDER BY count DESC LIMIT 50)
            Severity: Major
            Found in src/Repository/UserRepository.php - About 2 hrs to fix

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

              <?php
              
              // SPDX-FileCopyrightText: 2023 /kbin contributors <https://kbin.pub/>
              //
              // SPDX-License-Identifier: AGPL-3.0-only
              src/Controller/Entry/Comment/EntryCommentFavouriteController.php on lines 1..37

              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 124.

              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

              <?php
              
              // SPDX-FileCopyrightText: 2023 /kbin contributors <https://kbin.pub/>
              //
              // SPDX-License-Identifier: AGPL-3.0-only
              src/Controller/Post/Comment/PostCommentFavouriteController.php on lines 1..37

              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 124.

              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 __construct has 17 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      private Server $server,
                      private UserRepository $userRepository,
                      private UserCreate $userCreate,
                      private UserFactory $userFactory,
                      private MagazineCreate $magazineCreate,
              Severity: Major
              Found in src/Service/ActivityPubManager.php - About 2 hrs to fix

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

                    public function __invoke(
                        #[MapEntity(mapping: ['magazine_name' => 'name'])]
                        Magazine $magazine,
                        #[MapEntity(id: 'entry_id')]
                        Entry $entry,
                Severity: Major
                Found in src/Controller/Entry/EntrySingleController.php - About 2 hrs to fix

                  File NotificationReadApi.php has 255 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  
                  // SPDX-FileCopyrightText: 2023 /kbin contributors <https://kbin.pub/>
                  //
                  // SPDX-License-Identifier: AGPL-3.0-only
                  Severity: Minor
                  Found in src/Controller/Api/Notification/NotificationReadApi.php - About 2 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language