podemos-info/census

View on GitHub

Showing 7 of 10 total issues

Method build_resource has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def build_resource
      build_params = params[:orders_batch] || {}
      first_pending_order = OrdersWithoutOrdersBatch.new.merge(OrdersPending.new).first

      if first_pending_order
Severity: Minor
Found in app/admin/orders_batch.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 parse_response has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def parse_response(response)
        envelope = Hash.from_xml(response)
        envelope = envelope.dig("Envelope", "Body") if envelope.present?
        return nil unless envelope

Severity: Minor
Found in lib/census/payments/redsys_integration.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 build_resource has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def build_resource
      build_params = params[:order] || {}
      build_params[:amount] = (build_params[:full_amount].to_f * 100).to_i
      if build_params[:payment_method_id].present?
        form_class = Orders::ExistingPaymentMethodOrderForm
Severity: Minor
Found in app/admin/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 name has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def name
    if object.name == "page_view"
      action = properties["q"] ? "search" : properties["action"]
      controller = properties["controller"].singularize
      controller_text = I18n.t("activerecord.models.#{controller}", count: properties["id"] ? 1 : 10, default: nil)
Severity: Minor
Found in app/decorators/event_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

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

      def parse(response, date_span)
        # By default use raw response as response code
        self.response_code = response

        response_parts = parse_response(response)
Severity: Minor
Found in lib/census/payments/redsys_integration.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 response_message has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def response_message
        xml = Builder::XmlMarkup.new
        response = xml.Response Ds_Version: "0.0" do
          xml.Ds_Response_Merchant(success? ? "OK" : "KO")
        end
Severity: Minor
Found in lib/census/payments/redsys_integration.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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def call
      return broadcast(:invalid) unless valid?
      return broadcast(:review) if review?

      orders_batch.update! processed_at: Time.current, processed_by: admin
Severity: Minor
Found in app/commands/payments/process_orders_batch.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