ArturT/Railstom

View on GitHub

Showing 2 of 2 total issues

Consider simplifying this complex logical expression.
Open

    if devise_controller? && resource_name == :user && (
      # registration
      action_name == 'new' || action_name == 'create' ||
      # change password. Only for logout user because this action_names are also used on user_edit_registration_path
      ((action_name == 'edit' || action_name == 'update') && !user_signed_in?)
Severity: Major
Found in app/controllers/application_controller.rb - About 1 hr to fix

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

      def handle_omniauth_for_new_user(provider_name, authentication)
        # No user associated with the authentication so we need to create a new one
        user = user_service.build_with_omniauth
    
        if user_has_missing_only_email?(user)
    Severity: Minor
    Found in app/controllers/omniauth_callbacks_controller.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

    Severity
    Category
    Status
    Source
    Language