SysMO-DB/seek

View on GitHub
app/controllers/favourites_controller.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Method add has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  def add
    if request.post?
      if params[:id]=="drag_search" #needs to create the SavedSearch resource first
        saved_search = SavedSearch.new(:user_id => current_user.id, :search_query => params[:search_query], :search_type => params[:search_type],:include_external_search=>params[:include_external_search]=="1")
        if SavedSearch.find_by_user_id_and_search_query_and_search_type_and_include_external_search(current_user,params[:search_query],params[:search_type],params[:include_external_search]=="1").nil? && saved_search.save
Severity: Minor
Found in app/controllers/favourites_controller.rb - About 2 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 add has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def add
    if request.post?
      if params[:id]=="drag_search" #needs to create the SavedSearch resource first
        saved_search = SavedSearch.new(:user_id => current_user.id, :search_query => params[:search_query], :search_type => params[:search_type],:include_external_search=>params[:include_external_search]=="1")
        if SavedSearch.find_by_user_id_and_search_query_and_search_type_and_include_external_search(current_user,params[:search_query],params[:search_type],params[:include_external_search]=="1").nil? && saved_search.save
Severity: Minor
Found in app/controllers/favourites_controller.rb - About 1 hr to fix

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

      def delete
        if request.delete?
          id=params[:id].split("_")[1].to_i
          f=Favourite.find(id)
          f.resource.destroy if f.resource.instance_of?(SavedSearch)
    Severity: Minor
    Found in app/controllers/favourites_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

    There are no issues that match your filters.

    Category
    Status