hummingbird-me/kitsu-server

View on GitHub

Showing 162 of 163 total issues

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

          def date_format
            return @date_format if @date_format
            # if any dates have values higher than 12, assume the date format
            data.each do |row|
              row.fetch_values('start_date_string', 'finish_date_string').each do |date|
      Severity: Minor
      Found in app/models/list_import/my_anime_list.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 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 parameter has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def parameter(key, cast: nil, load: nil, required: false)
              # Set up the accessor
              attr_accessor(key)
      
              # Track all the attributes we've set up so far
      Severity: Minor
      Found in lib/action/dsl.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

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

        def apply_order_to(scope)
          return scope unless orders
      
          # Replace _text_match with _text_match(buckets: 6),user_count in the same direction
          # This generally gives significantly better results for media searches
      Severity: Minor
      Found in app/services/manga_search_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 apply_order_to has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def apply_order_to(scope)
          return scope unless orders
      
          # Replace _text_match with _text_match(buckets: 6),user_count in the same direction
          # This generally gives significantly better results for media searches
      Severity: Minor
      Found in app/services/anime_search_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 image_field has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def image_field(key, **options)
            options = {
              type: Types::Image,
              null: true
            }.merge(options)
      Severity: Minor
      Found in app/graphql/concerns/has_image_field.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_average_ratings has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def update_average_ratings
            #
            # Bayesian rating:
            #
            #     (total + (MIN * global_average)) / (count + MIN)
      Severity: Minor
      Found in app/models/concerns/rateable.rb - About 1 hr to fix

        Method create? has a Cognitive Complexity of 11 (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/post_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 apply! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def apply!
              data.each do |item|
                item = item.deep_symbolize_keys
                puts item[:titles][:canonical].titleize
        
        
        Severity: Minor
        Found in lib/anidb_category_import/category_importer.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_for has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def auto_query_for(field, value)
            case value
            when String, Numeric, Date
              { match: { field => value } }
            when Range
        Severity: Minor
        Found in app/services/search_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 decrement has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def decrement(user, library_entry)
                record = user.stats.find_by(type: "Stat::#{media_type}FavoriteYear")
        
                return unless record
                return if record.stats_data['total_media'].nil?
        Severity: Minor
        Found in app/models/concerns/stat/favorite_year.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_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/manga_search_service.rb - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language