tddwizard/magento2-fixtures

View on GitHub

Showing 57 of 61 total issues

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

        AddressRepositoryInterface $addressRepository,
        CartRepositoryInterface $quoteRepository,
        QuoteManagement $quoteManagement,
        PaymentConfig $paymentConfig,
        Cart $cart,
Severity: Major
Found in src/Checkout/CustomerCheckout.php - About 1 hr to fix

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

            ProductRepositoryInterface $productRepository,
            StockItemRepositoryInterface $stockItemRepository,
            ProductWebsiteLinkRepositoryInterface $websiteLinkRepository,
            ProductWebsiteLinkInterfaceFactory $websiteLinkFactory,
            IndexerFactory $indexerFactory,
    Severity: Major
    Found in src/Catalog/ProductBuilder.php - About 1 hr to fix

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

          public function build(): Order
          {
              $builder = clone $this;
      
              if (empty($builder->productBuilders)) {
      Severity: Minor
      Found in src/Sales/OrderBuilder.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

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

              CategoryRepositoryInterface $categoryRepository,
              CategoryResource $categoryResource,
              CategoryLinkRepositoryInterface $categoryLinkRepository,
              CategoryProductLinkInterfaceFactory $productLinkFactory,
              Category $category,
      Severity: Minor
      Found in src/Catalog/CategoryBuilder.php - About 45 mins to fix

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

                ShipmentItemCreationInterfaceFactory $itemFactory,
                ShipmentTrackCreationInterfaceFactory $trackFactory,
                ShipOrderInterface $shipOrder,
                ShipmentRepositoryInterface $shipmentRepository,
                Order $order
        Severity: Minor
        Found in src/Sales/ShipmentBuilder.php - About 35 mins to fix

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

                  CustomerRepositoryInterface $customerRepository,
                  CustomerInterface $customer,
                  Encryptor $encryptor,
                  string $password,
                  AddressBuilder ...$addressBuilders
          Severity: Minor
          Found in src/Customer/CustomerBuilder.php - About 35 mins to fix

            Missing class import via use statement (line '59', column '23').
            Open

                        throw new \RuntimeException('Order does not have any payment information');
            Severity: Minor
            Found in src/Sales/OrderFixture.php by phpmd

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '37', column '23').
            Open

                        throw new \OutOfBoundsException('No matching shipment found in fixture pool');
            Severity: Minor
            Found in src/Sales/ShipmentFixturePool.php by phpmd

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '38', column '23').
            Open

                        throw new \OutOfBoundsException('No matching category found in fixture pool');
            Severity: Minor
            Found in src/Catalog/CategoryFixturePool.php by phpmd

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '37', column '23').
            Open

                        throw new \OutOfBoundsException('No matching creditmemo found in fixture pool');
            Severity: Minor
            Found in src/Sales/CreditmemoFixturePool.php by phpmd

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '38', column '23').
            Open

                        throw new \OutOfBoundsException('No matching order found in fixture pool');
            Severity: Minor
            Found in src/Sales/OrderFixturePool.php by phpmd

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '41', column '23').
            Open

                        throw new \OutOfBoundsException('No matching option found in fixture pool');
            Severity: Minor
            Found in src/Catalog/OptionFixturePool.php by phpmd

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '176', column '23').
            Open

                        throw new \RuntimeException('QuoteManagement::submit() returned ' . $returnType . ' instead of Order');
            Severity: Minor
            Found in src/Checkout/CustomerCheckout.php by phpmd

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '37', column '23').
            Open

                        throw new \OutOfBoundsException('No matching invoice found in fixture pool');
            Severity: Minor
            Found in src/Sales/InvoiceFixturePool.php by phpmd

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '212', column '19').
            Open

                    throw new \RuntimeException('Error building option');
            Severity: Minor
            Found in src/Catalog/OptionBuilder.php by phpmd

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '38', column '23').
            Open

                        throw new \OutOfBoundsException('No matching product found in fixture pool');
            Severity: Minor
            Found in src/Catalog/ProductFixturePool.php by phpmd

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '38', column '23').
            Open

                        throw new \OutOfBoundsException('No matching customer found in fixture pool');
            Severity: Minor
            Found in src/Customer/CustomerFixturePool.php by phpmd

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Avoid unused private fields such as '$shippingMethod'.
            Open

                private $shippingMethod;
            Severity: Minor
            Found in src/Sales/OrderBuilder.php by phpmd

            UnusedPrivateField

            Since: 0.2

            Detects when a private field is declared and/or assigned a value, but not used.

            Example

            class Something
            {
                private static $FOO = 2; // Unused
                private $i = 5; // Unused
                private $j = 6;
                public function addOne()
                {
                    return $this->j++;
                }
            }

            Source https://phpmd.org/rules/unusedcode.html#unusedprivatefield

            The method withName uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
            Open

                    } else {
                        $builder->product->setName($name);
                    }
            Severity: Minor
            Found in src/Catalog/ProductBuilder.php by phpmd

            ElseExpression

            Since: 1.4.0

            An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

            Example

            class Foo
            {
                public function bar($flag)
                {
                    if ($flag) {
                        // one branch
                    } else {
                        // another branch
                    }
                }
            }

            Source https://phpmd.org/rules/cleancode.html#elseexpression

            The method add uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
            Open

                    } else {
                        $this->productFixtures[$key] = new ProductFixture($product);
                    }
            Severity: Minor
            Found in src/Catalog/ProductFixturePool.php by phpmd

            ElseExpression

            Since: 1.4.0

            An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

            Example

            class Foo
            {
                public function bar($flag)
                {
                    if ($flag) {
                        // one branch
                    } else {
                        // another branch
                    }
                }
            }

            Source https://phpmd.org/rules/cleancode.html#elseexpression

            Severity
            Category
            Status
            Source
            Language