ernestwisniewski/kbin

View on GitHub
src/Repository/MagazineRepository.php

Summary

Maintainability
C
1 day
Test Coverage
F
50%

File MagazineRepository.php has 450 lines of code (exceeds 250 allowed). Consider refactoring.
Invalid

<?php

// SPDX-FileCopyrightText: 2023 /kbin contributors <https://kbin.pub/>
//
// SPDX-License-Identifier: AGPL-3.0-only
Severity: Minor
Found in src/Repository/MagazineRepository.php - About 6 hrs to fix

    MagazineRepository has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class MagazineRepository extends ServiceEntityRepository
    {
        public const PER_PAGE = 48;
    
        public const SORT_HOT = 'hot';
    Severity: Minor
    Found in src/Repository/MagazineRepository.php - About 2 hrs to fix

      Method findTrashed has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Wontfix

          public function findTrashed(Magazine $magazine, int $page = 1, int $perPage = self::PER_PAGE): PagerfantaInterface
          {
              // @todo union adapter
              $conn = $this->_em->getConnection();
      
      
      Severity: Major
      Found in src/Repository/MagazineRepository.php - About 2 hrs to fix

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

            public function findPaginated(MagazinePageView $criteria): PagerfantaInterface
            {
                $qb = $this->createQueryBuilder('m')
                    ->andWhere('m.visibility = :visibility')
                    ->setParameter('visibility', VisibilityInterface::VISIBILITY_VISIBLE);
        Severity: Minor
        Found in src/Repository/MagazineRepository.php - About 1 hr to fix

          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

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

              public function findModlog(Magazine $magazine, ?int $page = 1, int $perPage = self::PER_PAGE): PagerfantaInterface
              {
                  $criteria = Criteria::create()->orderBy(['createdAt' => 'DESC']);
          
                  $logs = new Pagerfanta(new SelectableAdapter($magazine->logs, $criteria));
          Severity: Major
          Found in src/Repository/MagazineRepository.php and 1 other location - About 1 hr to fix
          src/Repository/MagazineRepository.php on lines 167..183

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

          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 findModerators(
                  Magazine $magazine,
                  ?int $page = 1,
                  int $perPage = self::PER_PAGE
              ): PagerfantaInterface {
          Severity: Major
          Found in src/Repository/MagazineRepository.php and 1 other location - About 1 hr to fix
          src/Repository/MagazineRepository.php on lines 185..199

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

          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 findAudience(Magazine $magazine): array
              {
                  $dql =
                      'SELECT COUNT(u.id), u.apInboxUrl FROM '.User::class.' u WHERE u IN ('.
                      'SELECT IDENTITY(ms.user) FROM '.MagazineSubscription::class.' ms WHERE ms.magazine = :magazine)'.
          Severity: Major
          Found in src/Repository/MagazineRepository.php and 1 other location - About 1 hr to fix
          src/Repository/UserRepository.php on lines 208..221

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

          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

          There are no issues that match your filters.

          Category
          Status