twitter/twitter-cldr-rb

View on GitHub

Showing 175 of 209 total issues

Method initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def initialize(boundary_type, locale, metadata, ftable, rtable, status_table, category_table)
Severity: Major
Found in lib/twitter_cldr/segmentation/state_machine.rb - About 50 mins to fix

    Method elements has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def elements(node, kind, context, width, options = {})
            node.xpath(kind).each_with_object({}) do |node, result|
              key = node.attribute('type').value
              key = key =~ /^\d*$/ ? key.to_i : key.to_sym
    
    
    Severity: Minor
    Found in lib/twitter_cldr/resources/calendars_importer.rb - About 45 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 compile_regexp has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def compile_regexp(regexp_str)
              TwitterCldr::Shared::UnicodeRegex.compile(regexp_str).tap do |re|
                re.elements.replace(
                  re.elements.flat_map do |element|
                    new_elem = case element.type
    Severity: Minor
    Found in lib/twitter_cldr/transforms/conversions/side.rb - About 45 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 execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def execute
            each_locale do |locale, doc|
              BOUNDARY_TYPES.each do |kind, icu_kind|
                seg = doc.xpath(
                  "//ldml/segmentations/segmentation[@type=\"#{TYPES_TO_ATTRS[kind]}\"]"
    Severity: Minor
    Found in lib/twitter_cldr/resources/segment_rules_importer.rb - About 45 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 compose_list has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def compose_list(list, res)
            result = compose(res[:end] || res[:middle] || "", [list[-2], list[-1]])
    
            # Ruby ranges don't support subtraction for some reason (eg. -3..-5).
            # Instead, we use a positive counter and negate it on array access.
    Severity: Minor
    Found in lib/twitter_cldr/formatters/list_formatter.rb - About 45 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_hash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def deep_merge_hash(first, second, &block)
            target = first.dup
    
            second.keys.each do |key|
              if second[key].is_a?(Hash) && first[key].is_a?(Hash)
    Severity: Minor
    Found in lib/twitter_cldr/utils.rb - About 45 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 resolve_implicit_levels has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def resolve_implicit_levels
            # This implements rules I1 and I2.
            @length.times do |i|
              if (@levels[i] & 1) == 0
                if @types[i] == :R
    Severity: Minor
    Found in lib/twitter_cldr/shared/bidi.rb - About 45 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 matches has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def matches(cursor, max_search_length, limit)
            return 0 if cursor.length == 0
    
            count = 0
            num_chars = 1
    Severity: Minor
    Found in lib/twitter_cldr/segmentation/dictionary.rb - About 45 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_bcp_47_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def process_bcp_47_data(data, result)
            if !data.empty? && %w[language extlang].include?(data['type']) && !data['names'].include?('Private use') && data['scope'] != 'collection'
              existing_names = data['names'].select { |name| result.has_key?(name) }
    
              prefered    = data['preferred-value']
    Severity: Minor
    Found in lib/twitter_cldr/resources/language_codes_importer.rb - About 45 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 pattern_for_sign has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def pattern_for_sign(pattern, sign)
            if pattern.include?(";")
              positive, negative = pattern.split(";")
              sign == :positive ? positive : negative
            else
    Severity: Minor
    Found in lib/twitter_cldr/data_readers/number_data_reader.rb - About 45 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_fallback has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_fallback
          locale_fallbacks.reverse_each do |fallback|
            result = if fallback.is_a?(Proc)
              begin
                fallback.call
    Severity: Minor
    Found in lib/twitter_cldr.rb - About 45 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_tokens has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def format_tokens(tokens, format, hour, min, sec)
    Severity: Minor
    Found in lib/twitter_cldr/timezones/gmt_location.rb - About 35 mins to fix

      Method format_display_name has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def format_display_name(date, type, fmt, dst = TZInfo::Timezone.default_dst, &block)
      Severity: Minor
      Found in lib/twitter_cldr/timezones/generic_location.rb - About 35 mins to fix

        Method arraycopy has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def arraycopy(orig, orig_index, dest, dest_index, length)
        Severity: Minor
        Found in lib/twitter_cldr/shared/bidi.rb - About 35 mins to fix

          Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  def initialize(direction, left, right, original_rule_text, index)
          Severity: Minor
          Found in lib/twitter_cldr/transforms/conversions/conversion_rule.rb - About 35 mins to fix

            Method elements has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def elements(node, kind, context, width, options = {})
            Severity: Minor
            Found in lib/twitter_cldr/resources/calendars_importer.rb - About 35 mins to fix

              Method format_offset has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                    def format_offset(offset, is_basic, use_utc_indicator, is_short, ignore_seconds)
              Severity: Minor
              Found in lib/twitter_cldr/timezones/iso8601_location.rb - About 35 mins to fix

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

                        def load
                          results = Hash.new do |h, k|
                            h[k] = Hash.new { |h, k| h[k] = [] }
                          end
                
                
                Severity: Minor
                Found in lib/twitter_cldr/resources/properties/property_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 includes_range? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                      def includes_range?(range)
                        result = bsearch do |cur_range|
                          fo = front_overlap?(cur_range, range)
                          ro = rear_overlap?(cur_range, 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 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

                Severity
                Category
                Status
                Source
                Language