hummingbird-me/kitsu-server

View on GitHub

Showing 98 of 164 total issues

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

    def aozora_user
      return unless ao_importable?

      return @aozora_user if @aozora_user
      return Zorro::DB::User.find(_id: @user.ao_id).first if @user
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 validate_each has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_each(record, attribute, value)
    ama = if value.respond_to?(:post)
            AMA.for_original_post(value.post).first
          elsif value.is_a?(Post)
            AMA.for_original_post(value).first
Severity: Minor
Found in app/validators/active_ama_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

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

      def sign_in
        return @signed_in unless @signed_in.nil?

        @agent.get('https://myanimelist.net/login.php') do |login_page|
          # Already logged in!
Severity: Minor
Found in app/services/list_sync/my_anime_list/login.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

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

  def follow(source, target)
    return false unless ENV['STREAMLOG_REDIS_URL']
    return unless log_follow?(source, target)
    source = rewrite_feed(*source)
    target = rewrite_feed(*target)
Severity: Minor
Found in lib/stream_log.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 progress_limit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def progress_limit
    return unless progress
    progress_cap = media&.progress_limit
    default_cap = [media&.default_progress_limit, 50].compact.max

Severity: Minor
Found in app/models/library_entry.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 auto_query_for has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def auto_query_for(field, value)
    value = value.first if value.is_a?(Array) && value&.count == 1

    case value
    when Range
Severity: Minor
Found in app/services/typesense_search_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 is_owner? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def is_owner? # rubocop:disable Naming/PredicateName
    return false unless user && record.respond_to?(:user)
    return false unless record.user_id == user.id
    return false if record.user_id_was && record.user_id_was != user.id
    true
Severity: Minor
Found in app/policies/application_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 fill_defaults has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def fill_defaults(activity)
    activity.tap do |act|
      act.actor ||= user
      act.object ||= library_entry
      act.to ||= []
Severity: Minor
Found in app/services/media_activity_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 missing_engagement_ids has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def missing_engagement_ids
    data = @entries.completed.joins(JOINS).group(GROUP).pluck(PLUCK)

    data.each_with_object(
      attributes: [],
Severity: Minor
Found in app/services/library_gaps_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 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/language_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

Avoid too many return statements within this method.
Open

      return false if banned_from_group?
Severity: Major
Found in app/policies/comment_like_policy.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

        return :unreleased if start_date&.future?
    Severity: Major
    Found in app/models/concerns/media.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return false if group.closed? && !member?
      Severity: Major
      Found in app/policies/post_like_policy.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return false if group.closed? && !member?
        Severity: Major
        Found in app/policies/comment_policy.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

              return false if user.flags.banned?
          Severity: Major
          Found in app/policies/post_policy.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                  return false if banned_from_group?
            Severity: Major
            Found in app/policies/post_policy.rb - About 30 mins to fix
              Severity
              Category
              Status
              Source
              Language