hummingbird-me/kitsu-server

View on GitHub

Showing 162 of 163 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

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

          def self.detailed_users
            Zorro::DB::User.find.batch_size(2000).aggregate([
              {
                '$addFields': {
                  detailsId: {
    Severity: Minor
    Found in app/services/zorro/importer/user_importer.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/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

      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

      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

      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 105..136

      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 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 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 update_in_batches has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def update_in_batches(updates = {}, of: 10000, **kwargs)
            updates = updates.merge(kwargs) if updates.is_a?(Hash)
            relation = self
            relation = relation.reorder(batch_order).limit(of)
            batch_relation = relation
      Severity: Minor
      Found in lib/update_in_batches.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 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 index has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def index(ids)
          Manga.where(id: ids).includes(:media_categories, :genres).find_each do |manga|
            titles = manga.titles_list
      
            yield({
      Severity: Minor
      Found in app/indices/typesense_manga_index.rb - About 1 hr to fix

        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 2 locations. Consider refactoring.
          Open

            def query
              @query ||= begin
                query = TypesenseAnimeIndex.search(
                  query: filters[:text]&.join(' ') || '',
                  query_by: {
          Severity: Minor
          Found in app/services/anime_search_service.rb and 1 other location - About 1 hr to fix
          app/services/manga_search_service.rb on lines 33..53

          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 47.

          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

            def query
              @query ||= begin
                query = TypesenseMangaIndex.search(
                  query: filters[:text]&.join(' ') || '',
                  query_by: {
          Severity: Minor
          Found in app/services/manga_search_service.rb and 1 other location - About 1 hr to fix
          app/services/anime_search_service.rb on lines 33..53

          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 47.

          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

          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
                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
                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

          Severity
          Category
          Status
          Source
          Language