bikeindex/bike_index

View on GitHub
app/controllers/bikes_controller.rb

Summary

Maintainability
C
1 day
Test Coverage
C
72%

Method create has a Cognitive Complexity of 32 (exceeds 10 allowed). Consider refactoring.
Open

  def create
    find_or_new_b_param
    org_param = (@b_param.organization || current_organization)&.slug # Protect from nil - see #2308
    if params.dig(:bike, :embeded).present? && org_param.present? # NOTE: if embeded, doesn't verify csrf token
      if @b_param.created_bike.present?
Severity: Minor
Found in app/controllers/bikes_controller.rb - About 3 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 resolve_token has a Cognitive Complexity of 23 (exceeds 10 allowed). Consider refactoring.
Open

  def resolve_token
    if params[:token_type] == "graduated_notification"
      matching_notification = GraduatedNotification.where(bike_id: @bike.id, marked_remaining_link_token: params[:token]).first
      if matching_notification.present? && matching_notification.processed?
        if matching_notification.marked_remaining_at.blank?
Severity: Minor
Found in app/controllers/bikes_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 update has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring.
Open

  def update
    if params[:bike].present?
      begin
        @bike = BikeUpdator.new(user: current_user, bike: @bike, b_params: permitted_bike_params.as_json, current_ownership: @current_ownership).update_available_attributes
      rescue => e
Severity: Minor
Found in app/controllers/bikes_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

Avoid too many return statements within this method.
Open

        redirect_to(edit_bike_url(@b_param.created_bike)) && return
Severity: Major
Found in app/controllers/bikes_controller.rb - About 30 mins to fix

    There are no issues that match your filters.

    Category
    Status