twitter/activerecord-reputation-system

View on GitHub
lib/reputation_system/models/reputation.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method update_reputation_value_with_updated_source has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def self.update_reputation_value_with_updated_source(rep, source, oldValue, newSize, weight, process)
      weight ||= 1 # weight is 1 by default.
      oldSize = rep.received_messages.size
      valueBeforeUpdate = oldSize > 0 ? rep.value : nil
      newValue = source.value
Severity: Minor
Found in lib/reputation_system/models/reputation.rb - About 1 hr 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 normalized_value has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def normalized_value
      if self.active == 1 || self.active == true
        max = ReputationSystem::Reputation.max(self.reputation_name, self.target_type)
        min = ReputationSystem::Reputation.min(self.reputation_name, self.target_type)
        if max && min
Severity: Minor
Found in lib/reputation_system/models/reputation.rb - About 1 hr 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_reputation_value_with_new_source has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.update_reputation_value_with_new_source(rep, source, weight, process)
      weight ||= 1 # weight is 1 by default.
      size = rep.received_messages.size
      valueBeforeUpdate = size > 0 ? rep.value : nil
      newValue = source.value
Severity: Minor
Found in lib/reputation_system/models/reputation.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 update_reputation_value_with_updated_source has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def self.update_reputation_value_with_updated_source(rep, source, oldValue, newSize, weight, process)
Severity: Minor
Found in lib/reputation_system/models/reputation.rb - About 45 mins to fix

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

          def self.update_reputation_value(receiver, sender, weight, process, oldValue)
    Severity: Minor
    Found in lib/reputation_system/models/reputation.rb - About 35 mins to fix

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

            def self.send_reputation_message_to_receiver(reputation_name, sender, target, scope, oldValue)
      Severity: Minor
      Found in lib/reputation_system/models/reputation.rb - About 35 mins to fix

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

              def self.initialize_reputation_value(receiver, target, process)
                name = receiver.reputation_name
                unless ReputationSystem::Network.is_primary_reputation?(target.class.name, name)
                  sender_defs = ReputationSystem::Network.get_reputation_def(target.class.name, name)[:source]
                  sender_defs.each do |sd|
        Severity: Minor
        Found in lib/reputation_system/models/reputation.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

        There are no issues that match your filters.

        Category
        Status