inklabs/kommerce-core

View on GitHub

Showing 254 of 254 total issues

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

    public static function loadValidatorMetadata(ClassMetadata $metadata)
    {
        $metadata->addPropertyConstraint('name', new Assert\NotBlank);
        $metadata->addPropertyConstraint('name', new Assert\Length([
            'max' => 128,
Severity: Minor
Found in src/Entity/CreditCard.php - About 1 hr to fix

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

        public static function loadValidatorMetadata(ClassMetadata $metadata)
        {
            $metadata->addPropertyConstraint('externalId', new Assert\Length([
                'max' => 60,
            ]));
    Severity: Minor
    Found in src/Entity/ShipmentLabel.php - About 1 hr to fix

      Function import has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          public function import(Iterator $iterator): ImportResult
          {
              $importResult = new ImportResult;
              foreach ($iterator as $key => $row) {
                  if ($key < 2 && $row[0] === 'order_ref') {
      Severity: Minor
      Found in src/Service/Import/ImportPaymentService.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

      Function calculateCartPriceRules has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          private function calculateCartPriceRules(): void
          {
              foreach ($this->pricing->getCartPriceRules() as $cartPriceRule) {
                  if ($cartPriceRule->isValid($this->pricing->getDate(), $this->cart->getCartItems())) {
                      $numberTimesToApply = $cartPriceRule->numberTimesToApply($this->cart->getCartItems());
      Severity: Minor
      Found in src/Lib/CartCalculator.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

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

      <?php
      namespace inklabs\kommerce\ActionHandler\Image;
      
      use inklabs\kommerce\Action\Image\CreateImageForProductCommand;
      use inklabs\kommerce\Lib\Authorization\AuthorizationContextInterface;
      Severity: Major
      Found in src/ActionHandler/Image/CreateImageForProductHandler.php and 4 other locations - About 1 hr to fix
      src/ActionHandler/Attachment/CreateAttachmentForOrderItemHandler.php on lines 1..37
      src/ActionHandler/Cart/AddCouponToCartHandler.php on lines 1..37
      src/ActionHandler/Cart/CopyCartItemsHandler.php on lines 1..37
      src/ActionHandler/Image/CreateImageForTagHandler.php on lines 1..35

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

      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 5 locations. Consider refactoring.
      Open

      <?php
      namespace inklabs\kommerce\ActionHandler\Attachment;
      
      use inklabs\kommerce\Action\Attachment\CreateAttachmentForOrderItemCommand;
      use inklabs\kommerce\Lib\Authorization\AuthorizationContextInterface;
      src/ActionHandler/Cart/AddCouponToCartHandler.php on lines 1..37
      src/ActionHandler/Cart/CopyCartItemsHandler.php on lines 1..37
      src/ActionHandler/Image/CreateImageForProductHandler.php on lines 1..37
      src/ActionHandler/Image/CreateImageForTagHandler.php on lines 1..35

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

      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
      namespace inklabs\kommerce\EntityDTO\Builder;
      
      use inklabs\kommerce\Entity\OptionType;
      use inklabs\kommerce\EntityDTO\OptionTypeDTO;
      Severity: Major
      Found in src/EntityDTO/Builder/OptionTypeDTOBuilder.php and 1 other location - About 1 hr to fix
      src/EntityDTO/Builder/PromotionTypeDTOBuilder.php on lines 1..34

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

      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 5 locations. Consider refactoring.
      Open

      <?php
      namespace inklabs\kommerce\ActionHandler\Cart;
      
      use inklabs\kommerce\Action\Cart\AddCouponToCartCommand;
      use inklabs\kommerce\Lib\Authorization\AuthorizationContextInterface;
      Severity: Major
      Found in src/ActionHandler/Cart/AddCouponToCartHandler.php and 4 other locations - About 1 hr to fix
      src/ActionHandler/Attachment/CreateAttachmentForOrderItemHandler.php on lines 1..37
      src/ActionHandler/Cart/CopyCartItemsHandler.php on lines 1..37
      src/ActionHandler/Image/CreateImageForProductHandler.php on lines 1..37
      src/ActionHandler/Image/CreateImageForTagHandler.php on lines 1..35

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

      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 5 locations. Consider refactoring.
      Open

      <?php
      namespace inklabs\kommerce\ActionHandler\Cart;
      
      use inklabs\kommerce\Action\Cart\CopyCartItemsCommand;
      use inklabs\kommerce\Lib\Authorization\AuthorizationContextInterface;
      Severity: Major
      Found in src/ActionHandler/Cart/CopyCartItemsHandler.php and 4 other locations - About 1 hr to fix
      src/ActionHandler/Attachment/CreateAttachmentForOrderItemHandler.php on lines 1..37
      src/ActionHandler/Cart/AddCouponToCartHandler.php on lines 1..37
      src/ActionHandler/Image/CreateImageForProductHandler.php on lines 1..37
      src/ActionHandler/Image/CreateImageForTagHandler.php on lines 1..35

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

      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 addItemOptionValues(UuidInterface $cartItemId, array $optionValueIds): void
          {
              $optionValues = $this->optionValueRepository->getAllOptionValuesByIds($optionValueIds);
      
              $cartItem = $this->cartRepository->getItemById($cartItemId);
      Severity: Major
      Found in src/Service/CartService.php and 1 other location - About 1 hr to fix
      src/Service/CartService.php on lines 160..175

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

      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
      namespace inklabs\kommerce\EntityDTO\Builder;
      
      use inklabs\kommerce\Entity\PromotionType;
      use inklabs\kommerce\EntityDTO\PromotionTypeDTO;
      Severity: Major
      Found in src/EntityDTO/Builder/PromotionTypeDTOBuilder.php and 1 other location - About 1 hr to fix
      src/EntityDTO/Builder/OptionTypeDTOBuilder.php on lines 1..34

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

      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 addItemOptionProducts(UuidInterface $cartItemId, array $optionProductIds): void
          {
              $optionProducts = $this->optionProductRepository->getAllOptionProductsByIds($optionProductIds);
      
              $cartItem = $this->cartRepository->getItemById($cartItemId);
      Severity: Major
      Found in src/Service/CartService.php and 1 other location - About 1 hr to fix
      src/Service/CartService.php on lines 181..196

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

      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 5 locations. Consider refactoring.
      Open

      <?php
      namespace inklabs\kommerce\ActionHandler\Image;
      
      use inklabs\kommerce\Action\Image\CreateImageForTagCommand;
      use inklabs\kommerce\Lib\Authorization\AuthorizationContextInterface;
      Severity: Major
      Found in src/ActionHandler/Image/CreateImageForTagHandler.php and 4 other locations - About 1 hr to fix
      src/ActionHandler/Attachment/CreateAttachmentForOrderItemHandler.php on lines 1..37
      src/ActionHandler/Cart/AddCouponToCartHandler.php on lines 1..37
      src/ActionHandler/Cart/CopyCartItemsHandler.php on lines 1..37
      src/ActionHandler/Image/CreateImageForProductHandler.php on lines 1..37

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

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

              EventDispatcherInterface $eventDispatcher,
              InventoryServiceInterface $inventoryService,
              OrderRepositoryInterface $orderRepository,
              OrderItemRepositoryInterface $orderItemRepository,
              PaymentGatewayInterface $paymentGateway,
      Severity: Major
      Found in src/Service/OrderService.php - About 1 hr to fix

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

                string $name,
                string $promotionTypeSlug,
                int $value,
                bool $reducesTaxSubtotal,
                ?int $maxRedemptions,
        Severity: Major
        Found in src/Action/CatalogPromotion/CreateCatalogPromotionCommand.php - About 1 hr to fix

          Method createOrderFromCart has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  UuidInterface $orderId,
                  User $user,
                  Cart $cart,
                  CartCalculatorInterface $cartCalculator,
                  string $ip4,
          Severity: Major
          Found in src/Service/OrderService.php - About 1 hr to fix

            Method createOrderFromCart has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    UuidInterface $orderId,
                    User $user,
                    Cart $cart,
                    CartCalculatorInterface $cartCalculator,
                    string $ip4,
            Severity: Major
            Found in src/Service/OrderServiceInterface.php - About 1 hr to fix

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

                  public function __construct(
                      CreateOrderFromCartCommand $command,
                      CartRepositoryInterface $cartRepository,
                      CartCalculatorInterface $cartCalculator,
                      OrderServiceInterface $orderService,
              Severity: Minor
              Found in src/ActionHandler/Order/CreateOrderFromCartHandler.php and 1 other location - About 1 hr to fix
              src/Service/ServiceFactory.php on lines 37..51

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

              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 __construct(
                      RepositoryFactory $repositoryFactory,
                      CartCalculatorInterface $cartCalculator,
                      EventDispatcherInterface $eventDispatcher,
                      PaymentGatewayInterface $paymentGateway,
              Severity: Minor
              Found in src/Service/ServiceFactory.php and 1 other location - About 1 hr to fix
              src/ActionHandler/Order/CreateOrderFromCartHandler.php on lines 35..49

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

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

                  public function import(Iterator $iterator): ImportResult
                  {
                      $importResult = new ImportResult;
                      foreach ($iterator as $key => $row) {
                          if ($key < 2 && $row[0] === 'id') {
              Severity: Minor
              Found in src/Service/Import/ImportUserService.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

              Severity
              Category
              Status
              Source
              Language