GrafiteInc/Commerce

View on GitHub

Showing 99 of 99 total issues

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

    public function billingAddress($key = null)
    {
        if (auth()->user()) {
            $profile = auth()->user()->meta;
            $address = json_decode($profile->billing_address);
Severity: Major
Found in src/Services/CustomerProfileService.php and 1 other location - About 1 hr to fix
src/Services/CustomerProfileService.php on lines 26..42

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

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 shippingAddress($key = null)
    {
        if (auth()->user()) {
            $profile = auth()->user()->meta;
            $address = json_decode($profile->shipping_address);
Severity: Major
Found in src/Services/CustomerProfileService.php and 1 other location - About 1 hr to fix
src/Services/CustomerProfileService.php on lines 51..67

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

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

  is.equal = function equal(value, other) {
    if (value === other) {
      return true;
    }

Severity: Minor
Found in src/Publishes/public/js/card.js - About 1 hr to fix

    Method purchase has 40 lines of code (exceeds 25 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 1 hr to fix

      Function extend has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        var extend = function extend() {
          var target = arguments[0] || {};
          var i = 1;
          var length = arguments.length;
          var deep = false;
      Severity: Minor
      Found in src/Publishes/public/js/card.js - About 1 hr to fix

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

            if ($('#Name').val() > '') {
                $('.plan-title').text($('#Name').val());
            } else {
                $('.plan-title').text('Plan Name');
            }
        Severity: Major
        Found in src/Assets/js/plans.js and 1 other location - About 1 hr to fix
        src/Assets/js/plans.js on lines 14..18

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

        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

            if ($('#Descriptor').val() > '') {
                $('.plan-descriptor').text($('#Descriptor').val());
            } else {
                $('.plan-descriptor').text('Credit Card Descriptor');
            }
        Severity: Major
        Found in src/Assets/js/plans.js and 1 other location - About 1 hr to fix
        src/Assets/js/plans.js on lines 2..6

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

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

            Card.prototype.render = function() {
              var $cardContainer, baseWidth, name, obj, selector, ua, _ref, _ref1;
              QJ.append(this.$container, this.template(this.cardTemplate, extend({}, this.options.messages, this.options.placeholders)));
              _ref = this.options.cardSelectors;
              for (name in _ref) {
        Severity: Minor
        Found in src/Publishes/public/js/card.js - About 1 hr to fix

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

            is.odd = function (value) {
              return is.infinite(value) || (is.number(value) && value === value && value % 2 !== 0);
            };
          Severity: Major
          Found in src/Publishes/public/js/card.js and 1 other location - About 1 hr to fix
          src/Publishes/public/js/card.js on lines 2305..2307

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

          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

            is.even = function (value) {
              return is.infinite(value) || (is.number(value) && value === value && value % 2 === 0);
            };
          Severity: Major
          Found in src/Publishes/public/js/card.js and 1 other location - About 1 hr to fix
          src/Publishes/public/js/card.js on lines 2318..2320

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

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

            function addStyle(obj, options) {
              var styleElement, update, remove;
          
              if (options.singleton) {
                var styleIndex = singletonCounter++;
          Severity: Minor
          Found in src/Publishes/public/js/card.js - About 1 hr to fix

            Function attachHandlers has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                Card.prototype.attachHandlers = function() {
                  var expiryFilters, numberInputFilters;
                  numberInputFilters = [this.validToggler('cardNumber')];
                  if (this.options.masks.cardNumber) {
                    numberInputFilters.push(this.maskCardNumber);
            Severity: Minor
            Found in src/Publishes/public/js/card.js - About 1 hr to fix

              Function update has a Cognitive Complexity of 12 (exceeds 5 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

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

                module.exports = function() {
                  var list = [];
              
                  // return the list of modules as css string
                  list.toString = function toString() {
              Severity: Minor
              Found in src/Publishes/public/js/card.js - About 1 hr to fix

                Function weightVariants has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function weightVariants($item, $product)
                    {
                        $variants = json_decode($item->product_variants);
                
                        if (!is_null($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 validateCardExpiry has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        validateCardExpiry: function(month, year) {
                          var currentTime, expiry, prefix, ref, ref1;
                          if (typeof month === 'object' && 'month' in month) {
                            ref = month, month = ref.month, year = ref.year;
                          } else if (typeof month === 'string' && indexOf.call(month, '/') >= 0) {
                Severity: Minor
                Found in src/Publishes/public/js/card.js - About 1 hr to fix

                  Function validToggler has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      Card.prototype.validToggler = function(validatorName) {
                        var isValid;
                        if (validatorName === "cardExpiry") {
                          isValid = function(val) {
                            var objVal;
                  Severity: Minor
                  Found in src/Publishes/public/js/card.js - About 1 hr to fix

                    Method createOrder has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function createOrder($user, $transaction, $items)
                        {
                            $customerService = app(CustomerProfileService::class);
                    
                            $shippingAddress = json_encode([
                    Severity: Minor
                    Found in src/Services/PaymentService.php - About 1 hr to fix

                      Method cancel has 30 lines of code (exceeds 25 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

                        Method addToCart has 30 lines of code (exceeds 25 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 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language