GrafiteInc/Commerce

View on GitHub

Showing 50 of 99 total issues

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

    public function priceVariants($item, $product)
    {
        $variants = json_decode($item->product_variants);

        if ($variants) {
Severity: Minor
Found in src/Services/CartService.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 cancel has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function cancel($orderId)
    {
        $order = $this->repo->find($orderId);

        if ($order->status != 'complete') {
Severity: Minor
Found in src/Services/OrderService.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

Method up has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function up()
    {
        Schema::create(config('cms.db-prefix', '').'products', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
Severity: Minor
Found in src/Migrations/2015_10_03_021904_create_products_table.php - About 1 hr to fix

    Method update has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function update($userId, $payload)
        {
            if (isset($payload['meta']) && ! isset($payload['meta']['terms_and_cond'])) {
                throw new Exception("You must agree to the terms and conditions.", 1);
            }
    Severity: Minor
    Found in fixture/Services/UserService.php - About 1 hr to fix

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

          public function addToCart($id, $type, $quantity, $variables)
          {
              $cart = Session::get('cart');
              $variableArray = null;
      
      
      Severity: Minor
      Found in src/Repositories/CartSessionRepository.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 collectNewCoupons has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          public function collectNewCoupons()
          {
              $stripeCoupons = $this->stripeService->collectStripeCoupons()->data;
      
              foreach ($stripeCoupons as $coupon) {
      Severity: Minor
      Found in src/Services/CouponService.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 purchase has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          public function purchase($stripeToken, $cart)
          {
              $user = auth()->user();
      
              if (is_null($user->meta->stripe_id) && $stripeToken) {
      Severity: Minor
      Found in src/Services/PaymentService.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

      Avoid deeply nested control flow statements.
      Open

                  if (copyIsArray) {
                    copyIsArray = false;
                    clone = src && is.array(src) ? src : [];
                  } else {
                    clone = src && is.hash(src) ? src : {};
      Severity: Major
      Found in src/Publishes/public/js/card.js - About 45 mins to fix

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

            public function addToCart($id, $type, $quantity, $variants)
            {
                $variantArray = null;
        
                if (json_decode($variants)) {
        Severity: Minor
        Found in src/Repositories/CartRepository.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

        Avoid deeply nested control flow statements.
        Open

                  } else if (typeof copy !== 'undefined') {
                    target[name] = copy;
                  }
        Severity: Major
        Found in src/Publishes/public/js/card.js - About 45 mins to fix

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

              public function cancel($id)
              {
                  try {
                      $orderItem = $this->find($id);
          
          
          Severity: Minor
          Found in src/Services/OrderItemService.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

          Consider simplifying this complex logical expression.
          Open

              } else if(obj.sourceMap &&
                typeof URL === "function" &&
                typeof URL.createObjectURL === "function" &&
                typeof URL.revokeObjectURL === "function" &&
                typeof Blob === "function" &&
          Severity: Major
          Found in src/Publishes/public/js/card.js - About 40 mins to fix

            Function favoriteToggle has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                favoriteToggle: function(_id, _button, _content, _isFavorite, _isNotFavorite) {
            Severity: Minor
            Found in src/Publishes/public/js/store.js - About 35 mins to fix

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

                      Transaction $transaction,
                      OrderService $orderService,
                      LogisticService $logisticService,
                      OrderItemService $orderItemService,
                      TransactionService $transactionService
              Severity: Minor
              Found in src/Services/PaymentService.php - About 35 mins to fix

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

                    public function favoriteToggleBtn($product, $content, $notFavorite, $isFavorite, $class = '')
                Severity: Minor
                Found in src/Services/Concerns/CartHtmlGenerator.php - About 35 mins to fix

                  Function balanceValues has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function balanceValues($transactions)
                      {
                          $collected = $transactions->groupBy(function ($item) {
                              return $item->created_at->format('d-M-y');
                          });
                  Severity: Minor
                  Found in src/Services/AnalyticsService.php - About 35 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

                  Avoid too many return statements within this function.
                  Open

                        return value.prototype === other.prototype;
                  Severity: Major
                  Found in src/Publishes/public/js/card.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return QJ.val(target, value.replace(/\s\d?$/, ''));
                    Severity: Major
                    Found in src/Publishes/public/js/card.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return false;
                      Severity: Major
                      Found in src/Publishes/public/js/card.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              return true;
                        Severity: Major
                        Found in src/Publishes/public/js/card.js - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language