autowp/autowp

View on GitHub

Showing 1,718 of 1,718 total issues

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

    private function applyIdFilter(Sql\Select $select, $value, string $id): void
    {
        if (is_array($value)) {
            $value = array_values($value);

Severity: Major
Found in module/Application/src/Model/Picture.php and 2 other locations - About 4 hrs to fix
module/Application/src/Model/Item.php on lines 1006..1030
module/User/src/Model/User.php on lines 109..133

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

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

File PictureItem.php has 359 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Application\Model;

use ArrayObject;
Severity: Minor
Found in module/Application/src/Model/PictureItem.php - About 4 hrs to fix

    Function calcAvgUserValue has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        private function calcAvgUserValue(array $attribute, int $itemId): array
        {
            $userValuesDataTable = $this->getUserValueDataTable($attribute['typeId']);
    
            $userValueDataRows = $userValuesDataTable->select([
    Severity: Minor
    Found in module/Application/src/Service/SpecificationsService.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

    File BrandsController.php has 357 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace Application\Controller\Api;
    
    use Application\Model\Brand;
    Severity: Minor
    Found in module/Application/src/Controller/Api/BrandsController.php - About 4 hrs to fix

      Method addPictureFromFile has 114 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function addPictureFromFile(
              string $path,
              int $userId,
              string $remoteAddr,
              int $itemId,
      Severity: Major
      Found in module/Application/src/Service/PictureService.php - About 4 hrs to fix

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

        <?php
        
        namespace Application\Hydrator\Api\Strategy;
        
        use Application\Hydrator\Api\PictureHydrator as Hydrator;
        Severity: Major
        Found in module/Application/src/Hydrator/Api/Strategy/Pictures.php and 2 other locations - About 4 hrs to fix
        module/Application/src/Hydrator/Api/Strategy/Items.php on lines 1..50
        module/Application/src/Hydrator/Api/Strategy/PictureItems.php on lines 1..48

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

        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
        
        namespace Application\Hydrator\Api\Strategy;
        
        use Application\Hydrator\Api\PictureItemHydrator as Hydrator;
        module/Application/src/Hydrator/Api/Strategy/Items.php on lines 1..50
        module/Application/src/Hydrator/Api/Strategy/Pictures.php on lines 1..50

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

        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
        
        namespace Application\Hydrator\Api\Strategy;
        
        use Application\Hydrator\Api\ItemHydrator as Hydrator;
        Severity: Major
        Found in module/Application/src/Hydrator/Api/Strategy/Items.php and 2 other locations - About 4 hrs to fix
        module/Application/src/Hydrator/Api/Strategy/PictureItems.php on lines 1..48
        module/Application/src/Hydrator/Api/Strategy/Pictures.php on lines 1..50

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

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

            public function indexAction()
            {
                $user = $this->user()->get();
        
                $isModer = $this->user()->enforce('global', 'moderate');
        Severity: Major
        Found in module/Application/src/Controller/Api/ItemParentController.php - About 4 hrs to fix

          Function getZoneItemsActualValues has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
          Open

              private function getZoneItemsActualValues(int $zoneId, array $itemIds): array
              {
                  if (count($itemIds) <= 0) {
                      return [];
                  }
          Severity: Minor
          Found in module/Application/src/Service/SpecificationsService.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

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

                              foreach ($this->userItemSubscribe->getItemSubscribers($item['id']) as $subscriber) {
                                  if ($subscriber && ((int) $subscriber['id'] !== (int) $user['id'])) {
                                      $uri = $this->hostManager->getUriByLanguage($subscriber['language']);
          
                                      $message = sprintf(
          Severity: Major
          Found in module/Application/src/Controller/Api/ItemController.php and 1 other location - About 4 hrs to fix
          module/Application/src/Controller/Api/ItemController.php on lines 1747..1765

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

          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

                          foreach ($this->userItemSubscribe->getItemSubscribers($item['id']) as $subscriber) {
                              if ($subscriber && ((int) $subscriber['id'] !== (int) $user['id'])) {
                                  $uri = $this->hostManager->getUriByLanguage($subscriber['language']);
          
                                  $message = sprintf(
          Severity: Major
          Found in module/Application/src/Controller/Api/ItemController.php and 1 other location - About 4 hrs to fix
          module/Application/src/Controller/Api/ItemController.php on lines 1706..1724

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

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

              public function getFileNamePattern(int $pictureId): string
              {
                  $result = rand(1, 9999);
          
                  $filenameFilter = new FilenameSafe();
          Severity: Major
          Found in module/Application/src/Model/Picture.php - About 4 hrs to fix

            Method getNameData has 103 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getNameData($rows, array $options = []): array
                {
                    $result = [];
            
                    $language = $options['language'] ?? 'en';
            Severity: Major
            Found in module/Application/src/Model/Picture.php - About 4 hrs to fix

              File Brand.php has 338 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              
              namespace Application\Model;
              
              use Autowp\Image;
              Severity: Minor
              Found in module/Application/src/Model/Brand.php - About 4 hrs to fix

                Function specifications has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function specifications(array $cars, array $options): CarSpecTable
                    {
                        $options = array_merge([
                            'contextCarId' => null,
                            'language'     => 'en',
                Severity: Minor
                Found in module/Application/src/Service/SpecificationsService.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

                Function getFileNamePattern has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function getFileNamePattern(int $pictureId): string
                    {
                        $result = rand(1, 9999);
                
                        $filenameFilter = new FilenameSafe();
                Severity: Minor
                Found in module/Application/src/Model/Picture.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

                Method indexAction has 101 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function indexAction()
                    {
                        $user = $this->user()->get();
                
                        $this->inputFilter->setData($this->params()->fromQuery());
                Severity: Major
                Found in module/Application/src/Controller/Api/NewController.php - About 4 hrs to fix

                  File PictureItemController.php has 335 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  
                  namespace Application\Controller\Api;
                  
                  use Application\Controller\Plugin\Pic;
                  Severity: Minor
                  Found in module/Application/src/Controller/Api/PictureItemController.php - About 4 hrs to fix

                    DayPictures has 32 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class DayPictures
                    {
                        private const DEFAULT_TIMEZONE = 'UTC';
                    
                        private DateTimeZone $timezone;
                    Severity: Minor
                    Found in module/Application/src/Service/DayPictures.php - About 4 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language