glebm/i18n-tasks

View on GitHub

Showing 64 of 67 total issues

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

    def replace_key_exp(key, replacement)
      scanner = StringScanner.new(key)
      braces  = []
      result  = []
      while (match_until = scanner.scan_until(/(?:#?\{|})/))
Severity: Minor
Found in lib/i18n/tasks/used_keys.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 mv_key! has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def mv_key!(from_pattern, to_pattern, root: false, retain: false) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
      moved_forest = Siblings.new
      moved_nodes = []
      old_key_to_new_key = {}
      nodes do |node|
Severity: Minor
Found in lib/i18n/tasks/data/tree/siblings.rb - About 1 hr to fix

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

        def missing_plural_forest(locales, _base = base_locale)
          locales.each_with_object(empty_forest) do |locale, forest|
            required_keys = required_plural_keys_for_locale(locale)
            next if required_keys.empty?
    
    
    Severity: Minor
    Found in lib/i18n/tasks/missing_keys.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 path_to_ast_and_comments has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def path_to_ast_and_comments(path)
          comments = []
          buffer = make_buffer(path)
    
          children = []
    Severity: Minor
    Found in lib/i18n/tasks/scanners/erb_ast_scanner.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 find_files has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_files # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
          results = []
          paths = @paths.select { |p| File.exist?(p) }
          log_warn "None of the search.paths exist #{@paths.inspect}" if paths.empty?
          Find.find(*paths) do |path|
    Severity: Minor
    Found in lib/i18n/tasks/scanners/files/file_finder.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 extract_literal_or_array_of_literals has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def extract_literal_or_array_of_literals(s)
          literals = []
          braces_stack = []
          acc = []
          consume_literal = proc do
    Severity: Minor
    Found in lib/i18n/tasks/scanners/pattern_with_scope_scanner.rb - About 1 hr to fix

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

          def collapse_same_key_in_locales!(forest)
            locales_and_node_by_key = {}
            to_remove               = []
            forest.each do |root|
              locale = root.key
      Severity: Minor
      Found in lib/i18n/tasks/missing_keys.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 levels has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def levels(&block)
              return to_enum(:levels) unless block
      
              nodes = to_nodes
              unless nodes.empty?
      Severity: Minor
      Found in lib/i18n/tasks/data/tree/traversal.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 file_config has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def file_config
          file   = @config_override || CONFIG_FILES.detect { |f| File.exist?(f) }
          # rubocop:disable Security/Eval
          config = file && YAML.load(eval(Erubi::Engine.new(File.read(file, encoding: 'UTF-8')).src))
          # rubocop:enable Security/Eval
      Severity: Minor
      Found in lib/i18n/tasks/configuration.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

      Consider simplifying this complex logical expression.
      Open

                if default.is_a?(Hash)
                  default.each_with_object({}) do |(k, v), h|
                    h[k] = StringInterpolation.interpolate_soft(
                      val_pattern,
                      value: node_value,
      Severity: Major
      Found in lib/i18n/tasks/data/tree/traversal.rb - About 1 hr to fix

        Method children has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def children(&block)
              return to_enum(:children) { map { |c| c.children ? c.children.size : 0 }.reduce(:+) } unless block
        
              each do |node|
                node.children.each(&block) if node.children?
        Severity: Minor
        Found in lib/i18n/tasks/data/tree/nodes.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 parse_option has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def parse_option(flag, val, argv, context)
            conf = flag.last.is_a?(Hash) ? flag.last : {}
            if conf[:consume_positional]
              val = Array(val) + Array(flag.include?(Array) ? argv.flat_map { |x| x.split(',') } : argv)
            end
        Severity: Minor
        Found in lib/i18n/tasks/cli.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 scan_file has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def scan_file(path)
              text = read_file(path)
              @patterns.flat_map do |pattern, key|
                result = []
                text.scan(pattern) do |_|
        Severity: Minor
        Found in lib/i18n/tasks/scanners/pattern_mapper.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 call has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

                  def call(vals, context)
                    if vals == %w[all] || vals.blank?
                      context.locales
                    else
                      move_base_locale_to_front!(vals.map { |v| v == 'base' ? context.base_locale : v }, context.base_locale)
        Severity: Minor
        Found in lib/i18n/tasks/command/option_parsers/locale.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 parse_value has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def parse_value(untranslated, each_translated, opts)
                case untranslated
                when Array
                  # implode array
                  untranslated.map { |from| parse_value(from, each_translated, opts) }
        Severity: Minor
        Found in lib/i18n/tasks/translators/base_translator.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_value has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def dump_value(value, opts)
                case value
                when Array
                  # dump recursively
                  value.map { |v| dump_value(v, opts) }
        Severity: Minor
        Found in lib/i18n/tasks/translators/base_translator.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 absolute_key has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                def absolute_key(key, path, roots: config[:relative_roots],
                                 exclude_method_name_paths: config[:relative_exclude_method_name_paths],
                                 calling_method: nil)
                  return key unless key.start_with?(DOT)
                  fail 'roots argument is required' unless roots.present?
        Severity: Minor
        Found in lib/i18n/tasks/scanners/relative_keys.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 run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def run(argv)
            argv.each_with_index do |arg, i|
              next unless ['--config', '-c'].include?(arg)
        
              _, config_file = argv.slice!(i, 2)
        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 route has a Cognitive Complexity of 8 (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/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 plural_nodes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def plural_nodes(tree)
            return to_enum(:plural_nodes, tree) unless block_given?
        
            visited = Set.new
            tree.leaves do |node|
        Severity: Minor
        Found in lib/i18n/tasks/plural_keys.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

        Severity
        Category
        Status
        Source
        Language