twitter/twitter-cldr-rb

View on GitHub

Showing 175 of 209 total issues

Method traverse_finding_best_fit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def traverse_finding_best_fit(path_pattern, path, hash = resource)
        if path_pattern.empty?
          result = traverse_following_aliases(path, hash)
          return result if result.is_a?(String)
        else
Severity: Minor
Found in lib/twitter_cldr/data_readers/number_data_reader.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 parse has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def parse(number_text, options = {})
        options[:strict] = true unless options.include?(:strict)
        group, decimal = separators(options[:strict])
        tokens = tokenize(number_text, group, decimal)

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

      def calculate_unit(seconds, options = {})
        approximate = options[:approximate]
        approximate = false if approximate.nil?
        multiplier = approximate ? APPROXIMATE_MULTIPLIER : 1

Severity: Minor
Found in lib/twitter_cldr/localized/localized_timespan.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 run_conformance_tests_with_icu has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def run_conformance_tests_with_icu(conformance_file, test_lines)
        boundary_type = case File.basename(conformance_file)
          when 'WordBreakTest.txt'
            :word
          when 'SentenceBreakTest.txt'
Severity: Minor
Found in lib/twitter_cldr/resources/segment_tests_importer.rb - About 1 hr to fix

    Method evaluate has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def evaluate(node)
              case node
                when UnaryOperator, BinaryOperator
                  case node.operator
                    when :negate
    Severity: Minor
    Found in lib/twitter_cldr/parsers/unicode_regex/character_class.rb - About 1 hr to fix

      Method preprocess has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def preprocess(tokens)
              result = []
              i = 0
      
              while i < tokens.size
      Severity: Minor
      Found in lib/twitter_cldr/parsers/unicode_regex_parser.rb - About 1 hr to fix

        Method fractional_rule_for has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def fractional_rule_for(number)
                  # the obvious way to do this (multiply the value being formatted
                  # by each rule's base value until you get an integral result)
                  # doesn't work because of rounding error.  This method is more
                  # accurate
        Severity: Minor
        Found in lib/twitter_cldr/formatters/numbers/rbnf/rule_set.rb - About 1 hr to fix

          Method import_dictionary has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def import_dictionary(path, locale)
                  options = {}
                  rules = []
          
                  File.foreach(path).with_index do |line, idx|
          Severity: Minor
          Found in lib/twitter_cldr/resources/hyphenation_importer.rb - About 1 hr to fix

            Method reorder_visually! has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def reorder_visually!
                    raise "No string given!" unless @string_arr
            
                    # Do this explicitly so we can also find the maximum depth at the
                    # same time.
            Severity: Minor
            Found in lib/twitter_cldr/shared/bidi.rb - About 1 hr to fix

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

                      def is_printable?(ucs_code)
                        # YAML 1.1 / 4.1.1.
                        (
                          [0x09, 0x0a, 0x0d, 0x85].include?(ucs_code)   ||
                          (ucs_code <=     0x7e && ucs_code >=    0x20) ||
              Severity: Minor
              Found in lib/twitter_cldr/utils/yaml.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 find_matching_rule_at has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def find_matching_rule_at(cursor)
                      indexed_match = find_matching_indexed_rule_at(cursor)
                      blank_key_match = find_matching_blank_key_rule_at(cursor)
              
                      if indexed_match
              Severity: Minor
              Found in lib/twitter_cldr/transforms/conversion_rule_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 string_type has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                      def string_type(str)
                        if str.respond_to?(:encoding) && (!str.valid_encoding? || str.encoding == Encoding::ASCII_8BIT)
                          return false, false, false, false
                        end
                        (ucs_codes = str.unpack('U*')) rescue (
              Severity: Minor
              Found in lib/twitter_cldr/utils/yaml.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 yaml_escape has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                      def yaml_escape(str)
                        # YAML 1.1 / 4.1.6.
                        str.gsub(/[^a-zA-Z0-9]/u) do |c|
                          ucs_code, = (c.unpack('U') rescue [??])
                          case
              Severity: Minor
              Found in lib/twitter_cldr/utils/yaml.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 lookup_code_point has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def lookup_code_point(code_point)
                      {}.tap do |properties|
                        each_property_pair do |property_name, property_value|
                          code_points = code_points_for_property(
                            property_name, property_value
              Severity: Minor
              Found in lib/twitter_cldr/shared/properties_database.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 generate_replacement has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                      def generate_replacement(number, rule, token)
                        if rule_set_name = token.rule_set_reference
                          RuleFormatter.format(
                            number,
                            rule_group.rule_set_for(rule_set_name),
              Severity: Minor
              Found in lib/twitter_cldr/formatters/numbers/rbnf/formatters.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 generate_test has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def generate_test
                      run_hash = {}
              
                      File.open(source_file, 'r').each_line do |ln|
                        cur_line = ln.strip
              Severity: Minor
              Found in lib/twitter_cldr/resources/bidi_test_importer.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 metadata has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def metadata
                      { aliases: {}, short_names: {} }.tap do |result|
                        doc.xpath("//ldmlBCP47/keyword/key[@name='tz']/type").each do |node|
                          alias_node = node.attribute('alias')
                          next unless alias_node
              Severity: Minor
              Found in lib/twitter_cldr/resources/bcp47_timezone_metadata_importer.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 format has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def format(tokens, number, options = {})
                      options[:currency] ||= "USD"
                      options[:locale] ||= :en
                      currency = TwitterCldr::Shared::Currencies.for_code(options[:currency], options[:locale])
                      currency ||= {
              Severity: Minor
              Found in lib/twitter_cldr/formatters/numbers/currency_formatter.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 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 preprocess has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def preprocess(tokens)
                      result = []
                      i = 0
              
                      while i < tokens.size
              Severity: Minor
              Found in lib/twitter_cldr/parsers/unicode_regex_parser.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

              Severity
              Category
              Status
              Source
              Language