twitter/twitter-cldr-rb

View on GitHub

Showing 175 of 209 total issues

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

      def property_values_for(property_name)
        if property_values.include?(property_name)
          return property_values[property_name]
        end

Severity: Minor
Found in lib/twitter_cldr/shared/properties_database.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 remove_illegal_hyphens has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def remove_illegal_hyphens(break_weights, text)
        break_weights.map.with_index do |break_weight, idx|
          next break_weight if idx.zero?
          next 0 if no_hyphen.include?(text[idx - 1])
          break_weight
Severity: Minor
Found in lib/twitter_cldr/shared/hyphenator.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 normalize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def normalize(property_name, property_value = nil)
        candidates = find_property_name_candidates(property_name)

        if property_value
          name, value = resolve_candidates(candidates, property_value)
Severity: Minor
Found in lib/twitter_cldr/shared/property_normalizer.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 round_to has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def round_to(number, precision, rounding = 0)
        factor = 10 ** precision
        result = number.is_a?(BigDecimal) ?
          ((number * factor).fix / factor) :
          ((number * factor).round.to_f / factor)
Severity: Minor
Found in lib/twitter_cldr/formatters/numbers/number_formatter.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 boundary_split has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def boundary_split(text_sample, boundaries)
        eos = text_sample.size

        boundaries = [*boundaries]
        boundaries.unshift(0) unless boundaries.first == 0
Severity: Minor
Found in lib/twitter_cldr/resources/segment_tests_importer.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 precision_from has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def precision_from(num)
        return 0 if num.is_a?(BigDecimal) && num.fix == num
        parts = (num.is_a?(BigDecimal) ? num.to_s("F") : num.to_s ).split(".")
        parts.size == 2 ? parts[1].size : 0
      end
Severity: Minor
Found in lib/twitter_cldr/formatters/numbers/number_formatter.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 alias_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def alias_for(alias_tag)
        doc.xpath("//alias/#{alias_tag}").inject({}) do |ret, alias_data|
          if replacement_attr = alias_data.attribute('replacement')
            replacement = replacement_attr.value

Severity: Minor
Found in lib/twitter_cldr/resources/aliases_importer.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 import_dictionary_file has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def import_dictionary_file(dictionary_file)
        source_url = url_for(dictionary_file)
        source = URI.open(source_url).read
        lines = source.split("\n")
        trie = TwitterCldr::Utils::Trie.new
Severity: Minor
Found in lib/twitter_cldr/resources/segment_dictionaries_importer.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 each_property_pair has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def each_property_pair
        if block_given?
          property_names.each do |property_name|
            if property_values = property_values_for(property_name)
              property_values.each do |property_value|
Severity: Minor
Found in lib/twitter_cldr/shared/properties_database.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 encode_trie has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def encode_trie(trie)
        arr = [].tap do |results|
          iter = trie.iterator

          while iter.hasNext
Severity: Minor
Found in lib/twitter_cldr/resources/segment_rules_importer.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 import_iso_639 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def import_iso_639(result = {})
        File.open(source_path_for(ISO_639_FILE)) do |file|
          lines = file.each_line
          lines.next # skip header

Severity: Minor
Found in lib/twitter_cldr/resources/language_codes_importer.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 reset_locale_fallbacks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def reset_locale_fallbacks
      locale_fallbacks.clear
      TwitterCldr.register_locale_fallback(lambda { I18n.locale if defined?(I18n) && I18n.respond_to?(:locale) })
      TwitterCldr.register_locale_fallback(lambda { FastGettext.locale if defined?(FastGettext) && FastGettext.respond_to?(:locale) })
    end
Severity: Minor
Found in lib/twitter_cldr.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

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

Severity
Category
Status
Source
Language