assemblymade/coderwall

View on GitHub
app/models/concerns/team_analytics.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Method aggregate_visitors has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def aggregate_visitors(since = 0)
      aggregate = {}
      visitors(since).map do |visitor|
        user_id = visitor[:user_id].to_i
        aggregate[user_id] ||= visitor
Severity: Minor
Found in app/models/concerns/team_analytics.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 record_exit has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def record_exit(viewer, exit_url, exit_target_type, furthest_scrolled, time_spent)
Severity: Minor
Found in app/models/concerns/team_analytics.rb - About 35 mins to fix

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

        def visitors(since = 0)
          detailed_visitors = self.detailed_visitors
          first_detailed_visit = detailed_visitors.last.nil? ? updated_at : detailed_visitors.first[:visited_at]
          self.detailed_visitors(since) + simple_visitors(since == 0 ? first_detailed_visit.to_i : since)
        end
    Severity: Minor
    Found in app/models/concerns/team_analytics.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