Sorcery/sorcery

View on GitHub
lib/sorcery/controller/submodules/session_timeout.rb

Summary

Maintainability
A
1 hr
Test Coverage

Method validate_session has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

          def validate_session
            session_to_use = Config.session_timeout_from_last_action ? session[:last_action_time] : session[:login_time]
            if (session_to_use && sorcery_session_expired?(session_to_use.to_time)) || sorcery_session_invalidated?
              reset_sorcery_session
              remove_instance_variable :@current_user if defined? @current_user
Severity: Minor
Found in lib/sorcery/controller/submodules/session_timeout.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 sorcery_session_invalidated? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

          def sorcery_session_invalidated?
            return false unless Config.session_timeout_invalidate_active_sessions_enabled
            return false unless current_user.present? && current_user.try(:invalidate_sessions_before).present?

            time = session[:login_time] || session[:last_action_time] || Time.now.in_time_zone
Severity: Minor
Found in lib/sorcery/controller/submodules/session_timeout.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