ernestwisniewski/kbin

View on GitHub

Showing 464 of 573 total issues

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

    public function getFunctions(): array
    {
        return [
            new TwigFunction('entry_url', [UrlExtensionRuntime::class, 'entryUrl']),
            new TwigFunction('entry_edit_url', [UrlExtensionRuntime::class, 'entryEditUrl']),
Severity: Minor
Found in src/Twig/Extension/UrlExtension.php - About 1 hr to fix

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

            if(inputType === 'password'){
                this.input.setAttribute('type', 'text');
                this.previewIcon.classList.remove('fa-eye-slash');
                this.previewIcon.classList.add('fa-eye');
    
    
    Severity: Major
    Found in assets/controllers/password_preview_controller.js and 1 other location - About 1 hr to fix
    assets/controllers/password_preview_controller.js on lines 55..59

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

    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

            }else{
                this.input.setAttribute('type', 'password');
                this.previewIcon.classList.remove('fa-eye');
                this.previewIcon.classList.add('fa-eye-slash');
            }
    Severity: Major
    Found in assets/controllers/password_preview_controller.js and 1 other location - About 1 hr to fix
    assets/controllers/password_preview_controller.js on lines 50..55

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

    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 sendForm has a Cognitive Complexity of 10 (exceeds 5 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

    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 handleEntries has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        async handleEntries(url) {
            let response = await fetch(url, {method: 'GET'});
    
            response = await ok(response);
    
    
    Severity: Minor
    Found in assets/controllers/infinite_scroll_controller.js - 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 buildResult has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function buildResult(array $result, $page, $countAll)
        {
            $entries = $this->entityManager->getRepository(Entry::class)->findBy(
                ['id' => $this->getOverviewIds((array) $result, 'entry')]
            );
    Severity: Minor
    Found in src/Repository/SearchRepository.php - About 1 hr to fix

      Method updateMagazine has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function updateMagazine(string $actorUrl): Magazine
          {
              $magazine = $this->magazineRepository->findOneBy(['apProfileId' => $actorUrl]);
              $actor = $this->apHttpClient->getActorObject($actorUrl);
      
      
      Severity: Minor
      Found in src/Service/ActivityPubManager.php - About 1 hr to fix

        Method getStats has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getStats(
                ?Magazine $magazine,
                string $intervalStr,
                ?\DateTime $start,
                ?\DateTime $end,
        Severity: Minor
        Found in src/Repository/StatsContentRepository.php - About 1 hr to fix

          Method create has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function create(
                  int $id = null,
                  MagazineSmallResponseDto $magazine = null,
                  UserSmallResponseDto $user = null,
                  DomainDto $domain = null,
          Severity: Minor
          Found in src/Kbin/Entry/DTO/EntryResponseDto.php - About 1 hr to fix

            Method getTests has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getTests(): array
                {
                    return [
                        new TwigTest(
                            'entry', function ($subject) {
            Severity: Minor
            Found in src/Twig/Extension/SubjectExtension.php - About 1 hr to fix

              Method byMagazine has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  #[OA\Response(
                      response: 200,
                      description: 'A paginated list of posts from the magazine',
                      content: new OA\JsonContent(
                          type: 'object',
              Severity: Minor
              Found in src/Controller/Api/Post/PostsRetrieveApi.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/Controller/Entry/EntryFavouriteController.php and 1 other location - About 1 hr to fix
                src/Controller/Post/PostFavouriteController.php on lines 1..33

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

                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/Controller/Post/PostFavouriteController.php and 1 other location - About 1 hr to fix
                src/Controller/Entry/EntryFavouriteController.php on lines 1..33

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

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

                    #[IsGranted('ROLE_USER')]
                    #[IsGranted('moderate', subject: 'comment')]
                    public function __invoke(
                        #[MapEntity(mapping: ['magazine_name' => 'name'])]
                        Magazine $magazine,
                Severity: Minor
                Found in src/Controller/Post/Comment/PostCommentModerateController.php - About 1 hr to fix

                  Method getDailyStats has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function getDailyStats(): array
                      {
                          $conn = $this->getEntityManager()
                              ->getConnection();
                  
                  
                  Severity: Minor
                  Found in src/Repository/StatsViewsRepository.php - About 1 hr to fix

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

                        #[IsGranted('moderate', subject: 'comment')]
                        public function __invoke(
                            #[MapEntity(mapping: ['magazine_name' => 'name'])]
                            Magazine $magazine,
                            #[MapEntity(id: 'entry_id')]
                    Severity: Minor
                    Found in src/Controller/Entry/Comment/EntryCommentModerateController.php - About 1 hr to fix

                      Method findOrCreateFromPath has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function findOrCreateFromPath(string $source): ?Image
                          {
                              $fileName = $this->imageManager->getFileName($source);
                              $filePath = $this->imageManager->getFilePath($source);
                              $sha256 = hash_file('sha256', $source, true);
                      Severity: Minor
                      Found in src/Repository/ImageRepository.php - About 1 hr to fix

                        Method hydrate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function hydrate(PostComment ...$comment): void
                            {
                                $this->_em->createQueryBuilder()
                                    ->select('PARTIAL c.{id}')
                                    ->addSelect('u')
                        Severity: Minor
                        Found in src/Repository/PostCommentRepository.php - About 1 hr to fix

                          Method buildForm has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function buildForm(FormBuilderInterface $builder, array $options): void
                              {
                                  $builder
                                      ->add('query', TextType::class, [
                                          'attr' => [
                          Severity: Minor
                          Found in src/Kbin/Magazine/Form/MagazinePageViewType.php - About 1 hr to fix

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

                                #[OA\Response(
                                    response: 200,
                                    description: 'Returns a paginated list of entries from a specific user',
                                    content: new OA\JsonContent(
                                        type: 'object',
                            Severity: Minor
                            Found in src/Controller/Api/Entry/UserEntriesRetrieveApi.php - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language