oivoodoo/devise_masquerade

View on GitHub

Showing 3 of 3 total issues

Method define_helpers has 103 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.define_helpers(mapping)
        name = mapping.name
        class_name = mapping.class_name

        class_eval <<-METHODS, __FILE__, __LINE__ + 1
Severity: Major
Found in lib/devise_masquerade/controllers/helpers.rb - About 4 hrs to fix

    Method back has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def back
        unless send("#{masqueraded_resource_name}_masquerade?")
          resource = send("current_#{masqueraded_resource_name}")
          go_back(resource, path: after_back_masquerade_path_for(resource))
        else
    Severity: Minor
    Found in app/controllers/devise/masquerades_controller.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

    Method show has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def show
        if send("#{masqueraded_resource_name}_masquerade?")
          resource = masquerading_current_user
    
          go_back(resource, path: after_masquerade_full_path_for(resource))
    Severity: Minor
    Found in app/controllers/devise/masquerades_controller.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