SysMO-DB/seek

View on GitHub
app/controllers/favourite_groups_controller.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method update has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    group_name = white_list(params[:favourite_group_name])
    found = FavouriteGroup.where(:name => group_name, :user_id => current_user.id).first
    
    # if the found group with the same is the current one - that's fine; otherwise - can't rename a group with such new name 
Severity: Minor
Found in app/controllers/favourite_groups_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 update has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def update
    group_name = white_list(params[:favourite_group_name])
    found = FavouriteGroup.where(:name => group_name, :user_id => current_user.id).first
    
    # if the found group with the same is the current one - that's fine; otherwise - can't rename a group with such new name 
Severity: Minor
Found in app/controllers/favourite_groups_controller.rb - About 2 hrs to fix

    Method create has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def create
        group_name = white_list(params[:favourite_group_name])
        already_exists = FavouriteGroup.where(:name => group_name, :user_id => current_user.id).first
        
        unless already_exists
    Severity: Minor
    Found in app/controllers/favourite_groups_controller.rb - About 1 hr to fix

      Method create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def create
          group_name = white_list(params[:favourite_group_name])
          already_exists = FavouriteGroup.where(:name => group_name, :user_id => current_user.id).first
          
          unless already_exists
      Severity: Minor
      Found in app/controllers/favourite_groups_controller.rb - About 55 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