ernestwisniewski/kbin

View on GitHub

Showing 226 of 573 total issues

Method serializeNotification has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function serializeNotification(Notification $dto)
    {
        $toReturn = [
            'notificationId' => $dto->getId(),
            'status' => $dto->status,
Severity: Major
Found in src/Controller/Api/Notification/NotificationBaseApi.php - About 2 hrs to fix

    Method findByObjectId has 56 lines of code (exceeds 25 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: Major
    Found in src/Repository/ApActivityRepository.php - About 2 hrs to fix

      File PostCommentsRetrieveApi.php has 257 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/PostCommentsRetrieveApi.php - About 2 hrs to fix

        Method findPeople has 54 lines of code (exceeds 25 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: Major
        Found in src/Repository/UserRepository.php - About 2 hrs to fix

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

                  private Server $server,
                  private UserRepository $userRepository,
                  private UserCreate $userCreate,
                  private UserFactory $userFactory,
                  private MagazineCreate $magazineCreate,
          Severity: Major
          Found in src/Service/ActivityPubManager.php - About 2 hrs to fix

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

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

              File NotificationReadApi.php has 255 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/Notification/NotificationReadApi.php - About 2 hrs to fix

                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

                    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

                              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

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

                                      public function up(Schema $schema): void
                                      {
                                          // this up() migration is auto-generated, please modify it to your needs
                                          $this->addSql("INSERT INTO \"public\".\"award_type\" (\"id\", \"name\", \"category\", \"count\", \"attributes\") VALUES
                                  (1, 'bronze_autobiographer', 'bronze', 0, 'a:0:{}'),
                                  Severity: Minor
                                  Found in migrations/Version20230314134010.php - About 1 hr to fix

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

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

                                      Method filter has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          private function filter(QueryBuilder $qb, Criteria $criteria): void
                                          {
                                              if ($criteria->post) {
                                                  $qb->andWhere('c.post = :post')
                                                      ->setParameter('post', $criteria->post);
                                      Severity: Minor
                                      Found in src/Repository/PostCommentRepository.php - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language