stevekaplan123/carpe_diem

View on GitHub
app/services/filter.rb

Summary

Maintainability
C
1 day
Test Coverage

Method filterByRecommendations has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def filterByRecommendations(events, user_id)
      events_attended = []
      tags_list = []
      tag_count = [0,0,0,0,0,0,0,0,0]
      recommended_events = []
Severity: Major
Found in app/services/filter.rb - About 2 hrs to fix

    Method initialize has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def initialize(user_id, location, near_me, other, time, tag, recommend)
      @events = Event.all
      if recommend == "true" 
            @events = filterByRecommendations(@events, user_id)
            @events = Filter.addAttendancestoEvents(@events)
    Severity: Minor
    Found in app/services/filter.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

    Method filterByOther has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def filterByOther(events, user_id, other)
        friend_events = []
        my_friends = []
        @users_friendships = Friendship.where(user_id: user_id)
        @users_friendships.each do |friendship|
    Severity: Minor
    Found in app/services/filter.rb - About 1 hr to fix

      Method filterByRecommendations has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def filterByRecommendations(events, user_id)
            events_attended = []
            tags_list = []
            tag_count = [0,0,0,0,0,0,0,0,0]
            recommended_events = []
      Severity: Minor
      Found in app/services/filter.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

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

      def filterByOther(events, user_id, other)
          friend_events = []
          my_friends = []
          @users_friendships = Friendship.where(user_id: user_id)
          @users_friendships.each do |friendship|
      Severity: Minor
      Found in app/services/filter.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

      Method initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def initialize(user_id, location, near_me, other, time, tag, recommend)
      Severity: Major
      Found in app/services/filter.rb - About 50 mins to fix

        Method search has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def self.search(searchValue)
          #@events = Event.all;  for each event, check each of the three in turn and add it to 
          #actual_events array to return
          #select distinct * from events where 
              @events = []
        Severity: Minor
        Found in app/services/filter.rb - About 35 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