drhenner/ror_ecommerce

View on GitHub

Showing 346 of 346 total issues

Method remove_items has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def remove_items(variant, final_quantity)

    current_qty = 0
    items_to_remove = []
    self.order_items.each_with_index do |order_item, i|
Severity: Minor
Found in app/models/order.rb - 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

Method items_to_add_or_destroy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def items_to_add_or_destroy(items_in_cart, order)
    #destroy_any_order_item_that_was_removed_from_cart
    destroy_order_items_not_in_cart!(items_in_cart, order)
   # order.order_items.delete_all #destroy(order_item.id)
    items = order.order_items.inject({}) {|h, item| h[item.variant_id].nil? ? h[item.variant_id] = [item.id]  : h[item.variant_id] << item.id; h}
Severity: Minor
Found in app/models/cart.rb - 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

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

  def update
    @shipping_category = ShippingCategory.find_by_id(params[:id])
    if @shipping_category
      session[:product_wizard] ||= {}
      session[:product_wizard][:shipping_category_id] = @shipping_category.id
app/controllers/admin/merchandise/wizards/brands_controller.rb on lines 21..31
app/controllers/admin/merchandise/wizards/product_types_controller.rb on lines 15..25

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

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

  def update
    @product_type = ProductType.find_by_id(params[:id])
    if @product_type
      session[:product_wizard] ||= {}
      session[:product_wizard][:product_type_id] = @product_type.id
app/controllers/admin/merchandise/wizards/brands_controller.rb on lines 21..31
app/controllers/admin/merchandise/wizards/shipping_categories_controller.rb on lines 20..30

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

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

  def update
    @brand = Brand.find_by_id(params[:id])
    if @brand
      session[:product_wizard] ||= {}
      session[:product_wizard][:brand_id] = @brand.id
Severity: Minor
Found in app/controllers/admin/merchandise/wizards/brands_controller.rb and 2 other locations - About 35 mins to fix
app/controllers/admin/merchandise/wizards/product_types_controller.rb on lines 15..25
app/controllers/admin/merchandise/wizards/shipping_categories_controller.rb on lines 20..30

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

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

  def create
    @brand = Brand.new(allowed_params)
    if @brand.save
      session[:product_wizard] ||= {}
      session[:product_wizard][:brand_id] = @brand.id
Severity: Minor
Found in app/controllers/admin/merchandise/wizards/brands_controller.rb and 1 other location - About 35 mins to fix
app/controllers/admin/merchandise/wizards/shipping_categories_controller.rb on lines 7..17

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

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

  newShipmentSelection : function(id) {
    window.location.href = Hadean.AdminIndexForm.formController+'/'+id+"/shipments/new";
  }
Severity: Minor
Found in app/assets/javascripts/admin/index_grid.js and 1 other location - About 35 mins to fix
app/assets/javascripts/admin/index_grid.js on lines 10..12

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

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(this.options.formPluginEnabled && jQuery().ajaxSubmit == undefined){
                this.options.formPluginEnabled = false;
                if( (window['console'] !== undefined) ){
                    console.log("%s", "formPluginEnabled option set but the form plugin is not included");
                }
Severity: Minor
Found in app/assets/javascripts/jqwizard/jquery.form.wizard.js and 1 other location - About 35 mins to fix
app/assets/javascripts/jqwizard/jquery.form.wizard.js on lines 90..97

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

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

  editSelection : function(id) {
    window.location.href = Hadean.AdminIndexForm.formController+'/'+id+"/edit";
  },
Severity: Minor
Found in app/assets/javascripts/admin/index_grid.js and 1 other location - About 35 mins to fix
app/assets/javascripts/admin/index_grid.js on lines 20..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 46.

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(this.options.validationEnabled && jQuery().validate  == undefined){
                this.options.validationEnabled = false;
                if( (window['console'] !== undefined) ){
                    console.log("%s", "validationEnabled option set, but the validation plugin is not included");
                }
Severity: Minor
Found in app/assets/javascripts/jqwizard/jquery.form.wizard.js and 1 other location - About 35 mins to fix
app/assets/javascripts/jqwizard/jquery.form.wizard.js on lines 98..103

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

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

  def create
    @shipping_category = ShippingCategory.new(allowed_params)
    if @shipping_category.save
      session[:product_wizard] ||= {}
      session[:product_wizard][:shipping_category_id] = @shipping_category.id
app/controllers/admin/merchandise/wizards/brands_controller.rb on lines 8..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 34.

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

Avoid too many return statements within this function.
Open

      return el.show();
Severity: Major
Found in app/assets/javascripts/foundation/foundation.reveal.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return this;
    Severity: Major
    Found in app/assets/javascripts/jqwizard/jquery.form.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return el.value;
      Severity: Major
      Found in app/assets/javascripts/jqwizard/jquery.form.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                      return options.onTab.keepDefault;
        Severity: Major
        Found in app/assets/javascripts/markitup/jquery.markitup.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                        return false;
          Severity: Major
          Found in app/assets/javascripts/markitup/jquery.markitup.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                          return false;
            Severity: Major
            Found in app/assets/javascripts/markitup/jquery.markitup.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    return el.hide();
              Severity: Major
              Found in app/assets/javascripts/foundation/foundation.reveal.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return $(this.scope).width() < settings.small_breakpoint;
                Severity: Major
                Found in app/assets/javascripts/foundation/foundation.section.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return this;
                  Severity: Major
                  Found in app/assets/javascripts/jqwizard/jquery.form.js - About 30 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language