twitter/twitter-cldr-rb

View on GitHub
lib/twitter_cldr/utils/yaml.rb

Summary

Maintainability
D
2 days
Test Coverage

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

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

    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

      Method emit_string has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

              def emit_string(str, level)
                if @options[:quote_all_strings] && !str.is_a?(Symbol)
                  emit_quoted_string(str, level)
                else
                  str = str.to_s
      Severity: Minor
      Found in lib/twitter_cldr/utils/yaml.rb - About 2 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 is_printable? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

              def is_printable?(ucs_code)
                # YAML 1.1 / 4.1.1.
                (
                  [0x09, 0x0a, 0x0d, 0x85].include?(ucs_code)   ||
                  (ucs_code <=     0x7e && ucs_code >=    0x20) ||
      Severity: Minor
      Found in lib/twitter_cldr/utils/yaml.rb - About 55 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 string_type has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

              def string_type(str)
                if str.respond_to?(:encoding) && (!str.valid_encoding? || str.encoding == Encoding::ASCII_8BIT)
                  return false, false, false, false
                end
                (ucs_codes = str.unpack('U*')) rescue (
      Severity: Minor
      Found in lib/twitter_cldr/utils/yaml.rb - About 55 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 yaml_escape has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

              def yaml_escape(str)
                # YAML 1.1 / 4.1.6.
                str.gsub(/[^a-zA-Z0-9]/u) do |c|
                  ucs_code, = (c.unpack('U') rescue [??])
                  case
      Severity: Minor
      Found in lib/twitter_cldr/utils/yaml.rb - About 55 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

      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

        There are no issues that match your filters.

        Category
        Status