hummingbird-me/kitsu-server

View on GitHub

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

      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

      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

      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

        Method follow_many has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def follow_many(follows, backlog)
            return false unless ENV['STREAMLOG_REDIS_URL']
            follow_keys = follows.map do |follow|
              source = follow[:source].split(':')
              target = follow[:target].split(':')
        Severity: Minor
        Found in lib/stream_log.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 stats_data has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def stats_data
              data = super || default_data
              # Generate percentile data
              if global_stat
                data['percentiles'] = %w[media units time].each_with_object({}) do |key, out|
        Severity: Minor
        Found in app/models/concerns/stat/amount_consumed.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 apply_scopes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def apply_scopes(filters, opts = {})
              context = opts[:context]
              if _search_service
                # Separate queries from filters
                queries = filters.select { |f| @_query_fields.include?(f) }
        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 apply_scopes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def apply_scopes(filters, opts = {})
              context = opts[:context]
              if @_search_service
                # Separate queries from filters
                queries = filters.select { |f| @_query_fields.include?(f) }
        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 create? has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def create?
            return false unless user
            return false if user.unregistered?
            return false if user.blocked?(record.post.user)
            return false if user.has_role?(:banned)
        Severity: Minor
        Found in app/policies/comment_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 object_hash has 38 lines of code (exceeds 25 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 1 hr to fix

          Method query_for has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def self.query_for(query)
                fields = %w[name^2 people media]
                {
                  bool: {
                    must: {
          Severity: Minor
          Found in app/chewy/characters_index.rb - About 1 hr to fix

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

              def create?
                return false unless user
                return false if user.unregistered?
                return false if user.blocked?(record.comment.user)
                return false if user.blocked?(record.comment.post.user)
            Severity: Minor
            Found in app/policies/comment_like_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 strip_unenriched has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                  def strip_unenriched(activities, includes)
                    activities.map do |act|
                      if act['activities'] # Recurse into activity groups
                        act['activities'] = strip_unenriched(act['activities'], includes)
                      else
            Severity: Minor
            Found in app/models/feed/activity_list/page.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