controlshift/prague-server

View on GitHub

Showing 10 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        it 'should be redirected to sign in and then prompt you to connect to stripe' do
          # start the OAuth flow
          url = client.auth_code.authorize_url(:redirect_uri => redirect_uri)
          visit url
    
    
    Severity: Minor
    Found in scenarios/scenarios/an_oauth_client_generates_a_token_spec.rb and 1 other location - About 55 mins to fix
    scenarios/scenarios/an_oauth_client_generates_a_token_spec.rb on lines 86..98

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 46.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        it 'should be redirected to sign in and then where you were trying to go' do
          # start the OAuth flow
          url = client.auth_code.authorize_url(:redirect_uri => redirect_uri)
          visit url
    
    
    Severity: Minor
    Found in scenarios/scenarios/an_oauth_client_generates_a_token_spec.rb and 1 other location - About 55 mins to fix
    scenarios/scenarios/an_oauth_client_generates_a_token_spec.rb on lines 104..116

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 46.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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