twitter/twitter-cldr-rb

View on GitHub
lib/twitter_cldr/utils/range_set.rb

Summary

Maintainability
C
1 day
Test Coverage

Class RangeSet has 32 methods (exceeds 20 allowed). Consider refactoring.
Open

    class RangeSet

      include Enumerable

      attr_reader :ranges
Severity: Minor
Found in lib/twitter_cldr/utils/range_set.rb - About 4 hrs to fix

    Method rangify has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

            def rangify(list, compress = false)
              last_item = nil
    
              list.sort.inject([]) do |ret, item|
                if last_item
    Severity: Minor
    Found in lib/twitter_cldr/utils/range_set.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

    File range_set.rb has 264 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'set'
    
    module TwitterCldr
      module Utils
    
    
    Severity: Minor
    Found in lib/twitter_cldr/utils/range_set.rb - About 2 hrs to fix

      Method flatten has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def flatten
              return if ranges.size <= 1
      
              sorted_ranges = ranges.sort do |a, b|
                if is_numeric_range?(a) && is_numeric_range?(b)
      Severity: Minor
      Found in lib/twitter_cldr/utils/range_set.rb - About 55 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 includes_range? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def includes_range?(range)
              result = bsearch do |cur_range|
                fo = front_overlap?(cur_range, range)
                ro = rear_overlap?(cur_range, range)
      
      
      Severity: Minor
      Found in lib/twitter_cldr/utils/range_set.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 intersection has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def intersection(range_set)
              new_ranges = []
      
              range_set.ranges.each do |their_range|
                ranges.each do |our_range|
      Severity: Minor
      Found in lib/twitter_cldr/utils/range_set.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 to_a has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def to_a(compress = false)
              if compress
                ranges.map do |range|
                  if range.first == range.last
                    range.first
      Severity: Minor
      Found in lib/twitter_cldr/utils/range_set.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 subtract has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def subtract(range_set)
              return self if range_set.empty?
              remaining = range_set.ranges.dup
              current_ranges = ranges.dup
              new_ranges = []
      Severity: Minor
      Found in lib/twitter_cldr/utils/range_set.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