twitter/twitter-cldr-rb

View on GitHub

Showing 175 of 209 total issues

Method week_fields_for has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def week_fields_for(date)
        week_data_cache[date] ||= begin
          eyear = date.year
          day_of_week = date.wday + 1
          day_of_year = date.yday
Severity: Minor
Found in lib/twitter_cldr/formatters/calendars/date_time_formatter.rb - About 1 hr to fix

    Method consume_until_balanced has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

            def consume_until_balanced
              open_brackets = 0
              consumed_tokens = []
    
              if is_opening?(current_token) || is_closing?(current_token)
    Severity: Minor
    Found in lib/twitter_cldr/transforms/transforms/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 apply_to has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def apply_to(cursor)
            until cursor.eos?
              if filter_rule.matches?(cursor)
                rule_match = find_matching_rule_at(cursor)
    
    
    Severity: Minor
    Found in lib/twitter_cldr/transforms/conversion_rule_set.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 normalize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

            def normalize(locale_text)
              Locale.new(nil).tap do |locale|
                subtags = identify_subtags(locale_text)
    
                until subtags.empty?
    Severity: Minor
    Found in lib/twitter_cldr/shared/locale.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 generate_test has 33 lines of code (exceeds 25 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 1 hr to fix

      Method standard_importer_classes has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def standard_importer_classes
              @standard_importer_classes ||= [
                AliasesImporter,
                Bcp47TimezoneMetadataImporter,
                BidiTestImporter,
      Severity: Minor
      Found in lib/twitter_cldr/resources.rb - About 1 hr to fix

        Method format_display_name has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def format_display_name(date, type, fmt, dst = TZInfo::Timezone.default_dst, &block)
                date_int = date.strftime('%s').to_i
                period = tz.period_for_local(date, dst, &block)
        
                flavor = if type == :generic
        Severity: Minor
        Found in lib/twitter_cldr/timezones/generic_location.rb - About 1 hr to fix

          Method formats_for_type has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                def formats_for_type(type)
                  doc.xpath("//ldml/numbers/#{type}Formats").each_with_object({}) do |formats_node, ret|
                    number_system = if ns_node = formats_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 update_break_weights has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                def update_break_weights(pattern, break_weights, start_idx)
                  pattern_idx = 0
          
                  pattern.each_char do |segment|
                    if segment =~ /\d/
          Severity: Minor
          Found in lib/twitter_cldr/shared/hyphenator.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 advance_to_plausible_word_boundary has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                def advance_to_plausible_word_boundary(cursor, end_pos, state)
                  remaining = end_pos - (state.current + state.word_length)
                  pc = cursor.codepoint
                  chars = 0
          
          
          Severity: Minor
          Found in lib/twitter_cldr/segmentation/brahmic_break_engine.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 each_boundary_helper has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def each_boundary_helper(str, &block)
                  # Set up two independent cursors so the algorithm can iterate
                  # over those portions of the input string that require a
                  # dictionary-based break iterator independently from those that
                  # only need the normal, rule-based break iterator. Cursors
          Severity: Minor
          Found in lib/twitter_cldr/segmentation/word_iterator.rb - About 1 hr to fix

            Method format_offset has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def format_offset(offset, is_basic, use_utc_indicator, is_short, ignore_seconds)
                    abs_offset = offset.abs
                    return UTC if use_utc_indicator && abs_offset == 0
            
                    min_fields_idx = is_short ? 0 : 1
            Severity: Minor
            Found in lib/twitter_cldr/timezones/iso8601_location.rb - About 1 hr to fix

              Method init_tertiary_constants has 30 lines of code (exceeds 25 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 1 hr to fix

                Method advance_past_suffix has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def advance_past_suffix(cursor, end_pos, state)
                        suffix_length = 0
                
                        if cursor.position < end_pos && state.word_length > 0
                          uc = cursor.codepoint
                Severity: Minor
                Found in lib/twitter_cldr/segmentation/thai_break_engine.rb - About 1 hr to fix

                  Method side has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          def side
                            prev_cluster = next_token_cluster
                            before_context = nil
                            after_context = nil
                            key = nil
                  Severity: Minor
                  Found in lib/twitter_cldr/transforms/conversions/parser.rb - About 1 hr to fix

                    Method import_components has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def import_components
                            locales = Set.new
                    
                            finish = -> (locale, *) do
                              locales.add(locale)
                    Severity: Minor
                    Found in lib/twitter_cldr/resources/locales_resources_importer.rb - About 1 hr to fix

                      Method parse_tailorings has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def parse_tailorings(data, locale)
                              rules = data && data.at_xpath('rules')
                      
                              return '' unless rules
                      
                      
                      Severity: Minor
                      Found in lib/twitter_cldr/resources/tailoring_importer.rb - About 1 hr to fix

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

                              def traverse(key)
                                current_path = path_root
                        
                                key.inject(@root) do |node, key_element|
                                  next unless node
                        Severity: Minor
                        Found in lib/twitter_cldr/utils/file_system_trie.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 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

                        Severity
                        Category
                        Status
                        Source
                        Language