bikeindex/bike_index

View on GitHub
app/controllers/api/v2/bikes.rb

Summary

Maintainability
A
2 hrs
Test Coverage
F
56%

Method registered_state has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring.
Open

        def registered_state(bike = nil)
          state = bike&.status&.gsub("status_", "")
          if state.present?
            return state if state == "stolen"
            if %w[abandoned impounded unregistered_parking_notification].include?(state)
Severity: Minor
Found in app/controllers/api/v2/bikes.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 creation_user_id has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
Open

        def creation_user_id
          if permanent_token? || doorkeeper_authorized_no_user?
            # current_organization requires token user to be authorized - V2_ACCESSOR is not
            organization = Organization.friendly_find(params[:organization_slug])
            if organization.present? && current_token&.application&.owner&.admin_of?(organization)
Severity: Minor
Found in app/controllers/api/v2/bikes.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

There are no issues that match your filters.

Category
Status