diaspora/diaspora

View on GitHub

Showing 124 of 4,444 total issues

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

  def initialize(url, result=Result.new)
    @url ||= url
    @result ||= result
    @uri ||= URI.parse(@url)
    raise AddressFailure,
Severity: Minor
Found in lib/connection_tester.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 object_link has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def object_link(note, actors_html)
    target_type = note.popup_translation_key
    opts = {actors: actors_html, count: note.actors.size}

    if note.respond_to?(:linked_object)
Severity: Minor
Found in app/helpers/notifications_helper.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 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 secret_token has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def secret_token
      if heroku?
        return ENV["SECRET_TOKEN"] if ENV["SECRET_TOKEN"]

        warn "FATAL: Running on Heroku with SECRET_TOKEN unset"
Severity: Minor
Found in lib/configuration_methods.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 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 new has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def new
    if params[:person_id] && fetch_person(params[:person_id])
      @aspect = :profile
      @contact = current_user.contact_for(@person)
      if @contact
Severity: Minor
Found in app/controllers/status_messages_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

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

                            def render_mentions
                              unless options[:disable_hovercards] || options[:mentioned_people].empty?
                                @message = Diaspora::Mentionable.format message, options[:mentioned_people]
                              end
                      
                      
                      Severity: Minor
                      Found in lib/diaspora/message_renderer.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