diaspora/diaspora

View on GitHub

Showing 123 of 4,475 total issues

Function _render has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  _render: function(locale, items, views) {
    var originalItems = items.slice();

    if(views && typeof views.count !== "undefined") {
      items.push(locale.pluralizationKey(views.count));
Severity: Minor
Found in app/assets/javascripts/helpers/i18n.js - 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 change_email has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def change_email(user_data)
    if AppConfig.mail.enable?
      @user.unconfirmed_email = user_data[:email]
      if @user.save
        @user.send_confirm_email
Severity: Minor
Found in app/controllers/users_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

Function collectionOptions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  collectionOptions :function(){
    var order = this.sortOrder();
    return {
      comparator: function(item1, item2) {
        if (item1[order]() < item2[order]()) { return 1; }
Severity: Minor
Found in app/assets/javascripts/app/models/stream.js - 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 a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def perform
      # Queue users for removal due to inactivity
      if AppConfig.settings.maintenance.remove_old_users.enable?
        users = User.where("last_seen < ? and locked_at is null and remove_after is null", 
          Time.now - (AppConfig.settings.maintenance.remove_old_users.after_days.to_i).days)
Severity: Minor
Found in app/workers/queue_users_for_removal.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 local_recipients has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def local_recipients
    recipients.each do |recipient|
      if recipient.local?
        unless recipient.owner.contacts.where(person_id: author.id).any? ||
            (author.owner && author.owner.podmin_account?)
Severity: Minor
Found in app/models/conversation.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

Function setupBloodhound has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  setupBloodhound: function(options) {
    var bloodhoundOptions = {
      datumTokenizer: function(datum) {
        // hashtags
        if(typeof datum.handle === "undefined") { return [datum.name]; }
Severity: Minor
Found in app/assets/javascripts/app/views/search_base_view.js - 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 a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def perform!
    raise "already performed" if performed?
    validate_sender if locally_initiated?

    ActiveRecord::Base.transaction do
Severity: Minor
Found in app/models/account_migration.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def initialize(user, klass, key, id, conditions={})
Severity: Minor
Found in lib/evil_query.rb - About 35 mins to fix

    Method perform has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def perform(user_id, retraction_class, retraction_data, recipient_ids, opts)
    Severity: Minor
    Found in app/workers/deferred_retraction.rb - About 35 mins to fix

      Method perform has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def perform(sender_id, obj_str, urls, xml, retry_count=0)
      Severity: Minor
      Found in app/workers/send_public.rb - About 35 mins to fix

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

              private_class_method def self.ignore_existing_guid(klass, guid, author)
                yield unless klass.where(guid: guid, author_id: author.id).exists?
              rescue => e
                raise e unless load_from_database(klass, guid, author)
                logger.warn "ignoring error on receive #{klass}:#{guid}: #{e.class}: #{e.message}"
        Severity: Minor
        Found in lib/diaspora/federation/receive.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 share_with has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def share_with(person, aspect)
              return if blocks.where(person_id: person.id).exists?
        
              contact = contacts.find_or_initialize_by(person_id: person.id)
              return false unless contact.valid?
        Severity: Minor
        Found in app/models/user/connecting.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 account_deletion has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.account_deletion(entity)
                person = author_of(entity)
                AccountDeletion.create!(person: person) unless AccountDeletion.where(person: person).exists?
              rescue => e # rubocop:disable Lint/RescueWithoutErrorClass
                raise e unless AccountDeletion.where(person: person).exists?
        Severity: Minor
        Found in lib/diaspora/federation/receive.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 destroy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def destroy
            if params[:user] && params[:user][:current_password] && current_user.valid_password?(params[:user][:current_password])
              current_user.close_account!
              sign_out current_user
              redirect_to(new_user_session_path(format: request[:format]), notice: I18n.t("users.destroy.success"))
        Severity: Minor
        Found in app/controllers/users_controller.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 destroy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def destroy
            @vis = ConversationVisibility.where(:person_id => current_user.person.id,
                                                :conversation_id => params[:conversation_id]).first
            if @vis
              participants = @vis.conversation.participants.count
        Severity: Minor
        Found in app/controllers/conversation_visibilities_controller.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 mentionable has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def mentionable
            respond_to do |format|
              format.json {
                if params[:id].present? && params[:q].present?
                  render json: post_service.mentionable_in_comment(params[:id], params[:q])
        Severity: Minor
        Found in app/controllers/posts_controller.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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def create
            @aspect = current_user.aspects.build(aspect_params)
            aspecting_person_id = params[:person_id]
        
            if @aspect.save
        Severity: Minor
        Found in app/controllers/aspects_controller.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_user has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def update_user(user_data)
            if user_data[:email_preferences]
              change_email_preferences(user_data)
            elsif user_data[:language]
              change_language(user_data)
        Severity: Minor
        Found in app/controllers/users_controller.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 fetch_and_save_opengraph_data! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def fetch_and_save_opengraph_data!
            object = OpenGraphReader.fetch!(self.url)
        
            return unless object
        
        
        Severity: Minor
        Found in app/models/open_graph_cache.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_user_preferences has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def update_user_preferences(pref_hash)
            if self.disable_mail
              UserPreference::VALID_EMAIL_TYPES.each{|x| self.user_preferences.find_or_create_by(email_type: x)}
              self.disable_mail = false
              self.save
        Severity: Minor
        Found in app/models/user.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