twitter/twitter-cldr-rb

View on GitHub

Showing 209 of 209 total issues

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

      def substitute_variables(tokens, symbol_table)
        return tokens unless symbol_table
        tokens.inject([]) do |ret, token|
          if token.type == :variable && sub = symbol_table.fetch(token.value)
            # variables can themselves contain references to other variables
Severity: Minor
Found in lib/twitter_cldr/parsers/unicode_regex_parser.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 deep_symbolize_keys has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def deep_symbolize_keys(arg)
        case arg
          when Array
            arg.map { |elem| deep_symbolize_keys(elem) }
          when Hash
Severity: Minor
Found in lib/twitter_cldr/utils.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 tokenize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def tokenize(text)
        text.split(splitter).inject([]) do |ret, token_text|
          recognizer = recognizers.find do |recognizer|
            recognizer.recognizes?(token_text)
          end
Severity: Minor
Found in lib/twitter_cldr/tokenizers/tokenizer.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 dump has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def dump(obj, opts = {})
          @options = opts.dup
          @options[:indent_size] = 2          if @options[:indent_size].to_i <= 0
          @options[:minimum_block_length] = 0 if @options[:minimum_block_length].to_i <= 0
          @options.update(
Severity: Minor
Found in lib/twitter_cldr/utils/yaml.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

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

        def find_match_comment_after(idx)
          loop do
            return nil if idx > schema.size

            if schema[idx].strip.start_with?('<!--@MATCH')
Severity: Minor
Found in lib/twitter_cldr/resources/cldr_dtd.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 init_tertiary_constants has a Cognitive Complexity of 7 (exceeds 5 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 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

Avoid too many return statements within this method.
Open

          return true, true, is_one_line?(str), is_one_plain_line?(str)
Severity: Major
Found in lib/twitter_cldr/utils/yaml.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 mz_name
      Severity: Major
      Found in lib/twitter_cldr/timezones/generic_location.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 code_point + NON_CJK_OFFSET # non-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_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 mz_name
              Severity: Major
              Found in lib/twitter_cldr/timezones/generic_location.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

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

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

                                def execute
                                  output_file = File.join(output_path, 'aliases.yml')
                                  FileUtils.mkdir_p(output_path)
                          
                                  File.open(output_file, 'w:utf-8') do |output|
                          Severity: Minor
                          Found in lib/twitter_cldr/resources/aliases_importer.rb and 1 other location - About 25 mins to fix
                          lib/twitter_cldr/resources/validity_data_importer.rb on lines 17..26

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

                          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