glebm/i18n-tasks

View on GitHub

Showing 67 of 67 total issues

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

  def start(argv)
    auto_output_coloring do
      exit 1 if run(argv) == :exit1
    rescue OptionParser::ParseError => e
      error e.message, 64
Severity: Minor
Found in lib/i18n/tasks/cli.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 get_nodes_by_key_filter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def get_nodes_by_key_filter(root: false, &block)
        matches = Set.new
        keys(root: root) do |full_key, node|
          if block.yield(full_key, node)
            node.walk_to_root do |p|
Severity: Minor
Found in lib/i18n/tasks/data/tree/traversal.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 smoosh has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def smoosh(chars)
          out = []
          until chars.empty?
            char = chars.shift
            if char == '*' && chars.first == '*'
Severity: Minor
Found in lib/i18n/tasks/data/router/isolating_router.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 to_hash_from_indifferent has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def to_hash_from_indifferent(value)
    case value
    when Hash
      value.stringify_keys.to_hash.tap do |h|
        h.each { |k, v| h[k] = to_hash_from_indifferent(v) if v.is_a?(Hash) || v.is_a?(Array) }
Severity: Minor
Found in lib/i18n/tasks/configuration.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_non_leaf! has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def process_non_leaf!(ref, usage, raw_refs, resolved_refs, refs)
Severity: Minor
Found in lib/i18n/tasks/references.rb - About 35 mins to fix

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

        def process_leaf!(ref, usage, raw_refs, resolved_refs, refs)
    Severity: Minor
    Found in lib/i18n/tasks/references.rb - About 35 mins to fix

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

              def add_missing(opt = {}) # rubocop:disable Metrics/AbcSize
                [
                  [i18n.base_locale] & opt[:locales],
                  opt[:locales] - [i18n.base_locale]
                ].reject(&:empty?).each_with_object(i18n.empty_forest) do |locales, added|
      Severity: Minor
      Found in lib/i18n/tasks/command/commands/missing.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 cmd has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def cmd(name, conf = nil)
                if conf
                  conf        = conf.dup
                  conf[:args] = (conf[:args] || []).map { |arg| arg.is_a?(Symbol) ? arg(arg) : arg }
                  dsl(:cmds)[name] = conf
      Severity: Minor
      Found in lib/i18n/tasks/command/dsl.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 inspect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def inspect(level = 0)
            label = if key.nil?
                      Rainbow('∅').faint
                    else
                      [Rainbow(key).color(1 + (level % 15)),
      Severity: Minor
      Found in lib/i18n/tasks/data/tree/node.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 forests_stdin_and_pos! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def forests_stdin_and_pos!(opt, num = false, format = opt[:format])
                args = opt[:arguments] || []
                if opt[:nostdin]
                  sources = []
                else
      Severity: Minor
      Found in lib/i18n/tasks/command/options/data.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 configure_api_key! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def configure_api_key!
            api_key = @i18n_tasks.translation_config[:deepl_api_key]
            host = @i18n_tasks.translation_config[:deepl_host]
            version = @i18n_tasks.translation_config[:deepl_version]
            fail ::I18n::Tasks::CommandError, I18n.t('i18n_tasks.deepl_translate.errors.no_api_key') if api_key.blank?
      Severity: Minor
      Found in lib/i18n/tasks/translators/deepl_translator.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 merge_scanner_configs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def merge_scanner_configs(a, b)
            a.deep_merge(b).tap do |c|
              %i[scanners paths relative_exclude_method_name_paths relative_roots].each do |key|
                c[key] = a[key] if b[key].blank?
              end
      Severity: Minor
      Found in lib/i18n/tasks/used_keys.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 depluralize_key has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def depluralize_key(key, locale = base_locale)
          return key if key !~ PLURAL_KEY_RE
      
          key_name = last_key_part(key)
          parent_key = key[0..- (key_name.length + 2)]
      Severity: Minor
      Found in lib/i18n/tasks/plural_keys.rb - About 25 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 route has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def route(locale, forest, &block)
              return to_enum(:route, locale, forest) unless block
      
              locale = locale.to_s
              out = {}
      Severity: Minor
      Found in lib/i18n/tasks/data/router/pattern_router.rb - About 25 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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

                def call(values, *)
                  values = Array(values)
                  return @valid if values == %w[all]
      
                  invalid = values - @valid
      Severity: Minor
      Found in lib/i18n/tasks/command/option_parsers/enum.rb - About 25 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 plural_keys_for_locale has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def plural_keys_for_locale(locale)
            configuration = load_rails_i18n_pluralization!(locale)
            if configuration[locale.to_sym].nil?
              alternate_locale = alternate_locale_from(locale)
              return Set.new if configuration[alternate_locale.to_sym].nil?
      Severity: Minor
      Found in lib/i18n/tasks/missing_keys.rb - About 25 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 set_each_value! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def set_each_value!(val_pattern, key_pattern = nil, &value_proc) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
              value_proc ||= proc do |node|
                node_value = node.value
                next node_value if node.reference?
      
      
      Severity: Minor
      Found in lib/i18n/tasks/data/tree/traversal.rb - About 25 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 merge_reference_trees has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def merge_reference_trees(roots)
            roots.inject(empty_forest) do |forest, root|
              root.keys do |full_key, node|
                if full_key == node.value.to_s
                  log_warn(
      Severity: Minor
      Found in lib/i18n/tasks/references.rb - About 25 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 translate_pairs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def translate_pairs(list, opts)
              return [] if list.empty?
      
              opts = opts.dup
              key_pos = list.each_with_index.inject({}) { |idx, ((k, _v), i)| idx.update(k => i) }
      Severity: Minor
      Found in lib/i18n/tasks/translators/base_translator.rb - About 25 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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def get
            return get_result_volatile unless get_result_volatile == NULL
      
            @mutex.synchronize do
              next unless get_result_volatile == NULL
      Severity: Minor
      Found in lib/i18n/tasks/concurrent/cached_value.rb - About 25 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