diaspora/diaspora

View on GitHub

Showing 123 of 4,443 total issues

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

  def index
    conditions = {:recipient_id => current_user.id}
    if params[:type] && types.has_key?(params[:type])
      conditions[:type] = types[params[:type]]
    end
Severity: Minor
Found in app/controllers/notifications_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 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

Function podUpToDate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  podUpToDate: function() {
    var podVersion = gon.podVersion.split(/\.|\-/).map(Number);
    if(this.latestVersion.length < 4 || podVersion.length < 4) { return null; }
    for(var i = 0; i < 4; i++) {
      if(this.latestVersion[i] < podVersion[i]) { return true; }
Severity: Minor
Found in app/assets/javascripts/app/pages/admin_dashboard.js - 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_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

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

Avoid too many return statements within this function.
Open

                return true;
Severity: Major
Found in app/assets/javascripts/app/helpers/direction_detector.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                    return true;
    Severity: Major
    Found in app/assets/javascripts/app/helpers/direction_detector.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return 0;
      Severity: Major
      Found in app/assets/javascripts/app/models/stream.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              return false;
        Severity: Major
        Found in app/assets/javascripts/app/helpers/direction_detector.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                          return true;
          Severity: Major
          Found in app/assets/javascripts/app/helpers/direction_detector.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                            return true;
            Severity: Major
            Found in app/assets/javascripts/app/helpers/direction_detector.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                              return true;
              Severity: Major
              Found in app/assets/javascripts/app/helpers/direction_detector.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                return true;
                Severity: Major
                Found in app/assets/javascripts/app/helpers/direction_detector.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                  return true;
                  Severity: Major
                  Found in app/assets/javascripts/app/helpers/direction_detector.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                    return true;
                    Severity: Major
                    Found in app/assets/javascripts/app/helpers/direction_detector.js - About 30 mins to fix

                      Method find_public! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def find_public!(id_or_guid)
                          Post.where(post_key(id_or_guid) => id_or_guid).first.tap do |post|
                            raise ActiveRecord::RecordNotFound, "could not find a post with id #{id_or_guid}" unless post
                            raise Diaspora::NonPublic unless post.public?
                          end
                      Severity: Minor
                      Found in app/services/post_service.rb - About 25 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 use_code has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def self.use_code(code)
                              return unless code
                              auth = find_by(code: code)
                              return unless auth
                              if auth.code_used
                      Severity: Minor
                      Found in app/models/api/openid_connect/authorization.rb - About 25 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