twitter/twitter-cldr-rb

View on GitHub
lib/twitter_cldr/collation/sort_key_builder.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method append_primary_bytes has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

      def append_primary_bytes
        @last_leading_byte = nil

        @collation_elements.each do |collation_element|
          bytes = integer_to_bytes_array(level_weight(collation_element, PRIMARY_LEVEL))
Severity: Minor
Found in lib/twitter_cldr/collation/sort_key_builder.rb - About 3 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 init_tertiary_constants has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def init_tertiary_constants
        @case_switch = @case_first == :upper ? CASE_SWITCH : NO_CASE_SWITCH

        if @case_first
          @tertiary_mask     = KEEP_CASE_MASK
Severity: Minor
Found in lib/twitter_cldr/collation/sort_key_builder.rb - About 1 hr to fix

    Method init_tertiary_constants has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def init_tertiary_constants
            @case_switch = @case_first == :upper ? CASE_SWITCH : NO_CASE_SWITCH
    
            if @case_first
              @tertiary_mask     = KEEP_CASE_MASK
    Severity: Minor
    Found in lib/twitter_cldr/collation/sort_key_builder.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 append_tertiary_byte has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def append_tertiary_byte(tertiary)
            if tertiary == @tertiary_common
              @common_count += 1
            else
              if @tertiary_common == TERTIARY_COMMON_NORMAL && @tertiary_common < tertiary
    Severity: Minor
    Found in lib/twitter_cldr/collation/sort_key_builder.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def initialize(collation_elements, options = {})
            raise ArgumentError, "second argument should be an options hash, not `#{options}`. Do you mean `:case_first => #{options}`?" unless options.kind_of? Hash
    
            case_first = options[:case_first]
            raise ArgumentError, "invalid case-first options '#{case_first.inspect}'" unless VALID_CASE_FIRST_OPTIONS.include?(case_first)
    Severity: Minor
    Found in lib/twitter_cldr/collation/sort_key_builder.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 build_bytes_array has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def build_bytes_array
            @bytes_array = []
    
            append_primary_bytes
            append_secondary_bytes unless @maximum_level && (@maximum_level < 2)
    Severity: Minor
    Found in lib/twitter_cldr/collation/sort_key_builder.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