sheerun/githubsocial

View on GitHub

Showing 3 of 3 total issues

Method recommend has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def recommend(id, options = {})
    id = id.to_i

    raw_ratings = cached_ratings(id, options)

Severity: Minor
Found in app/services/redis_recommender.rb - About 1 hr to fix

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

      def recommend(id, options = {})
        id = id.to_i
    
        raw_ratings = cached_ratings(id, options)
    
    
    Severity: Minor
    Found in app/services/redis_recommender.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

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

      def cached_related_repos
        Rails.cache.fetch(request.url, expires_in: 30.minutes) do
          repo = Repo.find_by(name: params[:name], owner: params[:owner])
          user_id = params[:user_id] ? params[:user_id].to_i : nil
          penalize_factor = (1.5 ** [9, [1, params[:popularity].to_i].max].min).floor
    Severity: Minor
    Found in app/controllers/api_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