ging/social_stream

View on GitHub

Showing 172 of 172 total issues

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

  def create_ability_file
    ability_code = [
      "# Generator social_stream:install has modified this file. Please,",   #0
      "# check everything is working ok, specially if the former `Ability`", #1
      "# class inherited from another class or included another module",     #2
Severity: Minor
Found in base/lib/generators/social_stream/base/install_generator.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 find_or_create_for_oauth has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def find_or_create_for_oauth(info, signed_in_user = nil)
      auth = Authentication.find_by_provider_and_uid(info["provider"], info["uid"])

      if auth.present?
        if signed_in_user.present? && auth.user != signed_in_user
Severity: Minor
Found in base/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 notify has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def notify
    return true unless notificable?
    #Avaible verbs: follow, like, make-friend, post, update, join

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

  def title_of(act_obj)
    if act_obj.is_a? Comment
      'Re: ' + title_of(act_obj.parent_post)
    elsif act_obj.respond_to? :title and (not act_obj.title.nil?)
      act_obj.title.truncate(30, :separator => ' ')
Severity: Minor
Found in base/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 defaults_for has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def defaults_for(actor)
      subject_type = actor.subject.class.to_s.underscore

      cfg_rels = SocialStream.custom_relations.with_indifferent_access[subject_type]

Severity: Minor
Found in base/app/models/relation/custom.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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        I18n.t('notification.update.'+ receiver.subject.class.to_s.underscore, 
              :sender => sender_name,
              :whose => I18n.t('notification.whose.'+ receiver.subject.class.to_s.underscore,
                               :receiver => receiver_name),
              :thing => I18n.t(direct_object.class.to_s.underscore+'.one'))
Severity: Minor
Found in base/app/models/activity.rb and 1 other location - About 35 mins to fix
base/app/models/activity.rb on lines 355..359

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 34.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

          I18n.t('notification.like.'+ receiver.subject.class.to_s.underscore, 
                :sender => sender_name,
                :whose => I18n.t('notification.whose.'+ receiver.subject.class.to_s.underscore,
                            :receiver => receiver_name),
                :thing => I18n.t(direct_object.class.to_s.underscore+'.name'))
Severity: Minor
Found in base/app/models/activity.rb and 1 other location - About 35 mins to fix
base/app/models/activity.rb on lines 378..382

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 34.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Avoid too many return statements within this function.
Open

            return parseWord(subwords[0]) + youtubeLink + parseWord(subwords[1])
Severity: Major
Found in presence/app/assets/javascripts/presence_parser.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

          return word
    Severity: Major
    Found in presence/app/assets/javascripts/presence_parser.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                return parseWord(subwords[0]) + imageLink + parseWord(subwords[1])
      Severity: Major
      Found in presence/app/assets/javascripts/presence_parser.js - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                      return ( params[:password] and params[:password] == SocialStream::Presence.xmpp_server_password )
        Severity: Major
        Found in presence/lib/social_stream/presence/xmpp_server_order.rb - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

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

            Avoid too many return statements within this function.
            Open

                      return parseWord(subwords[0]) + link + parseWord(subwords[1])
            Severity: Major
            Found in presence/app/assets/javascripts/presence_parser.js - About 30 mins to fix

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                  create_table "documents", :force => true do |t|
                    t.string   "type"
                    t.integer  "activity_object_id"
                    t.datetime "created_at"
                    t.datetime "updated_at"
              base/db/migrate/20120326083509_create_social_stream.rb on lines 200..208
              places/db/migrate/20130114184300_create_social_stream_places.rb on lines 28..36

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 32.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                  create_table "relations", :force => true do |t|
                    t.integer  "actor_id"
                    t.string   "type"
                    t.string   "name"
                    t.datetime "created_at"
              Severity: Minor
              Found in base/db/migrate/20120326083509_create_social_stream.rb and 2 other locations - About 30 mins to fix
              documents/db/migrate/20120208143721_create_social_stream_documents.rb on lines 4..12
              places/db/migrate/20130114184300_create_social_stream_places.rb on lines 28..36

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 32.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                  create_table "addresses", :force => true do |t|
                    t.string   "formatted"
                    t.string   "streetAddress"
                    t.string   "locality"
                    t.string   "region"
              base/db/migrate/20120326083509_create_social_stream.rb on lines 200..208
              documents/db/migrate/20120208143721_create_social_stream_documents.rb on lines 4..12

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 32.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                def suggestion
                  @contact = current_subject.suggestions.first
              
                  respond_to do |format|
                    format.html { @contact.present? ? render(partial: @contact) : render(text: "") }
              Severity: Minor
              Found in base/app/controllers/contacts_controller.rb and 1 other location - About 25 mins to fix
              base/app/controllers/contacts_controller.rb on lines 87..92

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 31.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                def pending
                  @contact = current_subject.pending_contacts.last
              
                  respond_to do |format|
                    format.html { @contact.present? ? render(partial: @contact) : render(text: "") }
              Severity: Minor
              Found in base/app/controllers/contacts_controller.rb and 1 other location - About 25 mins to fix
              base/app/controllers/contacts_controller.rb on lines 78..83

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 31.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

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

                    def current_subject_from_params
                      return unless params[:s].present?
              
                      subject = Actor.find_by_slug!(params[:s]).subject
              
              
              Severity: Minor
              Found in base/lib/social_stream/controllers/helpers.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 find_or_initialize_with_error_by_email has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def find_or_initialize_with_error_by_email(value, error)
                    if value.present?
                      record = find_by_email(value)
                    end
                    
              Severity: Minor
              Found in base/app/models/user.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