inklabs/kommerce-core

View on GitHub

Showing 254 of 254 total issues

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

    public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
    {
        $classMetadata = $eventArgs->getClassMetadata();

        if ($classMetadata->isInheritanceTypeSingleTable() && !$classMetadata->isRootEntity()) {
Severity: Minor
Found in src/Doctrine/Extensions/TablePrefix.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

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

    protected function getZip5OrRateOrStateTaxRate(array $taxRates): ?TaxRate
    {
        $stateTaxRates = $zip5TaxRates = $rangeTaxRates = [];

        foreach ($taxRates as $taxRate) {
Severity: Minor
Found in src/EntityRepository/TaxRateRepository.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

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

    private function getFullSku(): string
    {
        $fullSku = [];

        if ($this->product !== null) {
Severity: Minor
Found in src/Entity/OrderItem.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

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

    private function calculateCouponDiscounts(): void
    {
        foreach ($this->cart->getCoupons() as $key => $coupon) {
            if ($coupon->isValid($this->pricing->getDate(), $this->cartTotal->subtotal)) {
                $newSubtotal = $coupon->getUnitPrice($this->cartTotal->subtotal);
Severity: Minor
Found in src/Lib/CartCalculator.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

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

<?php
namespace inklabs\kommerce\ActionResponse\Tag;

use inklabs\kommerce\EntityDTO\Builder\TagDTOBuilder;
use inklabs\kommerce\EntityDTO\TagDTO;
Severity: Major
Found in src/ActionResponse/Tag/GetTagResponse.php and 2 other locations - About 55 mins to fix
src/ActionResponse/Cart/GetCartResponse.php on lines 1..39
src/ActionResponse/Option/GetOptionResponse.php on lines 1..39

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 createImageForProduct(UploadFileDTO $uploadFileDTO, UuidInterface $productId): void
    {
        $managedFile = $this->fileManager->saveFile($uploadFileDTO->getFilePath());

        $image = new Image(
Severity: Minor
Found in src/Service/ImageService.php and 1 other location - About 55 mins to fix
src/Service/ImageService.php on lines 66..80

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

<?php
namespace inklabs\kommerce\ActionResponse\Option;

use inklabs\kommerce\EntityDTO\Builder\OptionDTOBuilder;
use inklabs\kommerce\EntityDTO\OptionDTO;
Severity: Major
Found in src/ActionResponse/Option/GetOptionResponse.php and 2 other locations - About 55 mins to fix
src/ActionResponse/Cart/GetCartResponse.php on lines 1..39
src/ActionResponse/Tag/GetTagResponse.php on lines 1..39

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 createImageForTag(UploadFileDTO $uploadFileDTO, UuidInterface $tagId): void
    {
        $managedFile = $this->fileManager->saveFile($uploadFileDTO->getFilePath());

        $image = new Image(
Severity: Minor
Found in src/Service/ImageService.php and 1 other location - About 55 mins to fix
src/Service/ImageService.php on lines 50..64

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

<?php
namespace inklabs\kommerce\ActionResponse\Cart;

use inklabs\kommerce\EntityDTO\Builder\CartDTOBuilder;
use inklabs\kommerce\EntityDTO\CartDTO;
Severity: Major
Found in src/ActionResponse/Cart/GetCartResponse.php and 2 other locations - About 55 mins to fix
src/ActionResponse/Option/GetOptionResponse.php on lines 1..39
src/ActionResponse/Tag/GetTagResponse.php on lines 1..39

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

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

    public static function loadValidatorMetadata(ClassMetadata $metadata)
    {
        $metadata->addPropertyConstraint('name', new Assert\NotBlank);
        $metadata->addPropertyConstraint('name', new Assert\Length([
            'max' => 255,
Severity: Minor
Found in src/Entity/AttributeValue.php and 1 other location - About 55 mins to fix
src/Entity/Attribute.php on lines 42..54

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

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

    public static function loadValidatorMetadata(ClassMetadata $metadata)
    {
        $metadata->addPropertyConstraint('name', new Assert\NotBlank);
        $metadata->addPropertyConstraint('name', new Assert\Length([
            'max' => 255,
Severity: Minor
Found in src/Entity/Attribute.php and 1 other location - About 55 mins to fix
src/Entity/AttributeValue.php on lines 47..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 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 __construct has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

        string $fileExtension,
        string $basePath,
        int $imageType,
        string $mimeType,
        int $width,
Severity: Major
Found in src/Entity/LocalManagedFile.php - About 50 mins to fix

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

            RepositoryFactory $repositoryFactory,
            CartCalculatorInterface $cartCalculator,
            EventDispatcherInterface $eventDispatcher,
            PaymentGatewayInterface $paymentGateway,
            ShipmentGatewayInterface $shipmentGateway,
    Severity: Minor
    Found in src/Service/ServiceFactory.php - About 45 mins to fix

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

              Product $product,
              int $quantity,
              string $memo,
              InventoryLocation $sourceLocation,
              InventoryLocation $destinationLocation,
      Severity: Minor
      Found in src/Service/InventoryService.php - About 45 mins to fix

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

                string $cartId,
                string $userId,
                string $ip4,
                CreditCardDTO $creditCardDTO,
                OrderAddressDTO $shippingAddressDTO,
        Severity: Minor
        Found in src/Action/Order/CreateOrderFromCartCommand.php - About 45 mins to fix

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

                  string $name,
                  ?int $maxRedemptions,
                  bool $reducesTaxSubtotal,
                  ?int $startAt,
                  ?int $endAt,
          Severity: Minor
          Found in src/Action/CartPriceRule/AbstractCartPriceRuleCommand.php - About 45 mins to fix

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

                    CreateOrderFromCartCommand $command,
                    CartRepositoryInterface $cartRepository,
                    CartCalculatorInterface $cartCalculator,
                    OrderServiceInterface $orderService,
                    UserRepositoryInterface $userRepository,
            Severity: Minor
            Found in src/ActionHandler/Order/CreateOrderFromCartHandler.php - About 45 mins to fix

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

                      User $user,
                      UserTokenType $type,
                      string $token,
                      string $userAgent,
                      string $ip4,
              Severity: Minor
              Found in src/Entity/UserToken.php - About 45 mins to fix

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

                        string $cartId,
                        string $productId,
                        int $quantity,
                        array $optionProductIds = null,
                        array $optionValuesIds = null,
                Severity: Minor
                Found in src/Action/Cart/AddCartItemCommand.php - About 45 mins to fix

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

                  <?php
                  namespace inklabs\kommerce\EntityDTO\Builder;
                  
                  use inklabs\kommerce\Entity\CartPriceRuleTagItem;
                  use inklabs\kommerce\EntityDTO\CartPriceRuleTagItemDTO;
                  Severity: Minor
                  Found in src/EntityDTO/Builder/CartPriceRuleTagItemDTOBuilder.php and 1 other location - About 45 mins to fix
                  src/EntityDTO/Builder/CartPriceRuleProductItemDTOBuilder.php on lines 1..45

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language