twitter/twitter-cldr-rb

View on GitHub

Showing 175 of 209 total issues

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

      def sample(sample_size = 1)
        sample_set = Set.new
        counter = 1

        until sample_set.size == sample_size
Severity: Minor
Found in lib/twitter_cldr/shared/postal_code_generator.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 parse_number has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def parse_number(number, options = {})
        precision = options[:precision] || precision_from(number)
        rounding = options[:rounding] || 0

        if number.is_a? BigDecimal
Severity: Minor
Found in lib/twitter_cldr/formatters/numbers/number_formatter.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 deep_merge! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def deep_merge!(first, second)
        if first.is_a?(Hash) && second.is_a?(Hash)
          second.each { |key, val| first[key] = deep_merge!(first[key], val) }
        elsif first.is_a?(Array) && second.is_a?(Array)
          second.each_with_index { |elem, index| first[index] = deep_merge!(first[index], elem) }
Severity: Minor
Found in lib/twitter_cldr/utils.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 traverse_hash has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def traverse_hash(hash, path, &block)
        return if path.empty?

        path.inject(hash) do |current, key|
          return unless current.is_a?(Hash)
Severity: Minor
Found in lib/twitter_cldr/utils.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 expand has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def expand(pattern)
        if pattern.is_a?(Symbol)
          # symbols mean another path was given
          path = pattern.to_s.split(".").map(&:to_sym)
          data = data_reader.pattern_at_path(path)
Severity: Minor
Found in lib/twitter_cldr/tokenizers/pattern_tokenizer.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 tailoring_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def tailoring_data(locale)
        doc = get_collation_xml(locale).at_xpath('//collations')

        collations = doc.at_xpath('//collations')

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

      def era(date, pattern, length, options = {})
        choices = case length
          when 0
            ["", ""]
          when 1..3
Severity: Minor
Found in lib/twitter_cldr/formatters/calendars/date_time_formatter.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 substitute_variables has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def substitute_variables(tokens, symbol_table)
        return tokens unless symbol_table
        tokens.inject([]) do |ret, token|
          if token.type == :variable && sub = symbol_table.fetch(token.value)
            # variables can themselves contain references to other variables
Severity: Minor
Found in lib/twitter_cldr/parsers/unicode_regex_parser.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 deep_symbolize_keys has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def deep_symbolize_keys(arg)
        case arg
          when Array
            arg.map { |elem| deep_symbolize_keys(elem) }
          when Hash
Severity: Minor
Found in lib/twitter_cldr/utils.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 tokenize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def tokenize(text)
        text.split(splitter).inject([]) do |ret, token_text|
          recognizer = recognizers.find do |recognizer|
            recognizer.recognizes?(token_text)
          end
Severity: Minor
Found in lib/twitter_cldr/tokenizers/tokenizer.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 dump has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def dump(obj, opts = {})
          @options = opts.dup
          @options[:indent_size] = 2          if @options[:indent_size].to_i <= 0
          @options[:minimum_block_length] = 0 if @options[:minimum_block_length].to_i <= 0
          @options.update(
Severity: Minor
Found in lib/twitter_cldr/utils/yaml.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 formats_from_node has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def formats_from_node(formats_node, type, number_system)
        formats_node.xpath("#{type}FormatLength").each_with_object({}) do |format_length_node, format_result|
          format_nodes = format_length_node.xpath("#{type}Format")

          format_key = format_length_node.attribute('type')
Severity: Minor
Found in lib/twitter_cldr/resources/number_formats_importer.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 find_match_comment_after has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def find_match_comment_after(idx)
          loop do
            return nil if idx > schema.size

            if schema[idx].strip.start_with?('<!--@MATCH')
Severity: Minor
Found in lib/twitter_cldr/resources/cldr_dtd.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 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

Avoid too many return statements within this method.
Open

          return true, true, is_one_line?(str), is_one_plain_line?(str)
Severity: Major
Found in lib/twitter_cldr/utils/yaml.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

              return code_point + NON_CJK_OFFSET if code_point < CJK_A_BASE
    Severity: Major
    Found in lib/twitter_cldr/collation/implicit_collation_elements.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                  return mz_name
      Severity: Major
      Found in lib/twitter_cldr/timezones/generic_location.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return code_point                                                 if code_point < CJK_B_LIMIT # non-BMP-CJK
        Severity: Major
        Found in lib/twitter_cldr/collation/implicit_collation_elements.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return code_point + NON_CJK_OFFSET # non-CJK
          Severity: Major
          Found in lib/twitter_cldr/collation/implicit_collation_elements.rb - About 30 mins to fix
            Severity
            Category
            Status
            Source
            Language