crispgm/holy-images

View on GitHub

Showing 7 of 7 total issues

Method format_image has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

      def format_image(image, with_exif: true, with_likes: false, with_comments: false)
        if with_likes
          likes = []
          image.likes.each do |like|
            likes << {
Severity: Minor
Found in app/controllers/api/v1/images_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 format_image has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def format_image(image, with_exif: true, with_likes: false, with_comments: false)
        if with_likes
          likes = []
          image.likes.each do |like|
            likes << {
Severity: Minor
Found in app/controllers/api/v1/images_controller.rb - About 1 hr to fix

    Method like has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def like
        image_id = params[:id]
        user_id = current_user.id
    
        result = {
    Severity: Minor
    Found in app/controllers/image_controller.rb - About 1 hr to fix

      Method like has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def like
          image_id = params[:id]
          user_id = current_user.id
      
          result = {
      Severity: Minor
      Found in app/controllers/image_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

      Method read has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def read
          id = params[:id]
          user = current_user
      
          result = nil
      Severity: Minor
      Found in app/controllers/notification_controller.rb - About 1 hr to fix

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

          def read
            id = params[:id]
            user = current_user
        
            result = nil
        Severity: Minor
        Found in app/controllers/notification_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

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

          def index
            unless logged_in?
              @images = Image.unscoped.joins(:likes).group("likes.image_id").order("count(likes.id) desc").limit(18)
              
              render "index/landing"
        Severity: Minor
        Found in app/controllers/index_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

        Severity
        Category
        Status
        Source
        Language