controlshift/prague-server

View on GitHub

Showing 8 of 10 total issues

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

  def create
    build_resource(sign_up_params.reject { |k, v| k == 'organization_attributes' && v['name'].blank? })

    if params[:invitation_token]
      @invitation = Invitation.includes(:sender, :organization).find_by(token: params[:invitation_token])
Severity: Minor
Found in app/controllers/users_controller.rb - About 2 hrs 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 create has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    organization = Organization.find_by_slug(organization_slug_param)
    if organization.present?
      customer = Customer.find_or_initialize(customer_params, status: organization.status)
      charge = customer.build_charge_with_params(customer_params[:charges_attributes], config: config_param, organization: organization)
Severity: Minor
Found in app/controllers/charges_controller.rb - About 2 hrs 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 formatted_zip has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def formatted_zip
      if country
        fp = format_postcode(zip, country)
        fp.present? ? fp : zip
      else
Severity: Minor
Found in app/notifiers/adapters/base.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 create has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create
    build_resource(sign_up_params.reject { |k, v| k == 'organization_attributes' && v['name'].blank? })

    if params[:invitation_token]
      @invitation = Invitation.includes(:sender, :organization).find_by(token: params[:invitation_token])
Severity: Minor
Found in app/controllers/users_controller.rb - About 1 hr to fix

    Method find_in_batches has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_in_batches(options = {})
          batch_size = options[:batch_size] || 10000
          primary_key_offset = options[:primary_key_offset] || 0
    
          records = records_for_batch(batch_size, primary_key_offset)
    Severity: Minor
    Found in app/actions/queries/export.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 breadcrumbs has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def breadcrumbs(paths)
        content_tag(:ol, class: 'breadcrumb') do
          paths.collect do |path|
            li_options = if paths.last == path
              {class: 'active'}
    Severity: Minor
    Found in app/helpers/application_helper.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 after_sign_in_path_for has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def after_sign_in_path_for(resource)
        return admin_path if resource.admin?
    
        stored_location = stored_location_for(resource)
        if stored_location && current_organization
    Severity: Minor
    Found in app/controllers/application_controller.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 perform has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def perform(id)
        organization = Organization.find(id)
        event = { kind: KIND }
        organization.webhook_endpoints.each do |hook|
          Rails.logger.debug "Notifying #{hook.url} of #{KIND}"
    Severity: Minor
    Found in app/workers/organization_updated_worker.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