twitter/twitter-cldr-rb

View on GitHub

Showing 209 of 209 total issues

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

      def symbols
        doc.xpath('//ldml/numbers/symbols').each_with_object({}) do |symbols_node, symbols_result|
          number_system = if ns_node = symbols_node.attribute('numberSystem')
            ns_node.value
          else
Severity: Minor
Found in lib/twitter_cldr/resources/number_formats_importer.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 format has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def format(number, options = {})
          rule_group_name, rule_set_name = *if options[:rule_group].nil? && options[:rule_set].nil?
            [DEFAULT_SPELLOUT_OPTIONS[:rule_group], DEFAULT_SPELLOUT_OPTIONS[:rule_set]]
          else
            [options[:rule_group], options[:rule_set]]
Severity: Minor
Found in lib/twitter_cldr/formatters/numbers/rbnf.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 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

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                module Resources
                  module Properties
              
                    class PropListImporter < PropertyImporter
                      DATA_FILE = 'ucd/PropList.txt'
              lib/twitter_cldr/resources/properties/derived_core_properties_importer.rb on lines 7..28
              lib/twitter_cldr/resources/properties/emoji_importer.rb on lines 7..28

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 47.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                module Resources
                  module Properties
              
                    class EmojiImporter < PropertyImporter
                      DATA_FILE = 'ucd/emoji/emoji-data.txt'
              Severity: Major
              Found in lib/twitter_cldr/resources/properties/emoji_importer.rb and 2 other locations - About 1 hr to fix
              lib/twitter_cldr/resources/properties/derived_core_properties_importer.rb on lines 7..28
              lib/twitter_cldr/resources/properties/prop_list_importer.rb on lines 7..28

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 47.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                module Resources
                  module Properties
              
                    class DerivedCorePropertiesImporter < PropertyImporter
                      DATA_FILE = 'ucd/DerivedCoreProperties.txt'
              lib/twitter_cldr/resources/properties/emoji_importer.rb on lines 7..28
              lib/twitter_cldr/resources/properties/prop_list_importer.rb on lines 7..28

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 47.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              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

              Severity
              Category
              Status
              Source
              Language