hackedteam/rcs-db

View on GitHub
lib/rcs-intelligence/infer.rb

Summary

Maintainability
A
2 hrs
Test Coverage

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

        def normalize_interval(interval, timezone = 0)
          return unless interval.respond_to?(:[])

          start, stop = interval['start'], interval['end']
          shift = timezone.to_i * 3600
Severity: Minor
Found in lib/rcs-intelligence/infer.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 group_and_count_positions_within has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def group_and_count_positions_within(ranges)
          dist = week_distribution
          return [] if dist.keys.size < MIN_DAYS

          grouped = {}
Severity: Minor
Found in lib/rcs-intelligence/infer.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 week_distribution has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def week_distribution
          results = {}

          each_aggregate do |aggregate|
            aggregate.info.each do |interval|
Severity: Minor
Found in lib/rcs-intelligence/infer.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 most_visited_place has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def most_visited_place(ranges)
          max_half_hour_per_week = ranges.inject(0) { |num, range| num += range.step(HALF_HOUR).size; num } * 7
          minimum_frequency = (35.0 / 100.0) * max_half_hour_per_week # 35%

          grouped = group_and_count_positions_within(ranges).last
Severity: Minor
Found in lib/rcs-intelligence/infer.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