ernestwisniewski/kbin

View on GitHub

Showing 464 of 573 total issues

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

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

    File StatsContentRepository.php has 253 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/Repository/StatsContentRepository.php - About 2 hrs to fix

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

          public function findForDeletionPaginated(int $page): PagerfantaInterface
          {
              $query = $this->createQueryBuilder('u')
                  ->where('u.apId IS NULL')
                  ->andWhere('u.visibility = :visibility')
      Severity: Major
      Found in src/Repository/UserRepository.php and 1 other location - About 2 hrs to fix
      src/Repository/MagazineRepository.php on lines 496..519

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

      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 findForDeletionPaginated(int $page): PagerfantaInterface
          {
              $query = $this->createQueryBuilder('m')
                  ->where('m.apId IS NULL')
                  ->andWhere('m.visibility = :visibility')
      Severity: Major
      Found in src/Repository/MagazineRepository.php and 1 other location - About 2 hrs to fix
      src/Repository/UserRepository.php on lines 269..292

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

      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 __invoke has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          #[OA\Response(
              response: 201,
              description: 'Returns the created oauth2 client. Be sure to save the identifier and secret since these will be how you obtain tokens for the API.',
              content: new Model(type: OAuth2ClientDto::class, groups: ['created', 'common']),
              headers: [
      Severity: Major
      Found in src/Controller/Api/OAuth2/CreateClientApi.php - About 2 hrs to fix

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

            public function findActorOrCreate(string $actorUrlOrHandle): null|User|Magazine
            {
                if (str_contains($actorUrlOrHandle, $this->settingsManager->get('KBIN_DOMAIN').'/m/')) {
                    $magazine = str_replace('https://'.$this->settingsManager->get('KBIN_DOMAIN').'/m/', '', $actorUrlOrHandle);
        
        
        Severity: Minor
        Found in src/Service/ActivityPubManager.php - About 1 hr to fix

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

              public function findByApId($url): array
              {
                  // @todo union adapter
                  $conn = $this->entityManager->getConnection();
                  $sql = "
          Severity: Minor
          Found in src/Repository/SearchRepository.php - About 1 hr to fix

            Method aggregateTotalStats has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function aggregateTotalStats(?Magazine $magazine): array
                {
                    $conn = $this->getEntityManager()->getConnection();
            
                    $results = [];
            Severity: Minor
            Found in src/Repository/StatsVotesRepository.php - About 1 hr to fix

              Function sendForm has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  async sendForm(event) {
                      event.preventDefault();
              
                      const form = event.target.closest('form');
                      const url = form.action;
              Severity: Minor
              Found in assets/controllers/subject_controller.js - About 1 hr to fix

                Function findPeople has a Cognitive Complexity of 15 (exceeds 5 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: Minor
                Found in src/Repository/UserRepository.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

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

                <?php
                
                declare(strict_types=1);
                
                namespace DoctrineMigrations;
                Severity: Major
                Found in migrations/Version20231119205627.php and 3 other locations - About 1 hr to fix
                migrations/Version20231103070928.php on lines 1..35
                migrations/Version20231111124634.php on lines 1..37
                migrations/Version20231119115804.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 119.

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

                <?php
                
                declare(strict_types=1);
                
                namespace DoctrineMigrations;
                Severity: Major
                Found in migrations/Version20231103070928.php and 3 other locations - About 1 hr to fix
                migrations/Version20231111124634.php on lines 1..37
                migrations/Version20231119115804.php on lines 1..37
                migrations/Version20231119205627.php on lines 1..35

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

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

                <?php
                
                declare(strict_types=1);
                
                namespace DoctrineMigrations;
                Severity: Major
                Found in migrations/Version20231111124634.php and 3 other locations - About 1 hr to fix
                migrations/Version20231103070928.php on lines 1..35
                migrations/Version20231119115804.php on lines 1..37
                migrations/Version20231119205627.php on lines 1..35

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

                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 up(Schema $schema): void
                    {
                        // this up() migration is auto-generated, please modify it to your needs
                        $this->addSql('CREATE SEQUENCE award_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
                        $this->addSql('CREATE SEQUENCE award_type_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
                Severity: Major
                Found in migrations/Version20220320191810.php and 1 other location - About 1 hr to fix
                migrations/Version20211205133802.php on lines 20..34

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

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

                <?php
                
                declare(strict_types=1);
                
                namespace DoctrineMigrations;
                Severity: Major
                Found in migrations/Version20231119115804.php and 3 other locations - About 1 hr to fix
                migrations/Version20231103070928.php on lines 1..35
                migrations/Version20231111124634.php on lines 1..37
                migrations/Version20231119205627.php on lines 1..35

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

                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 up(Schema $schema): void
                    {
                        $this->addSql('ALTER TABLE notification DROP CONSTRAINT FK_BF5476CABA364942');
                        $this->addSql('ALTER TABLE notification DROP CONSTRAINT FK_BF5476CA60C33421');
                        $this->addSql('ALTER TABLE notification DROP CONSTRAINT FK_BF5476CA4B89032C');
                Severity: Major
                Found in migrations/Version20211205133802.php and 1 other location - About 1 hr to fix
                migrations/Version20220320191810.php on lines 20..35

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

                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

                        if ('Person' === $actor['type']) {
                            // User
                            $user = $this->userRepository->findOneBy(['apProfileId' => $actorUrl]);
                            if (!$user) {
                                $user = $this->createUser($actorUrl);
                Severity: Major
                Found in src/Service/ActivityPubManager.php and 1 other location - About 1 hr to fix
                src/Service/ActivityPubManager.php on lines 153..168

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

                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

                        if ('Group' === $actor['type']) {
                            // User
                            $magazine = $this->magazineRepository->findOneBy(['apProfileId' => $actorUrl]);
                            if (!$magazine) {
                                $magazine = $this->createMagazine($actorUrl);
                Severity: Major
                Found in src/Service/ActivityPubManager.php and 1 other location - About 1 hr to fix
                src/Service/ActivityPubManager.php on lines 135..150

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

                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 __invoke has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    #[OA\Response(
                        response: 200,
                        description: 'Returns a paginated list of content, along with any ActivityPub actors that matched the query by username, or ActivityPub objects that matched the query by URL. Actors and objects are not paginated',
                        content: new OA\JsonContent(
                            type: 'object',
                Severity: Minor
                Found in src/Controller/Api/Search/SearchRetrieveApi.php - About 1 hr to fix

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

                      #[OA\Response(
                          response: 201,
                          description: 'Returns the created oauth2 client. Be sure to save the identifier and secret since these will be how you obtain tokens for the API.',
                          content: new Model(type: OAuth2ClientDto::class, groups: ['Default', 'created', 'common']),
                          headers: [
                  Severity: Minor
                  Found in src/Controller/Api/OAuth2/CreateClientApi.php - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language