appirits/comable

View on GitHub

Showing 11 of 34 total issues

Method change has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def change
    reversible do |dir|
      change_table :comable_stocks do |t|
        dir.up   { t.references :variant }
        dir.down { t.remove :variant_id }

    Method load_directory_tree has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def load_directory_tree(path, parent = nil)
            children = []
            tree = { (parent || :root) => children }
    
            Dir.foreach(path) do |entry|
    Severity: Minor
    Found in backend/app/helpers/comable/admin/themes_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 reset_stock_from_cart has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def reset_stock_from_cart(stock, quantity)
          cart_item = find_cart_item_by(stock)
          if quantity > 0
            return add_stock_to_cart(stock, quantity) unless cart_item
            cart_item.update_attributes(quantity: quantity)
    Severity: Minor
    Found in core/app/models/concerns/comable/cart_owner.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 remove_duplicated has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def remove_duplicated(unit)
            duplicated = false
    
            packages.each do |package|
              next unless package.find(unit)
    Severity: Minor
    Found in core/app/models/comable/inventory/adjuster.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 stock_location_params has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def stock_location_params
            params.require(:stock_location).permit(
              :name,
              :active,
              :default,
    Severity: Minor
    Found in backend/app/controllers/comable/admin/stock_locations_controller.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
          if Rails::VERSION::MAJOR == 3
            @page = Comable::Page.find(params[:id])
          else
            @page = Comable::Page.friendly.find(params[:id])
    Severity: Minor
    Found in frontend/app/controllers/comable/pages_controller.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

    Method find_cart_item has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_cart_item
          cart_item = Comable::Stock.find_by(id: params[:stock_id])
          cart_item ||= Comable::Variant.find_by(id: params[:variant_id])
          cart_item ||= Comable::Product.find_by(id: params[:product_id])
          return unless cart_item
    Severity: Minor
    Found in frontend/app/controllers/comable/carts_controller.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

    Method __association__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def __association__(hash)
        return unless hash.is_a? Hash
    
        association = hash.keys.first
        method_path = hash_to_method_path(hash)
    Severity: Minor
    Found in core/lib/comma_extractor_extentions.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

    Method inherit! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def inherit!(order)
          self.bill_address ||= order.bill_address
          self.ship_address ||= order.ship_address
          self.payment ||= order.payment
          self.shipments = order.shipments if shipments.empty?
    Severity: Minor
    Found in core/app/models/comable/order.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

    Method package has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def package
            package = Package.new(stock_location)
    
            units.group_by(&:variant).each do |variant, variant_units|
              stock = stock_location.find_stock_item(variant)
    Severity: Minor
    Found in core/app/models/comable/inventory/packer.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

    Method build_associations has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def build_associations
            @order.build_bill_address unless @order.bill_address
            @order.build_ship_address unless @order.ship_address
            @order.build_payment unless @order.payment
          end
    Severity: Minor
    Found in backend/app/controllers/comable/admin/draft_orders_controller.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