jdutil/spree_marketplace

View on GitHub

Showing 6 of 8 total issues

Method initialize has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def initialize(user)
      user ||= Spree.user_class.new

      if user.supplier
        if SpreeMarketplace::Engine.spree_digital_available?
Severity: Major
Found in app/models/spree/supplier_ability.rb - About 2 hrs to fix

    Method create has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def create
        authorize! :create, Spree::Supplier
    
        @supplier = Spree::Supplier.new(supplier_params)
    
    
    Severity: Minor
    Found in app/controllers/spree/suppliers_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 stripe_recipient_setup has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def stripe_recipient_setup
        return if self.tax_id.blank? and self.address.blank?
    
        recipient = Stripe::Recipient.create(
          :name => (self.merchant_type == 'business' ? self.name : "#{self.address.first_name} #{self.address.last_name}"),
    Severity: Minor
    Found in app/models/spree/supplier_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 stripe_recipient_update has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def stripe_recipient_update
        unless new_record? or !changed?
          if token.present?
            rp = Stripe::Recipient.retrieve(token)
            rp.name  = name
    Severity: Minor
    Found in app/models/spree/supplier_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 initialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(user)
          user ||= Spree.user_class.new
    
          if user.supplier
            if SpreeMarketplace::Engine.spree_digital_available?
    Severity: Minor
    Found in app/models/spree/supplier_ability.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 assign_name has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def assign_name
        self.address = Spree::Address.default     unless self.address.present?
        self.address.first_name = self.first_name unless self.address.first_name.present?
        self.address.last_name = self.last_name   unless self.address.last_name.present?
      end
    Severity: Minor
    Found in app/models/spree/supplier_decorator.rb - 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

    Severity
    Category
    Status
    Source
    Language