hackedteam/rcs-db

View on GitHub
lib/rcs-aggregator/peer.rb

Summary

Maintainability
C
1 day
Test Coverage

Method extract_chat has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def self.extract_chat(ev)
    data = []

    # "peer" attribute was present before 9.0.0
    # than has been replaced by "from" and "rcpt"
Severity: Minor
Found in lib/rcs-aggregator/peer.rb - About 2 hrs 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 extract_call has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def self.extract_call(ev)
    data = []
    versus = ev.data['incoming'] == 1 ? :in : :out
    hash = {:time => ev.da, :versus => versus, :type => ev.data['program'].downcase.to_sym, :size => ev.data['duration'].to_i}
    bidirectional = hash[:type] == :skype
Severity: Minor
Found in lib/rcs-aggregator/peer.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 create_suggested_peer has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.create_suggested_peer(target_id, params)
    time = Time.parse(params[:day])
    peer = params[:data][:peer]
    type = params[:type]
    versus = params[:data][:versus]
Severity: Minor
Found in lib/rcs-aggregator/peer.rb - About 1 hr to fix

    Method extract_chat has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.extract_chat(ev)
        data = []
    
        # "peer" attribute was present before 9.0.0
        # than has been replaced by "from" and "rcpt"
    Severity: Minor
    Found in lib/rcs-aggregator/peer.rb - About 1 hr to fix

      Method create_suggested_peer has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.create_suggested_peer(target_id, params)
          time = Time.parse(params[:day])
          peer = params[:data][:peer]
          type = params[:type]
          versus = params[:data][:versus]
      Severity: Minor
      Found in lib/rcs-aggregator/peer.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

      Avoid too many return statements within this method.
      Open

          return data
      Severity: Major
      Found in lib/rcs-aggregator/peer.rb - About 30 mins to fix

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

          def self.extract_sms_or_mms ev
            data = []
            hash = {:time => ev.da, type: ev.data['type'].downcase.to_sym, size: ev.data['content'].length}
        
            if ev.data['incoming'] == 1
        Severity: Minor
        Found in lib/rcs-aggregator/peer.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