hummingbird-me/kitsu-server

View on GitHub

Showing 97 of 166 total issues

Method only_following has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def only_following(user_id)
      followed = Set.new(Follow.where(follower_id: user_id).pluck(:followed_id))
      select(0.5) do |act|
        user_id = act['actor'].split(':')[1].to_i
        is_followed = followed.include?(user_id)
Severity: Minor
Found in app/models/feed/activity_list.rb - About 55 mins 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 by_slug has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def by_slug(slug)
      record = where(slug: slug)
      return record if record.present?

      value = slug.is_a?(Array) ? slug.first : slug
Severity: Minor
Found in app/models/concerns/sluggable.rb - About 55 mins 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 generate_query has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def generate_query(filters)
      # For each queryable field, attempt to apply.  If there's no apply
      # specified, use auto_query to generate one.
      queries = @_query_fields.map do |field, opts|
        next unless filters.key?(field) # Skip if we don't have a filter
Severity: Minor
Found in app/resources/concerns/searchable_resource.rb - About 55 mins 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 generate_query has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def generate_query(filters)
      # For each queryable field, attempt to apply.  If there's no apply
      # specified, use auto_query to generate one.
      queries = @_query_fields.map do |field, opts|
        next unless filters.key?(field) # Skip if we don't have a filter
Severity: Minor
Found in app/resources/concerns/algolia_searchable_resource.rb - About 55 mins 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_sort has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def self.apply_sort(records, order_options, context = {})
    # For each requested sort option, decide whether to use the title sort logic
    order_options = order_options.map do |field, dir|
      [(TITLE_SORT =~ field ? :title : :other), field, dir]
    end
Severity: Minor
Found in app/resources/library_entry_resource.rb - About 55 mins 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 stream_activity has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def stream_activity
    to = []
    to << post.user.notifications unless post.user == user
    to << parent&.user&.notifications unless parent&.user == user
    to += mentioned_users.map(&:notifications)
Severity: Minor
Found in app/models/comment.rb - About 45 mins 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 increment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def increment(user, library_entry)
        record = user.stats.find_or_initialize_by(
          type: "Stat::#{media_type}FavoriteYear"
        )
        # set default to total and all_years if it doesn't exist
Severity: Minor
Found in app/models/concerns/stat/favorite_year.rb - About 45 mins 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 blocking has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def blocking(user_ids)
      blocked = Set.new(user_ids)
      select do |act|
        user_id = act['actor'].split(':')[1].to_i
        will_block = blocked.include?(user_id)
Severity: Minor
Found in app/models/feed/activity_list.rb - About 45 mins 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 8 (exceeds 5 allowed). Consider refactoring.
Open

    def update_in_batches(updates, of: 10000)
      relation = self
      relation = relation.reorder(batch_order).limit(of)
      batch_relation = relation
      updated_total = 0
Severity: Minor
Found in lib/update_in_batches.rb - About 45 mins 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 run! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def run!
        each_anime do |kitsu_id, anime|
          # Import Anime Mappings
          create_mapping('aozora', anime['_id'], kitsu_id)
          mal_id = anime['myAnimeListID']
Severity: Minor
Found in app/services/zorro/anime_mapper.rb - About 45 mins 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 results_for has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def results_for(key, limit = 5, offset = 0)
    results = []
    loop.with_index do |_, index|
      break if index > 5
      page = raw_results_for(key, limit, offset)
Severity: Minor
Found in app/services/trending_service.rb - About 45 mins 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 status has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def status
    return :tba if start_date.nil? && end_date.nil?
    return :finished if end_date&.past?
    return :current if start_date&.past? || start_date&.today?
    return :upcoming if start_date && start_date <= Date.today + 3.months
Severity: Minor
Found in app/models/concerns/media.rb - About 45 mins 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 feed_visible? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def feed_visible?
    case params[:group].sub(/_aggr\z/, '')
    when 'media'
      media_type, media_id = params[:id].split('-')
      return false unless %w[Manga Anime Drama].include?(media_type)
Severity: Minor
Found in app/controllers/feeds_controller.rb - About 45 mins 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 verify has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def verify
      mode = params['hub.mode']
      topic = params['hub.topic']
      challenge = params['hub.challenge']

Severity: Minor
Found in app/controllers/webhooks/youtube_controller.rb - About 45 mins 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 include? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def include?(key)
      return true if @whitelist.include?(key)
      # Magic match-handling code
      match = TITLE_SORT.match(key.to_s)
      return false unless match
Severity: Minor
Found in app/resources/library_entry_resource.rb - About 45 mins 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 perform has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def perform(namespace, half_life, user, id, weight)
Severity: Minor
Found in app/workers/trending_fanout_worker.rb - About 35 mins to fix

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

        def ao_importable?
          # No Conflict
          return true if kitsu_user.blank?
          # Post-conflict (chose Aozora)
          return false if kitsu_user.ao_imported
    Severity: Minor
    Found in app/services/zorro/user_conflict_detector.rb - About 35 mins 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 annotate_with_reason has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def annotate_with_reason(act)
        if act['target'].is_a?(Post)
          user_id = act['target'].user_id
          group_id = act['target'].target_group_id
          act['reason'] = 'media'
    Severity: Minor
    Found in app/services/feed_query_service.rb - About 35 mins 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_unused has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def strip_unused(activity_groups)
            activity_groups.each do |group|
              return activity_groups unless group['activities']
              next unless STRIPPED_VERBS.include?(group['verb'])
              group['activities'] = [group['activities'].first]
    Severity: Minor
    Found in app/models/feed/activity_list/page.rb - About 35 mins 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? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def update?
        return false unless user
        return false if user.has_role?(:banned)
        return true if can_administrate?
        return false if record.locked?
    Severity: Minor
    Found in app/policies/post_policy.rb - About 35 mins 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