hummingbird-me/kitsu-server

View on GitHub

Showing 162 of 163 total issues

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

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

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 true if group && has_group_permission?(:content)
    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 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 :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 banned_from_group?
            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/post_policy.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                      return false unless /[a-z]{2}(_[a-z]{2})?/.match?(title)
                Severity: Major
                Found in app/resources/library_entry_resource.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 banned_from_group?
                    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.has_role?(:banned)
                      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 false if group.closed? && !member?
                        Severity: Major
                        Found in app/policies/comment_like_policy.rb - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language