suryart/spree_active_sale

View on GitHub

Showing 6 of 6 total issues

Method update_parent_active_sales has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def update_parent_active_sales
      active_sale_events = self.self_and_ancestors
      parents = self.ancestors
      oldest_start_date = active_sale_events.not_blank_and_sorted_by(:start_date).first
      latest_end_date = active_sale_events.not_blank_and_sorted_by(:end_date).last
Severity: Minor
Found in app/models/spree/active_sale_event.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 start_and_end_date_range has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def start_and_end_date_range
        unless self.start_date.nil? || self.end_date.nil?
          oldest_start_date = self.active_sale_events.not_blank_and_sorted_by(:start_date).first
          latest_end_date = self.active_sale_events.not_blank_and_sorted_by(:end_date).last
          errors.add(:start_date, I18n.t('spree.active_sale.event.validation.errors.invalid_root_dates')) if (oldest_start_date.nil? && latest_end_date.nil?) ? false : (self.start_date > oldest_start_date || self.end_date < latest_end_date)
Severity: Minor
Found in app/models/spree/active_sale.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 show has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def show
      @product = Spree::Product.active.find_by_permalink!(params[:id])
      return unless @product

      if @product.live?
Severity: Minor
Found in app/controllers/spree/products_controller_decorator.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 define_sale_image_method has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def define_sale_image_method(style)
      self.class.send :define_method, "#{style}_event_image" do |sale_event, *options|
        options = options.first || {}
        if sale_event.sale_images.empty?
          image_tag "noimage/#{style}.png", options
Severity: Minor
Found in app/helpers/spree/active_sale_events_helper.rb - 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

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

        def get_eventable_object(object_name = {})
          unless object_name[:eventable_type].nil?
            eventable = "#{object_name[:eventable_type]}".constantize.find_by_name(object_name[:eventable_name])
            object_name.delete(:eventable_name)
            unless eventable.nil?
Severity: Minor
Found in app/controllers/spree/admin/resource_controller_decorator.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 show has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def show
      @taxon = Spree::Taxon.find_by_permalink!(params[:id])
      return unless @taxon

      if @taxon.live?
Severity: Minor
Found in app/controllers/spree/taxons_controller_decorator.rb - About 25 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

Severity
Category
Status
Source
Language