glebm/i18n-tasks

View on GitHub

Showing 52 of 60 total issues

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

  class Siblings < Nodes # rubocop:disable Metrics/ClassLength
    include ::I18n::Tasks::SplitKey
    include ::I18n::Tasks::PluralKeys

    attr_reader :parent, :key_to_node
Severity: Minor
Found in lib/i18n/tasks/data/tree/siblings.rb - About 4 hrs to fix

    Class Node has 28 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Node # rubocop:disable Metrics/ClassLength
        include Enumerable
        include Traversal
    
        attr_accessor :value
    Severity: Minor
    Found in lib/i18n/tasks/data/tree/node.rb - About 3 hrs to fix

      Method send_node_to_key_occurrence has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def send_node_to_key_occurrence(send_node, method_name, location: send_node.loc)
            if (first_arg_node = send_node.children[2]) &&
               (key = extract_string(first_arg_node))
              if (second_arg_node = send_node.children[3]) &&
                 second_arg_node.type == :hash
      Severity: Minor
      Found in lib/i18n/tasks/scanners/ruby_ast_scanner.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 mv_key! has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def mv_key!(from_pattern, to_pattern, root: 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 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 Terminal has 26 methods (exceeds 20 allowed). Consider refactoring.
      Open

            class Terminal < Base # rubocop:disable Metrics/ClassLength
              def missing_keys(forest = task.missing_keys)
                forest = collapse_missing_tree! forest
                if forest.present?
                  print_title missing_title(forest)
      Severity: Minor
      Found in lib/i18n/tasks/reports/terminal.rb - About 3 hrs to fix

        Method extract_literal_or_array_of_literals has a Cognitive Complexity of 21 (exceeds 5 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 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

        Class CLI has 23 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class I18n::Tasks::CLI
          include ::I18n::Tasks::Logging
        
          def self.start(argv)
            new.start(argv)
        Severity: Minor
        Found in lib/i18n/tasks/cli.rb - About 2 hrs to fix

          Method scan_file has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              def scan_file(path)
                keys = []
                text = read_file(path)
                text.scan(@pattern) do |match|
                  src_pos = Regexp.last_match.offset(0).first
          Severity: Minor
          Found in lib/i18n/tasks/scanners/pattern_scanner.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

          File siblings.rb has 257 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'set'
          require 'i18n/tasks/split_key'
          require 'i18n/tasks/data/tree/nodes'
          require 'i18n/tasks/data/tree/node'
          
          
          Severity: Minor
          Found in lib/i18n/tasks/data/tree/siblings.rb - About 2 hrs to fix

            Method key_parts has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                  def key_parts(key, &block)
                    return enum_for(:key_parts, key) unless block
                    nesting = PARENS
                    counts  = PARENS_ZEROS # dup'd later if key contains parenthesis
                    delim   = '.'
            Severity: Minor
            Found in lib/i18n/tasks/split_key.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 merge_node! has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def merge_node!(node, on_leaves_merge: nil) # rubocop:disable Metrics/AbcSize,Metrics/PerceivedComplexity
                  if key_to_node.key?(node.key)
                    our = key_to_node[node.key]
                    return if our == node
                    our.value = node.value if node.leaf?
            Severity: Minor
            Found in lib/i18n/tasks/data/tree/siblings.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 replace_key_exp has a Cognitive Complexity of 14 (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 inconsistent_interpolations has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                def inconsistent_interpolations(locales: nil, base_locale: nil) # rubocop:disable Metrics/AbcSize
                  locales ||= self.locales
                  base_locale ||= self.base_locale
                  result = empty_forest
            
            
            Severity: Minor
            Found in lib/i18n/tasks/interpolations.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_string has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def extract_string(node, array_join_with: nil, array_flatten: false, array_reject_blank: false)
                  if %i[sym str int].include?(node.type)
                    node.children[0].to_s
                  elsif %i[true false].include?(node.type) # rubocop:disable Lint/BooleanSymbol
                    node.type.to_s
            Severity: Minor
            Found in lib/i18n/tasks/scanners/ruby_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 extract_array_as_string has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def extract_array_as_string(node, array_join_with:, array_flatten: false, array_reject_blank: false)
                  children_strings = node.children.map do |child|
                    if %i[sym str int true false].include?(child.type) # rubocop:disable Lint/BooleanSymbol
                      extract_string child
                    else
            Severity: Minor
            Found in lib/i18n/tasks/scanners/ruby_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 process_references has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def process_references(usages,
                                       data_refs = merge_reference_trees(data_forest.select_keys { |_, node| node.reference? }))
                  fail ArgumentError, 'usages must be a Data::Tree::Instance' unless usages.is_a?(Data::Tree::Siblings)
                  fail ArgumentError, 'all_references must be a Data::Tree::Instance' unless data_refs.is_a?(Data::Tree::Siblings)
                  raw_refs = empty_forest
            Severity: Minor
            Found in lib/i18n/tasks/references.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 route has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                  def route(locale, forest, &block)
                    return to_enum(:route, locale, forest) unless block
                    out = Hash.new { |hash, key| hash[key] = Set.new }
                    not_found = Set.new
                    forest.keys do |key, _node|
            Severity: Minor
            Found in lib/i18n/tasks/data/router/conservative_router.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 set has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def set(full_key, node)
                  fail 'value should be a I18n::Tasks::Data::Tree::Node' unless node.is_a?(Node)
                  key_part, rest = split_key(full_key, 2)
                  child          = key_to_node[key_part]
            
            
            Severity: Minor
            Found in lib/i18n/tasks/data/tree/siblings.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) # 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 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

              Severity
              Category
              Status
              Source
              Language