ernestwisniewski/kbin

View on GitHub

Showing 464 of 573 total issues

Function serializeNotification has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    protected function serializeNotification(Notification $dto)
    {
        $toReturn = [
            'notificationId' => $dto->getId(),
            'status' => $dto->status,
Severity: Minor
Found in src/Controller/Api/Notification/NotificationBaseApi.php - About 55 mins 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

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

        let container = this.element.nextElementSibling && this.element.nextElementSibling.classList.contains('js-container') ? this.element.nextElementSibling : null;
Severity: Minor
Found in assets/controllers/subject_controller.js and 1 other location - About 55 mins to fix
assets/controllers/preview_controller.js on lines 25..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 53.

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

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

        let container = this.element.nextElementSibling && this.element.nextElementSibling.classList.contains('js-container')
            ? this.element.nextElementSibling : null;
Severity: Minor
Found in assets/controllers/preview_controller.js and 1 other location - About 55 mins to fix
assets/controllers/subject_controller.js on lines 223..223

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

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 findBySubject(ReportInterface $subject): ?Report
    {
        return match (true) {
            $subject instanceof Entry => $this->findByEntry($subject),
            $subject instanceof EntryComment => $this->findByEntryComment($subject),
Severity: Minor
Found in src/Repository/ReportRepository.php and 1 other location - About 55 mins to fix
src/Repository/ReportRepository.php on lines 93..102

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

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 findPendingBySubject(ReportInterface $subject): ?Report
    {
        return match (true) {
            $subject instanceof Entry => $this->findPendingByEntry($subject),
            $subject instanceof EntryComment => $this->findPendingByEntryComment($subject),
Severity: Minor
Found in src/Repository/ReportRepository.php and 1 other location - About 55 mins to fix
src/Repository/ReportRepository.php on lines 46..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 98.

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

        #[MapEntity(id: 'magazine_id')]
        Magazine $magazine,
        #[MapEntity(id: 'user_id')]
        User $user,
        MagazineBan $magazineBan,
Severity: Major
Found in src/Controller/Api/Magazine/Moderate/MagazineUserBanApi.php - About 50 mins to fix

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

        public static function create(int $id, string $filePath, int $width = null, int $height = null, string $altText = null, string $sourceUrl = null, string $storageUrl = null): self
    Severity: Major
    Found in src/DTO/ImageDto.php - About 50 mins to fix

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

              private string $route,
              private string $paramName,
              private string $slug,
              string $label,
              string $title,
      Severity: Major
      Found in src/Markdown/CommonMark/Node/RoutedMentionLink.php - About 50 mins to fix

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

                string $name,
                string $title,
                User $user,
                ?string $description,
                ?string $rules,
        Severity: Major
        Found in src/Entity/Magazine.php - About 50 mins to fix

          Method uploadImage has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  ClientManagerInterface $manager,
                  ClientFactory $clientFactory,
                  UserCreate $userCreate,
                  UserRepository $userRepository,
                  SettingsManager $settingsManager,
          Severity: Major
          Found in src/Controller/Api/OAuth2/CreateClientApi.php - About 50 mins to fix

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

                    string $fileName,
                    string $filePath,
                    string $sha256,
                    ?int $width,
                    ?int $height,
            Severity: Minor
            Found in src/Entity/Image.php - About 45 mins to fix

              Method __invoke has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      #[MapEntity(id: 'magazine_id')]
                      Magazine $magazine,
                      EntryBadgeCreate $entryBadgeCreate,
                      MagazineFactory $factory,
                      SerializerInterface $serializer,
              Severity: Minor
              Found in src/Controller/Api/Magazine/Admin/MagazineAddBadgesApi.php - About 45 mins to fix

                Method __invoke has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        #[MapEntity(id: 'magazine_id')]
                        Magazine $magazine,
                        MagazineThemeChange $magazineThemeChange,
                        MagazineFactory $magazineFactory,
                        ImageFactory $imageFactory,
                Severity: Minor
                Found in src/Controller/Api/Magazine/Admin/MagazineUpdateThemeApi.php - About 45 mins to fix

                  Function getMonthlyStats has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function getMonthlyStats(): array
                      {
                          $conn = $this->getEntityManager()
                              ->getConnection();
                  
                  
                  Severity: Minor
                  Found in src/Repository/StatsViewsRepository.php - About 45 mins 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 updateUser has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function updateUser(string $actorUrl): User
                      {
                          $user = $this->userRepository->findOneBy(['apProfileId' => $actorUrl]);
                  
                          $actor = $this->apHttpClient->getActorObject($actorUrl);
                  Severity: Minor
                  Found in src/Service/ActivityPubManager.php - About 45 mins 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 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public static function create(UserSmallResponseDto $sender, string $body, string $status, int $threadId, \DateTimeImmutable $createdAt, int $messageId): self
                  Severity: Minor
                  Found in src/DTO/MessageResponseDto.php - About 45 mins to fix

                    Function setDimensions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function setDimensions(?int $width, ?int $height): void
                        {
                            if (null !== $width && $width <= 0) {
                                throw new \InvalidArgumentException('$width must be NULL or >0');
                            }
                    Severity: Minor
                    Found in src/Entity/Image.php - About 45 mins 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 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        public static function create(int $consentId, string $clientName, ?string $clientDescription, ?ImageDto $logo, array $scopesGranted, array $scopesAvailable): self
                    Severity: Minor
                    Found in src/DTO/ClientConsentsResponseDto.php - About 45 mins to fix

                      Function findOrCreateFromPath has a Cognitive Complexity of 8 (exceeds 5 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 45 mins 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 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                              #[MapEntity(id: 'magazine_id')]
                              Magazine $magazine,
                              MagazineEdit $magazineEdit,
                              MagazineFactory $magazineFactory,
                              ValidatorInterface $validator,
                      Severity: Minor
                      Found in src/Controller/Api/Magazine/Admin/MagazineUpdateApi.php - About 45 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language