ernestwisniewski/kbin

View on GitHub

Showing 226 of 573 total issues

File subject_controller.js has 363 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// SPDX-FileCopyrightText: 2023 /kbin contributors <https://kbin.pub/>
//
// SPDX-License-Identifier: AGPL-3.0-only

import {Controller} from '@hotwired/stimulus';
Severity: Minor
Found in assets/controllers/subject_controller.js - About 4 hrs to fix

    Function findActorOrCreate has a Cognitive Complexity of 29 (exceeds 5 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 4 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

    UserRepository has 31 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class UserRepository extends ServiceEntityRepository implements UserLoaderInterface, PasswordUpgraderInterface
    {
        public const PER_PAGE = 48;
        public const USERS_ALL = 'all';
        public const USERS_LOCAL = 'local';
    Severity: Minor
    Found in src/Repository/UserRepository.php - About 3 hrs to fix

      File CreateClientApi.php has 304 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/OAuth2/CreateClientApi.php - About 3 hrs to fix

        Function aggregateStats has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            private function aggregateStats(?Magazine $magazine, string $interval, ?\DateTime $end): array
            {
                if (null === $end) {
                    $end = new \DateTime();
                }
        Severity: Minor
        Found in src/Repository/StatsVotesRepository.php - About 3 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

        Method create has 25 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                int $id = null,
                MagazineSmallResponseDto $magazine = null,
                UserSmallResponseDto $user = null,
                DomainDto $domain = null,
                string $title = null,
        Severity: Major
        Found in src/Kbin/Entry/DTO/EntryResponseDto.php - About 3 hrs to fix

          Function addMainSubject has a Cognitive Complexity of 21 (exceeds 5 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 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

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

                private function aggregateStats(?Magazine $magazine, string $interval, ?\DateTime $end): array
                {
                    if (null === $end) {
                        $end = new \DateTime();
                    }
            Severity: Major
            Found in src/Repository/StatsVotesRepository.php - About 2 hrs to fix

              Method create has 21 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      int $id = null,
                      UserSmallResponseDto $user = null,
                      MagazineSmallResponseDto $magazine = null,
                      int $entryId = null,
                      int $parentId = null,
              Severity: Major
              Found in src/Kbin/EntryComment/DTO/EntryCommentResponseDto.php - About 2 hrs to fix

                File EntryCommentsCreateApi.php has 271 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/Entry/Comments/EntryCommentsCreateApi.php - About 2 hrs to fix

                  Method __construct has 20 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          public string $KBIN_DOMAIN,
                          public string $KBIN_TITLE,
                          public string $KBIN_META_TITLE,
                          public string $KBIN_META_KEYWORDS,
                          public string $KBIN_META_DESCRIPTION,
                  Severity: Major
                  Found in src/DTO/SettingsDto.php - About 2 hrs to fix

                    Method create has 20 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            MagazineModeratorResponseDto $owner = null,
                            ImageDto $icon = null,
                            string $name = null,
                            string $title = null,
                            string $description = null,
                    Severity: Major
                    Found in src/Kbin/Magazine/DTO/MagazineResponseDto.php - About 2 hrs to fix

                      Method __construct has 20 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                              public ?bool $notifyOnNewEntry = null,
                              public ?bool $notifyOnNewEntryReply = null,
                              public ?bool $notifyOnNewEntryCommentReply = null,
                              public ?bool $notifyOnNewPost = null,
                              public ?bool $notifyOnNewPostReply = null,
                      Severity: Major
                      Found in src/Kbin/User/DTO/UserSettingsDto.php - About 2 hrs to fix

                        Method create has 20 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                int $id,
                                UserSmallResponseDto $user = null,
                                MagazineSmallResponseDto $magazine = null,
                                Post $post = null,
                                PostComment $parent = null,
                        Severity: Major
                        Found in src/Kbin/PostComment/DTO/PostCommentResponseDto.php - About 2 hrs to fix

                          Method create has 20 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                                  int $id,
                                  UserSmallResponseDto $user,
                                  MagazineSmallResponseDto $magazine,
                                  ImageDto $image = null,
                                  string $body = null,
                          Severity: Major
                          Found in src/Kbin/Post/DTO/PostResponseDto.php - About 2 hrs to fix

                            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
                                Severity
                                Category
                                Status
                                Source
                                Language