drhenner/ror_ecommerce

View on GitHub

Showing 346 of 346 total issues

Function initialize has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    initialize      : function() {
      jQuery('#submit_add_to_cart').click( function() {
          if (jQuery('#cart_item_variant_id').val() == '' ) { // Select to see if variant is selected in hidden field
            alert('Please click on a specific item to add.');
          } else
Severity: Minor
Found in app/assets/javascripts/shopping/cart.js - About 1 hr to fix

    Function search_field_scale has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        Chosen.prototype.search_field_scale = function() {
          var dd_top, div, h, style, style_block, styles, w, _i, _len;
          if (this.is_multiple) {
            h = 0;
            w = 0;
    Severity: Minor
    Found in app/assets/javascripts/chosen/chosen.jquery.js - About 1 hr to fix

      Function renderPreview has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            function renderPreview() {
              var phtml;
              if (options.previewParser && typeof options.previewParser === 'function') {
                var data = options.previewParser( $$.val() );
                writeInPreview( localize(data, 1) );
      Severity: Minor
      Found in app/assets/javascripts/markitup/jquery.markitup.js - About 1 hr to fix

        Function magicMarkups has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              function magicMarkups(string) {
                if (string) {
                  string = string.toString();
                  string = string.replace(/\(\!\(([\s\S]*?)\)\!\)/g,
                    function(x, a) {
        Severity: Minor
        Found in app/assets/javascripts/markitup/jquery.markitup.js - About 1 hr to fix

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

            def update
              @order = session_admin_order
              @order.ip_address = request.remote_ip
          
              @credit_card ||= ActiveMerchant::Billing::CreditCard.new(cc_params)
          Severity: Minor
          Found in app/controllers/admin/shopping/checkout/orders_controller.rb - About 1 hr to fix

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

                Chosen.prototype.result_clear_highlight = function() {
                  if (this.result_highlight) {
                    this.result_highlight.removeClass("highlighted");
                  }
                  return this.result_highlight = null;
            Severity: Major
            Found in app/assets/javascripts/chosen/chosen.jquery.js and 1 other location - About 1 hr to fix
            app/assets/javascripts/chosen/chosen.jquery.js on lines 818..823

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

            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

                Chosen.prototype.clear_backstroke = function() {
                  if (this.pending_backstroke) {
                    this.pending_backstroke.removeClass("search-choice-focus");
                  }
                  return this.pending_backstroke = null;
            Severity: Major
            Found in app/assets/javascripts/chosen/chosen.jquery.js and 1 other location - About 1 hr to fix
            app/assets/javascripts/chosen/chosen.jquery.js on lines 509..514

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

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

                def ensure_available
                  if active? && deleted_at_changed?
                    self.errors.add(:base, 'There must be active variants.')  if active_variants.blank?
                    self.errors.add(:base, 'Variants must have inventory.')   unless active_variants.any?{|v| v.is_available? }
                    self.deleted_at = deleted_at_was if active_variants.blank? || !active_variants.any?{|v| v.is_available? }
            Severity: Minor
            Found in app/models/product.rb - 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 create has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                @referring_user = User.find_by_email(params[:referring_user_email])
                @referral = Referral.new(allowed_params)
                @referral.referral_type_id = ReferralType::ADMIN_WEB_FORM_ID
                @referral.skip_validate_has_not_signed_up_yet = true
            Severity: Minor
            Found in app/controllers/admin/user_datas/referrals_controller.rb - 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 create_invoice has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def create_invoice(credit_card, charge_amount, args, credited_amount = 0.0)
                transaction do
                  new_invoice = create_invoice_transaction(credit_card, charge_amount, args, credited_amount)
                  if new_invoice.succeeded?
                    remove_user_store_credits
            Severity: Minor
            Found in app/models/order.rb - 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 update has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def update
                @variant = Variant.find(params[:id])
                ###  the reason will effect accounting
                #    if the item is refunded by the supplier the accounting will be reflected
                if params[:refund].present? && params[:variant][:qty_to_add].present?
            Severity: Minor
            Found in app/controllers/admin/inventory/adjustments_controller.rb - 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 2 locations. Consider refactoring.
            Open

              class << self
            
                def send!(variant_ids)
                  Notifier.out_of_stock_message(out_of_stock_user_ids(variant_ids), Array(variant_ids)).deliver_later
                end
            Severity: Major
            Found in app/models/out_of_stock_notification.rb and 1 other location - About 1 hr to fix
            app/models/low_stock_notification.rb on lines 4..21

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

            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

              class << self
            
                def send!(variant_ids)
                  Notifier.low_stock_message(low_stock_user_ids(variant_ids), Array(variant_ids)).deliver_later
                end
            Severity: Major
            Found in app/models/low_stock_notification.rb and 1 other location - About 1 hr to fix
            app/models/out_of_stock_notification.rb on lines 4..22

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

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

                Chosen.prototype.keydown_checker = function(evt) {
                  var stroke, _ref;
                  stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
                  this.search_field_scale();
                  if (stroke !== 8 && this.pending_backstroke) {
            Severity: Minor
            Found in app/assets/javascripts/chosen/chosen.jquery.js - About 1 hr to fix

              Function initialize has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                initialize : function(invoiceId, order_id) {
              
                  var captureTag      = jQuery(Hadean.Fulfillment.captureInvoiceButton + invoiceId );
                  var capturePartTag  = jQuery(Hadean.Fulfillment.capturePartInvoiceButton + invoiceId);
                  var cancelTag       = jQuery(Hadean.Fulfillment.cancelInvoiceButton + invoiceId);
              Severity: Minor
              Found in app/assets/javascripts/admin/fulfillment.js - About 1 hr to fix

                Function indexOf has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
                      "use strict";
                      if (this == null) {
                        throw new TypeError();
                      }
                Severity: Minor
                Found in app/assets/javascripts/foundation_init/foundation.js - About 1 hr to fix

                  Function clean has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    jQuery.clean = function( elems, context, fragment, scripts ) {
                      // Set context per 1.8 logic
                      context = context || document;
                      context = !context.nodeType && context[0] || context;
                      context = context.ownerDocument || context;
                  Severity: Minor
                  Found in app/assets/javascripts/jquery/jquery-migrate-1.1.1.js - About 1 hr to fix

                    Function fieldValue has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    $.fieldValue = function(el, successful) {
                        var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
                        if (typeof successful == 'undefined') successful = true;
                    
                        if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
                    Severity: Minor
                    Found in app/assets/javascripts/jqwizard/jquery.form.js - About 1 hr to fix

                      Function add_option has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
                            if (option.nodeName === "OPTION") {
                              if (option.text !== "") {
                                if (group_position != null) {
                                  this.parsed[group_position].children += 1;
                      Severity: Minor
                      Found in app/assets/javascripts/chosen/chosen.jquery.js - About 1 hr to fix

                        Consider simplifying this complex logical expression.
                        Open

                              } else if (region.hasClass(self.settings.active_class) && self.is_accordion(section) || !settings.one_up && (self.small(section) || self.is_vertical_nav(section) || self.is_horizontal_nav(section) || self.is_accordion(section))) {
                                region.removeClass(self.settings.active_class);
                                region.trigger('closed.fndtn.section');
                              }
                        Severity: Major
                        Found in app/assets/javascripts/foundation/foundation.section.js - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language