ernestwisniewski/kbin

View on GitHub

Showing 464 of 573 total issues

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

    protected function serializePostCommentTree(?PostComment $comment, int $depth = null): array
    {
        if (null === $comment) {
            return [];
        }
Severity: Major
Found in src/Controller/Api/Post/PostsBaseApi.php and 1 other location - About 1 hr to fix
src/Controller/Api/Entry/EntriesBaseApi.php on lines 183..196

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

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

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

    public static function create(string $identifier, string $secret, string $name, UserSmallResponseDto $user = null, string $contactEmail = null, string $description = null, array $redirectUris = [], array $grants = [], array $scopes = ['read'], ImageDto $image = null): OAuth2ClientDto
    {
        $dto = new OAuth2ClientDto();
        $dto->identifier = $identifier;
        $dto->secret = $secret;
Severity: Major
Found in src/DTO/OAuth2ClientDto.php and 1 other location - About 1 hr to fix
src/Kbin/Report/DTO/ReportResponseDto.php on lines 42..67

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

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

    protected function serializeCommentTree(?EntryComment $comment, int $depth = null): array
    {
        if (null === $comment) {
            return [];
        }
Severity: Major
Found in src/Controller/Api/Entry/EntriesBaseApi.php and 1 other location - About 1 hr to fix
src/Controller/Api/Post/PostsBaseApi.php on lines 158..171

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

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

    public static function create(
        int $id = null,
        MagazineSmallResponseDto $magazine = null,
        UserSmallResponseDto $reported = null,
        UserSmallResponseDto $reporting = null,
Severity: Major
Found in src/Kbin/Report/DTO/ReportResponseDto.php and 1 other location - About 1 hr to fix
src/DTO/OAuth2ClientDto.php on lines 228..243

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

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

    public function findAudience(User $user): array
    {
        $dql =
            'SELECT COUNT(u.id), u.apInboxUrl FROM '.User::class.' u WHERE u IN ('.
            'SELECT IDENTITY(us.follower) FROM '.UserFollow::class.' us WHERE us.following = :user)'.
Severity: Major
Found in src/Repository/UserRepository.php and 1 other location - About 1 hr to fix
src/Repository/MagazineRepository.php on lines 360..373

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

Method getMonthlyStats has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function getMonthlyStats(string $table, string $relation = null): array
    {
        $conn = $this->getEntityManager()
            ->getConnection();

Severity: Minor
Found in src/Repository/StatsVotesRepository.php - About 1 hr to fix

    Method getMonthlyStats has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function getMonthlyStats(): array
        {
            $conn = $this->getEntityManager()
                ->getConnection();
    
    
    Severity: Minor
    Found in src/Repository/StatsViewsRepository.php - About 1 hr 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/Kbin/Post/DTO/PostRequestDto.php and 1 other location - About 1 hr to fix
      src/Kbin/EntryComment/DTO/EntryCommentRequestDto.php on lines 1..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 104.

      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/Kbin/EntryComment/DTO/EntryCommentRequestDto.php and 1 other location - About 1 hr to fix
      src/Kbin/Post/DTO/PostRequestDto.php on lines 1..26

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

      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 findBannedPaginated(
              int $page,
              string $group = self::USERS_ALL,
              int $perPage = self::PER_PAGE
          ): PagerfantaInterface {
      Severity: Major
      Found in src/Repository/UserRepository.php and 1 other location - About 1 hr to fix
      src/Repository/UserRepository.php on lines 376..397

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

      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 findWithAboutPaginated(
              int $page,
              string $group = self::USERS_ALL,
              int $perPage = self::PER_PAGE
          ): PagerfantaInterface {
      Severity: Major
      Found in src/Repository/UserRepository.php and 1 other location - About 1 hr to fix
      src/Repository/UserRepository.php on lines 422..443

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

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

          public function blurhash(string $filePath): ?string
          {
              try {
                  $image = imagecreatefromstring(file_get_contents($filePath));
                  $width = imagesx($image);
      Severity: Minor
      Found in src/Repository/ImageRepository.php - About 1 hr to fix

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

            public function createWithParent(
                Entry $entry,
                ?EntryComment $parent,
                Image $image = null,
                string $body = null
        Severity: Major
        Found in src/Kbin/EntryComment/DTO/EntryCommentDto.php and 1 other location - About 1 hr to fix
        src/Kbin/PostComment/DTO/PostCommentDto.php on lines 85..97

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

        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 createWithParent(Post $post, ?PostComment $parent, ImageDto $image = null, string $body = null): self
            {
                $this->post = $post;
                $this->parent = $parent;
                $this->body = $body;
        Severity: Major
        Found in src/Kbin/PostComment/DTO/PostCommentDto.php and 1 other location - About 1 hr to fix
        src/Kbin/EntryComment/DTO/EntryCommentDto.php on lines 85..101

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

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

                string $title,
                ?string $url,
                ?string $body,
                Magazine $magazine,
                User $user,
        Severity: Major
        Found in src/Entity/Entry.php - About 1 hr to fix

          Method findBoosts has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function findBoosts(int $page, User $user): PagerfantaInterface
              {
                  // @todo union adapter
                  $conn = $this->entityManager->getConnection();
                  $sql = "
          Severity: Minor
          Found in src/Repository/SearchRepository.php - About 1 hr to fix

            Method front has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function front(?string $sortBy, ?string $time, PostRepository $repository, Request $request): Response
                {
                    $user = $this->getUser();
            
                    $criteria = new PostPageView($this->getPageNb($request));
            Severity: Minor
            Found in src/Controller/Post/PostFrontController.php - About 1 hr to fix

              Function addCommentOverview has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  async addCommentOverview(data) {
                      try {
                          const parent = document.getElementById(data.detail.parentSubject.htmlId);
                          if (!parent) {
                              return;
              Severity: Minor
              Found in assets/controllers/subject_list_controller.js - About 1 hr to fix

                Method search has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function search($query, int $page = 1): PagerfantaInterface
                    {
                        // @todo union adapter
                        $conn = $this->entityManager->getConnection();
                        $sql = "
                Severity: Minor
                Found in src/Repository/SearchRepository.php - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language