hummingbird-me/kitsu-server

View on GitHub

Showing 165 of 166 total issues

Method apply_status_filter_for has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def apply_status_filter_for(scope)
    return scope if filters[:status].blank?

    statuses = filters[:status].map do |status|
      case status
Severity: Minor
Found in app/services/anime_search_service.rb - About 1 hr to fix

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

      Attacher.derivatives do |original|
        info = ImageInfo.new(original.path)
        if info.animated?
          magick = ImageProcessing::MiniMagick.source(original).loader(loader: info.type)
                                              .background('transparent').dispose('background')
    Severity: Major
    Found in app/uploaders/cover_image_uploader.rb and 1 other location - About 1 hr to fix
    app/uploaders/avatar_uploader.rb on lines 51..59

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 52.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

      Attacher.derivatives do |original|
        info = ImageInfo.new(original.path)
        if info.animated?
          magick = ImageProcessing::MiniMagick.source(original).loader(loader: info.type)
                                              .background('transparent').dispose('background')
    Severity: Major
    Found in app/uploaders/avatar_uploader.rb and 1 other location - About 1 hr to fix
    app/uploaders/cover_image_uploader.rb on lines 42..50

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 52.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      query :query,
        mode: :query,
        apply: ->(values, _ctx) { # rubocop:disable Metrics/BlockLength
          {
            bool: {
    Severity: Major
    Found in app/resources/group_member_resource.rb and 1 other location - About 1 hr to fix
    app/resources/user_resource.rb on lines 98..129

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 51.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      query :query,
        mode: :query,
        apply: ->(values, _ctx) {
          {
            bool: {
    Severity: Major
    Found in app/resources/user_resource.rb and 1 other location - About 1 hr to fix
    app/resources/group_member_resource.rb on lines 45..77

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 51.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

        def load_query_records(query, opts = {})
          include_directives = opts[:include_directives]
          unless include_directives
            return @_search_service ? query.to_a : query.load.to_a
          end
    Severity: Minor
    Found in app/resources/concerns/algolia_searchable_resource.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 load_query_records has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def load_query_records(query, opts = {})
          include_directives = opts[:include_directives]
          unless include_directives
            return _search_service ? query.to_a : query.load.to_a
          end
    Severity: Minor
    Found in app/resources/concerns/searchable_resource.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 to_a has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def to_a
            return @data if @termination_reason
    
            @termination_reason = loop do
              break :iterations if @pages >= 10
    Severity: Minor
    Found in app/models/feed/activity_list/fetcher.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 query has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def query(field, opts = {})
          field = field.to_sym
    
          # For some reason, #filter(verify:) is supposed to return the values to
          # use.  I cannot honestly figure out why this is the case, so we provide
    Severity: Minor
    Found in app/resources/concerns/algolia_searchable_resource.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 query has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def query(field, opts = {})
          field = field.to_sym
    
          # For some reason, #filter(verify:) is supposed to return the values to
          # use.  I cannot honestly figure out why this is the case, so we provide
    Severity: Minor
    Found in app/resources/concerns/searchable_resource.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 feed_visible? has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def feed_visible?
        case params[:group].sub(/_aggr\z/, '')
        when 'media'
          media_type, media_id = params[:id].split('-')
          return false unless %w[Manga Anime Drama].include?(media_type)
    Severity: Minor
    Found in app/controllers/feeds_controller.rb - About 1 hr to fix

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

        sort :following,
          transform: ->(ast, context) {
            follows = Follow.arel_table
            comment = Comment.arel_table
      
      
      Severity: Major
      Found in app/graphql/loaders/comments_loader.rb and 3 other locations - About 55 mins to fix
      app/graphql/loaders/comment_likes_loader.rb on lines 3..15
      app/graphql/loaders/media_reaction_votes_loader.rb on lines 5..17
      app/graphql/loaders/post_likes_loader.rb on lines 3..15

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 46.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

        sort :following,
          transform: ->(ast, context) {
            follows = Follow.arel_table
            votes = MediaReactionVote.arel_table
      
      
      Severity: Major
      Found in app/graphql/loaders/media_reaction_votes_loader.rb and 3 other locations - About 55 mins to fix
      app/graphql/loaders/comment_likes_loader.rb on lines 3..15
      app/graphql/loaders/comments_loader.rb on lines 3..15
      app/graphql/loaders/post_likes_loader.rb on lines 3..15

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 46.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

        sort :following,
          transform: ->(ast, context) {
            follows = Follow.arel_table
            likes = CommentLike.arel_table
      
      
      Severity: Major
      Found in app/graphql/loaders/comment_likes_loader.rb and 3 other locations - About 55 mins to fix
      app/graphql/loaders/comments_loader.rb on lines 3..15
      app/graphql/loaders/media_reaction_votes_loader.rb on lines 5..17
      app/graphql/loaders/post_likes_loader.rb on lines 3..15

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 46.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

        sort :following,
          transform: ->(ast, context) {
            follows = Follow.arel_table
            likes = PostLike.arel_table
      
      
      Severity: Major
      Found in app/graphql/loaders/post_likes_loader.rb and 3 other locations - About 55 mins to fix
      app/graphql/loaders/comment_likes_loader.rb on lines 3..15
      app/graphql/loaders/comments_loader.rb on lines 3..15
      app/graphql/loaders/media_reaction_votes_loader.rb on lines 5..17

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 46.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

        def self.apply_sort(records, order_options, context = {})
          # For each requested sort option, decide whether to use the title sort logic
          order_options = order_options.map do |field, dir|
            [(TITLE_SORT =~ field ? :title : :other), field, dir]
          end
      Severity: Minor
      Found in app/resources/library_entry_resource.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 generate_query has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def generate_query(filters)
            # For each queryable field, attempt to apply.  If there's no apply
            # specified, use auto_query to generate one.
            queries = @_query_fields.map do |field, opts|
              next unless filters.key?(field) # Skip if we don't have a filter
      Severity: Minor
      Found in app/resources/concerns/searchable_resource.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 only_following has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def only_following(user_id)
            followed = Set.new(Follow.where(follower_id: user_id).pluck(:followed_id))
            select(0.5) do |act|
              user_id = act['actor'].split(':')[1].to_i
              is_followed = followed.include?(user_id)
      Severity: Minor
      Found in app/models/feed/activity_list.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 by_slug has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def by_slug(slug)
            record = where(slug: slug)
            return record if record.present?
      
            value = slug.is_a?(Array) ? slug.first : slug
      Severity: Minor
      Found in app/models/concerns/sluggable.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 generate_query has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def generate_query(filters)
            # For each queryable field, attempt to apply.  If there's no apply
            # specified, use auto_query to generate one.
            queries = @_query_fields.map do |field, opts|
              next unless filters.key?(field) # Skip if we don't have a filter
      Severity: Minor
      Found in app/resources/concerns/algolia_searchable_resource.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