hummingbird-me/kitsu-server

View on GitHub

Showing 97 of 166 total issues

File rails_admin.rb has 477 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 33 (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 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 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

    Class User has 33 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class User < ApplicationRecord
      include AvatarUploader::Attachment(:avatar)
      include CoverImageUploader::Attachment(:cover_image)
    
      PAST_NAMES_LIMIT = 10
    Severity: Minor
    Found in app/models/user.rb - About 4 hrs to fix

      File user.rb has 309 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      class User < ApplicationRecord
        include AvatarUploader::Attachment(:avatar)
        include CoverImageUploader::Attachment(:cover_image)
      
        PAST_NAMES_LIMIT = 10
      Severity: Minor
      Found in app/models/user.rb - About 3 hrs to fix

        Method preload_included_fragments has 83 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

          Class Row has 23 methods (exceeds 20 allowed). Consider refactoring.
          Open

              class Row
                def initialize(node, type)
                  @node = node
                  @type = type.to_s.downcase # anime | manga
                end
          Severity: Minor
          Found in app/models/list_import/anilist/row.rb - About 2 hrs to fix

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

              def create? # rubocop:disable Metrics/PerceivedComplexity
                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 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 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 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 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 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
                Severity
                Category
                Status
                Source
                Language