hummingbird-me/kitsu-server

View on GitHub

Showing 163 of 164 total issues

File rails_admin.rb has 489 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require Rails.root.join('lib/rails_admin/config/fields/types/localized_string')
require Rails.root.join('lib/rails_admin/config/fields/types/localized_text')
require Rails.root.join('lib/rails_admin/config/fields/types/string_list')
require Rails.root.join('lib/rails_admin/config/fields/types/flags')
require Rails.root.join('lib/rails_admin/config/fields/types/duration')
Severity: Minor
Found in config/initializers/rails_admin.rb - About 7 hrs to fix

    Method preload_included_fragments has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

        def preload_included_fragments(resources, records, serializer, options)
          return if resources.empty?
          res_ids = resources.keys
    
          include_directives = options[:include_directives]
    Severity: Minor
    Found in app/resources/concerns/ignore_preloading_nils.rb - About 6 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 object_hash has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

      def object_hash(source, include_directives = {})
        obj_hash = {}
    
        if source.is_a?(JSONAPI::CachedResourceFragment)
          if source.class.name != 'CategoryRecommendationResource'
    Severity: Minor
    Found in app/serializers/category_recommendation_serializer.rb - About 4 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 preload_included_fragments has 84 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def preload_included_fragments(resources, records, serializer, options)
          return if resources.empty?
          res_ids = resources.keys
    
          include_directives = options[:include_directives]
    Severity: Major
    Found in app/resources/concerns/ignore_preloading_nils.rb - About 3 hrs to fix

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

        def apply_status_filter_for(scope)
          return scope if filters[:status].blank?
      
          statuses = filters[:status].map do |status|
            case status
      Severity: Major
      Found in app/services/manga_search_service.rb and 1 other location - About 2 hrs to fix
      app/services/anime_search_service.rb on lines 102..133

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

      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

        def apply_status_filter_for(scope)
          return scope if filters[:status].blank?
      
          statuses = filters[:status].map do |status|
            case status
      Severity: Major
      Found in app/services/anime_search_service.rb and 1 other location - About 2 hrs to fix
      app/services/manga_search_service.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 101.

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

            def apply_selects(activities, selects, grouped = false)
              return activities if selects.empty?
              # We use map+reject(blank) so that we can modify the activities in the
              # groups
              activities = activities.lazy.map do |act|
      Severity: Minor
      Found in app/models/feed/activity_list/page.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

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

      class UnitThumbnailUploader < Shrine
        include ImageUploader
        include PublicUploader
      
        DERIVATIVES = {
      Severity: Major
      Found in app/uploaders/unit_thumbnail_uploader.rb and 2 other locations - About 2 hrs to fix
      app/uploaders/portrait_image_uploader.rb on lines 3..25
      app/uploaders/poster_image_uploader.rb on lines 3..25

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

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

      class PortraitImageUploader < Shrine
        include ImageUploader
        include PublicUploader
      
        DERIVATIVES = {
      Severity: Major
      Found in app/uploaders/portrait_image_uploader.rb and 2 other locations - About 2 hrs to fix
      app/uploaders/poster_image_uploader.rb on lines 3..25
      app/uploaders/unit_thumbnail_uploader.rb on lines 3..25

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

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

      class PosterImageUploader < Shrine
        include ImageUploader
        include PublicUploader
      
        DERIVATIVES = {
      Severity: Major
      Found in app/uploaders/poster_image_uploader.rb and 2 other locations - About 2 hrs to fix
      app/uploaders/portrait_image_uploader.rb on lines 3..25
      app/uploaders/unit_thumbnail_uploader.rb on lines 3..25

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

      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

          def pluck_arel_attributes(relation, *attrs)
            if relation.is_a?(Chewy::Query)
              attr_names = attrs.map { |a| a.name.to_s }
              relation = relation.only(*attr_names)
              relation.map { |row| row.attributes.values_at(*attr_names) }
      Severity: Major
      Found in app/resources/concerns/searchable_resource.rb and 1 other location - About 2 hrs to fix
      app/resources/concerns/algolia_searchable_resource.rb on lines 103..119

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

      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

          def pluck_arel_attributes(relation, *attrs)
            if relation.is_a?(Chewy::Query)
              attr_names = attrs.map { |a| a.name.to_s }
              relation = relation.only(*attr_names)
              relation.map { |row| row.attributes.values_at(*attr_names) }
      Severity: Major
      Found in app/resources/concerns/algolia_searchable_resource.rb and 1 other location - About 2 hrs to fix
      app/resources/concerns/searchable_resource.rb on lines 110..126

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

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

          def associate_initial_anime!
            exclude_ids = []
            puts 'Associating Anime With Categories From AniDB Dump'
            data.each do |unfiltered_anime|
              unfiltered_anime = unfiltered_anime.deep_symbolize_keys
      Severity: Minor
      Found in lib/anidb_category_import/media_importer.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

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

          def auto_query(field, value)
            case value
            when String, Integer, Float, Date
              { match: { field => value } }
            when Range
      Severity: Major
      Found in app/resources/concerns/algolia_searchable_resource.rb and 1 other location - About 2 hrs to fix
      app/resources/concerns/searchable_resource.rb on lines 185..202

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

      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

          def auto_query(field, value)
            case value
            when String, Integer, Float, Date
              { match: { field => value } }
            when Range
      Severity: Major
      Found in app/resources/concerns/searchable_resource.rb and 1 other location - About 2 hrs to fix
      app/resources/concerns/algolia_searchable_resource.rb on lines 178..195

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

      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 index has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def index(ids)
          Anime.where(id: ids).includes(
            :media_categories, :genres, streaming_links: [:streamer]
          ).find_each do |anime|
            titles = anime.titles_list
      Severity: Minor
      Found in app/indices/typesense_anime_index.rb - About 1 hr to fix

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

          def create?
            return false unless user
            return false if user.unregistered?
            return false if user.blocked?(record.target_user)
            return false if user.has_role?(:banned)
        Severity: Minor
        Found in app/policies/post_policy.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 auto_query has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def auto_query(field, value)
              case value
              when String, Integer, Float, Date
                { match: { field => value } }
              when Range
        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 auto_query has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def auto_query(field, value)
              case value
              when String, Integer, Float, Date
                { match: { field => value } }
              when Range
        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 list has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def list
            return @list if @list
            list = feed.activities
            list = list.page(id_lt: cursor) if cursor
            list = list.per(limit) if limit
        Severity: Minor
        Found in app/services/feed_query_service.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

        Severity
        Category
        Status
        Source
        Language