twitter/twitter-cldr-rb

View on GitHub

Showing 175 of 209 total issues

Avoid too many return statements within this method.
Open

          return code_point - CJK_A_BASE + (CJK_LIMIT - CJK_BASE) + (CJK_COMPAT_USED_LIMIT - CJK_COMPAT_USED_BASE) if code_point < CJK_A_LIMIT
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                                                 if code_point < CJK_C_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                                                 if code_point < CJK_D_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                                if code_point < CJK_C_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 code_point + NON_CJK_OFFSET                                if code_point < CJK_D_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 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 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 partial_location_name_for(tz_metazone.metazone, mz_name)
                Severity: Major
                Found in lib/twitter_cldr/timezones/generic_location.rb - About 30 mins to fix

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

                        def subtract(range_set)
                          return self if range_set.empty?
                          remaining = range_set.ranges.dup
                          current_ranges = ranges.dup
                          new_ranges = []
                  Severity: Minor
                  Found in lib/twitter_cldr/utils/range_set.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 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 break_weights_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def break_weights_for(text)
                          break_weights = Array.new(text.size - 1, 0)
                  
                          text.each_char.with_index do |char, idx|
                            subtrie = trie.root
                  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 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 match has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                          def match(cursor)
                            if before_match = match_before(cursor)
                              if key_match = match_key(cursor, before_match)
                                if after_match = match_after(cursor, key_match)
                                  SideMatch.new(
                  Severity: Minor
                  Found in lib/twitter_cldr/transforms/conversions/side.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 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 to_a has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def to_a(compress = false)
                          if compress
                            ranges.map do |range|
                              if range.first == range.last
                                range.first
                  Severity: Minor
                  Found in lib/twitter_cldr/utils/range_set.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 character_class has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def character_class
                          operator_stack = []
                          operand_stack = []
                          open_count = 0
                  
                  
                  Severity: Minor
                  Found in lib/twitter_cldr/parsers/unicode_regex_parser.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 process_plurals has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def process_plurals(component, locale, path)
                          return unless component == 'PluralRules'
                  
                          output_file = File.join(File.dirname(path), 'plurals.yml')
                  
                  
                  Severity: Minor
                  Found in lib/twitter_cldr/resources/locales_resources_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

                  Severity
                  Category
                  Status
                  Source
                  Language