twitter/twitter-cldr-rb

View on GitHub

Showing 209 of 209 total issues

Method resolve_weak_types has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
Open

      def resolve_weak_types
        run_count = @runs.size
        previous_level = @base_embedding

        run_count.times do |run_idx|
Severity: Minor
Found in lib/twitter_cldr/shared/bidi.rb - About 1 day 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 emit has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
Open

        def emit(obj, level)
          case obj
            when Array
              if (obj.length == 0)
                '[]'
Severity: Minor
Found in lib/twitter_cldr/utils/yaml.rb - About 1 day 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 compute_explicit_levels has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

      def compute_explicit_levels
        current_embedding = @base_embedding

        # The directional override is a Character directionality
        # constant.  -1 means there is no override.
Severity: Minor
Found in lib/twitter_cldr/shared/bidi.rb - About 6 hrs 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_neutral_types has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

      def resolve_neutral_types
        # This implements rules N1 and N2.
        run_count = get_run_count
        previous_level = @base_embedding

Severity: Minor
Found in lib/twitter_cldr/shared/bidi.rb - About 6 hrs 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

Class Locale has 42 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Locale

      class << self
        # http://unicode.org/reports/tr35/tr35-9.html#Likely_Subtags
        #
Severity: Minor
Found in lib/twitter_cldr/shared/locale.rb - About 5 hrs to fix

    Method divide_up_dictionary_range has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

          def divide_up_dictionary_range(cursor, end_pos, &block)
            return to_enum(__method__, cursor, end_pos) unless block_given?
    
            input_length = end_pos - cursor.position
            best_snlp = Array.new(input_length + 1) { LARGE_NUMBER }
    Severity: Minor
    Found in lib/twitter_cldr/segmentation/cj_break_engine.rb - About 4 hrs 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 mark_best_candidate has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

          def mark_best_candidate(cursor, end_pos, state)
            # if there was more than one, see which one can take us forward the most words
            found_best = false
    
            # if we're already at the end of the range, we're done
    Severity: Minor
    Found in lib/twitter_cldr/segmentation/brahmic_break_engine.rb - About 4 hrs 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

    File bidi.rb has 345 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module TwitterCldr
      module Shared
        class Bidi
          attr_reader :types, :levels, :string_arr
    
    
    Severity: Minor
    Found in lib/twitter_cldr/shared/bidi.rb - About 4 hrs to fix

      Method format_display_name has a Cognitive Complexity of 29 (exceeds 5 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 4 hrs 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 has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

      def process(str, rule_set)
        # markers depend on what rule set we are using
        buf = str.unpack("U*")
      
        name = rule_set.name
      Severity: Minor
      Found in lib/twitter_cldr/formatters/numbers/rbnf/post_processors/chinese.rb - About 4 hrs 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

      Class RangeSet has 32 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class RangeSet
      
            include Enumerable
      
            attr_reader :ranges
      Severity: Minor
      Found in lib/twitter_cldr/utils/range_set.rb - About 4 hrs to fix

        Method format_tokens has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

              def format_tokens(tokens, format, hour, min, sec)
                ''.tap do |result|
                  tokens.each do |token|
                    case token.type
                      when :plaintext
        Severity: Minor
        Found in lib/twitter_cldr/timezones/gmt_location.rb - About 3 hrs 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_data has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

              def generate_test_data(transforms)
                transforms.each_with_object([]) do |transform_id_str, ret|
                  forward_id = transform_id.parse(transform_id_str)
        
                  [forward_id, forward_id.reverse].each do |id|
        Severity: Minor
        Found in lib/twitter_cldr/resources/transform_tests_importer.rb - About 3 hrs 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

        Class CodePoint has 30 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class CodePoint
              DECOMPOSITION_REGEX = /^(?:<(.+)>\s+)?(.+)?$/
              MAX_CODE_POINT = 1_112_111
        
              attr_reader :fields
        Severity: Minor
        Found in lib/twitter_cldr/shared/code_point.rb - About 3 hrs to fix

          File yaml.rb has 318 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module TwitterCldr
            module Utils
          
              class YAML
          
          
          Severity: Minor
          Found in lib/twitter_cldr/utils/yaml.rb - About 3 hrs to fix

            Class LocalizedString has 29 methods (exceeds 20 allowed). Consider refactoring.
            Open

                class LocalizedString < LocalizedObject
                  include Enumerable
            
                  # Uses wrapped string object as a format specification and returns the result of applying it to +args+ (see
                  # standard String#% method documentation for interpolation syntax).
            Severity: Minor
            Found in lib/twitter_cldr/localized/localized_string.rb - About 3 hrs to fix

              File date_time_formatter.rb has 304 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require 'tzinfo'
              
              module TwitterCldr
                module Formatters
                  class DateTimeFormatter < Formatter
              Severity: Minor
              Found in lib/twitter_cldr/formatters/calendars/date_time_formatter.rb - About 3 hrs to fix

                Method emit has 80 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        def emit(obj, level)
                          case obj
                            when Array
                              if (obj.length == 0)
                                '[]'
                Severity: Major
                Found in lib/twitter_cldr/utils/yaml.rb - About 3 hrs to fix

                  Class UnicodeRegexParser has 27 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                      class UnicodeRegexParser < Parser
                  
                        autoload :Component,      "twitter_cldr/parsers/unicode_regex/component"
                        autoload :CharacterClass, "twitter_cldr/parsers/unicode_regex/character_class"
                        autoload :CharacterRange, "twitter_cldr/parsers/unicode_regex/character_range"
                  Severity: Minor
                  Found in lib/twitter_cldr/parsers/unicode_regex_parser.rb - About 3 hrs to fix

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

                        class UnitsImporter < Importer
                    
                          requirement :cldr, Versions.cldr_version
                          output_path 'locales'
                          locales TwitterCldr.supported_locales
                    Severity: Major
                    Found in lib/twitter_cldr/resources/units_importer.rb and 1 other location - About 3 hrs to fix
                    lib/twitter_cldr/resources/number_formats_importer.rb on lines 15..56

                    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 112.

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language