ernestwisniewski/kbin

View on GitHub

Showing 464 of 573 total issues

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

        if ($this->user) {
            $sql = "SELECT  date_trunc('day', e.created_at) as day, COUNT(case e.choice when 1 then 1 else null end) as up, 
                    COUNT(case e.choice when -1 then 1 else null end) as down FROM ".$table.' e
                    WHERE e.created_at >= :startDate AND e.user_id = :userId
                    '.$onlyLocalWhere.'
Severity: Major
Found in src/Repository/StatsVotesRepository.php and 1 other location - About 1 hr to fix
src/Repository/StatsVotesRepository.php on lines 77..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 114.

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 ($this->user) {
            $sql = "SELECT to_char(e.created_at,'Mon') as month, extract(year from e.created_at) as year,
                    COUNT(case e.choice when 1 then 1 else null end) as up, COUNT(case e.choice when -1 then 1 else null end) as down FROM ".$table.'
                    e WHERE e.user_id = :userId '.$onlyLocalWhere.' GROUP BY 1,2';
        } elseif ($this->magazine) {
Severity: Major
Found in src/Repository/StatsVotesRepository.php and 1 other location - About 1 hr to fix
src/Repository/StatsVotesRepository.php on lines 196..216

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

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

    async addMainSubject(data) {
        try {
            const url = router().generate(`ajax_fetch_${getTypeFromNotification(data)}`, {id: data.detail.id});

            let response = await fetch(url);
Severity: Minor
Found in assets/controllers/subject_list_controller.js - About 1 hr to fix

    Method jsonSerialize has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function jsonSerialize(): mixed
        {
            if (null === self::$keysToDelete) {
                self::$keysToDelete = [
                    'image',
    Severity: Minor
    Found in src/Kbin/PostComment/DTO/PostCommentResponseDto.php - About 1 hr to fix

      Function findByObjectId has a Cognitive Complexity of 13 (exceeds 5 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: Minor
      Found in src/Repository/ApActivityRepository.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 preparePageResults has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          public function preparePageResults(iterable $posts): ?iterable
          {
              $firstIndexes = [];
              $tmp = [];
              $duplicates = [];
      Severity: Minor
      Found in src/Kbin/Entry/EntryCrosspost.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 magazine has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function magazine(
              Magazine $magazine,
              ?string $sortBy,
              ?string $time,
              PostRepository $repository,
      Severity: Minor
      Found in src/Controller/Post/PostFrontController.php - About 1 hr to fix

        Method jsonSerialize has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function jsonSerialize(): mixed
            {
                if (null === self::$keysToDelete) {
                    self::$keysToDelete = [
                        'image',
        Severity: Minor
        Found in src/Kbin/EntryComment/DTO/EntryCommentResponseDto.php - About 1 hr to fix

          Method jsonSerialize has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function jsonSerialize(): mixed
              {
                  if (null === self::$keysToDelete) {
                      self::$keysToDelete = [
                          'image',
          Severity: Minor
          Found in src/Kbin/Post/DTO/PostResponseDto.php - About 1 hr to fix

            Similar blocks of code found in 3 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/Repository/UserBlockRepository.php and 2 other locations - About 1 hr to fix
            src/Repository/MagazineBlockRepository.php on lines 1..45
            src/Repository/UserFollowRepository.php on lines 1..45

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

            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

            <?php
            
            // SPDX-FileCopyrightText: 2023 /kbin contributors <https://kbin.pub/>
            //
            // SPDX-License-Identifier: AGPL-3.0-only
            Severity: Major
            Found in src/Repository/MagazineBlockRepository.php and 2 other locations - About 1 hr to fix
            src/Repository/UserBlockRepository.php on lines 1..45
            src/Repository/UserFollowRepository.php on lines 1..45

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

            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

            <?php
            
            // SPDX-FileCopyrightText: 2023 /kbin contributors <https://kbin.pub/>
            //
            // SPDX-License-Identifier: AGPL-3.0-only
            Severity: Major
            Found in src/Repository/UserFollowRepository.php and 2 other locations - About 1 hr to fix
            src/Repository/MagazineBlockRepository.php on lines 1..45
            src/Repository/UserBlockRepository.php on lines 1..45

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

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

                    string $username,
                    string $email = null,
                    ImageDto $avatar = null,
                    ImageDto $cover = null,
                    string $about = null,
            Severity: Major
            Found in src/Kbin/User/DTO/UserDto.php - About 1 hr to fix

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

              <?php
              
              declare(strict_types=1);
              
              namespace DoctrineMigrations;
              Severity: Major
              Found in migrations/Version20220306181222.php and 3 other locations - About 1 hr to fix
              migrations/Version20211231174542.php on lines 1..36
              migrations/Version20220218220935.php on lines 1..34
              migrations/Version20221015120344.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 110.

              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
              
              declare(strict_types=1);
              
              namespace DoctrineMigrations;
              Severity: Major
              Found in migrations/Version20231121084534.php and 1 other location - About 1 hr to fix
              migrations/Version20220723182602.php on lines 1..36

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

              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/Version20221015120344.php and 3 other locations - About 1 hr to fix
              migrations/Version20211231174542.php on lines 1..36
              migrations/Version20220218220935.php on lines 1..34
              migrations/Version20220306181222.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 110.

              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/Version20220218220935.php and 3 other locations - About 1 hr to fix
              migrations/Version20211231174542.php on lines 1..36
              migrations/Version20220306181222.php on lines 1..34
              migrations/Version20221015120344.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 110.

              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/Version20211231174542.php and 3 other locations - About 1 hr to fix
              migrations/Version20220218220935.php on lines 1..34
              migrations/Version20220306181222.php on lines 1..34
              migrations/Version20221015120344.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 110.

              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
              
              declare(strict_types=1);
              
              namespace DoctrineMigrations;
              Severity: Major
              Found in migrations/Version20220723182602.php and 1 other location - About 1 hr to fix
              migrations/Version20231121084534.php on lines 1..36

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

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

                  async getForm(event) {
                      event.preventDefault();
              
                      if ('' !== this.containerTarget.innerHTML.trim()) {
                          if (false === confirm('Do you really want to leave?')) {
              Severity: Minor
              Found in assets/controllers/subject_controller.js - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language