veersuvrat/CalDining-169

View on GitHub

Showing 5 of 5 total issues

Method get_submenu_items has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
Open

  def get_submenu_items(submenu_data, submenu_record)
    items = []
  
    submenu_data.css("a").each do |item|
      curr_item = Item.find_or_create_by(name: item.text)
Severity: Minor
Found in app/workers/parser_worker.rb - About 1 day 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 get_submenu_items has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def get_submenu_items(submenu_data, submenu_record)
    items = []
  
    submenu_data.css("a").each do |item|
      curr_item = Item.find_or_create_by(name: item.text)
Severity: Major
Found in app/workers/parser_worker.rb - About 2 hrs to fix

    Method perform has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def perform
        @base_url = "http://services.housing.berkeley.edu/FoodPro/dining/static/"
        @menu_path = "todaysentrees.asp"
        doc = Nokogiri::HTML(open(@base_url + @menu_path))
        
    Severity: Minor
    Found in app/workers/parser_worker.rb - About 1 hr to fix

      Method index has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def index
          @meals = Menu.meals
          @locations = Menu.locations
          @menus = Menu.all
          params[:meal] ? @selected_meal = params[:meal] : @selected_meal = session[:selected_meal]
      Severity: Minor
      Found in app/controllers/menus_controller.rb - About 1 hr 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

      Consider simplifying this complex logical expression.
      Open

          if (request.path != "/users/sign_in" &&
              request.path != "/users/sign_up" &&
              request.path != "/users/password/new" &&
              request.path != "/users/password/edit" &&
              request.path != "/users/confirmation" &&
      Severity: Major
      Found in app/controllers/application_controller.rb - About 1 hr to fix
        Severity
        Category
        Status
        Source
        Language