hummingbird-me/kitsu-server

View on GitHub

Showing 97 of 163 total issues

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

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

          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 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 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 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 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 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 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
            Severity
            Category
            Status
            Source
            Language