hummingbird-me/kitsu-server

View on GitHub

Showing 98 of 164 total issues

Method feed_visible? has 26 lines of code (exceeds 25 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 1 hr to fix

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

          def processable(column, pipeline)
            processed_column = "processed_#{column}"
            memoized = "@#{processed_column}"
      
            define_method(processed_column) do
      Severity: Minor
      Found in app/models/concerns/content_processable.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 complete_stream_activity has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def complete_stream_activity
          stream_activity&.tap do |activity|
            activity.actor ||= user if respond_to?(:user)
            activity.object ||= self
            activity.foreign_id ||= activity.object
      Severity: Minor
      Found in app/models/concerns/with_activity.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?
          # admins are allowed to update comments on locked posts
      Severity: Minor
      Found in app/policies/comment_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

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

        def validate_each(record, attr, value)
          if value.respond_to?(:each)
            value.each do |v|
              error = validate_value(v)
              record.errors.add(attr, message: error) if error
      Severity: Minor
      Found in app/validators/country_code_validator.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