translation/rails

View on GitHub

Showing 30 of 32 total issues

Avoid deeply nested control flow statements.
Open

              if key_string.count(']') > key_string.count('[')
                key_string = '[' + key_string
              end
Severity: Major
Found in lib/translation_io/flat_hash.rb - About 45 mins to fix

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

          def remove_reserved_keys!(h)
            if h.is_a?(Hash)
              h.keys.each do |key|
                if [TrueClass, FalseClass].include?(key.class)
                  # # This warning is commented because Rails admin uses bad keys: https://github.com/sferik/rails_admin/blob/master/config/locales/rails_admin.en.yml
    Severity: Minor
    Found in lib/translation_io/flat_hash.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

    Avoid deeply nested control flow statements.
    Open

                    current_object[array_pos] = value if current_object.is_a?(Array)
    Severity: Major
    Found in lib/translation_io/flat_hash.rb - About 45 mins to fix

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

              def run(params)
                TranslationIO.info "Importing translations from YAML files."
      
                all_translations = {}
      
      
      Severity: Minor
      Found in lib/translation_io/client/init_operation/create_yaml_po_files_step.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

      Avoid deeply nested control flow statements.
      Open

                    current_object[new_key] = value if current_object.is_a?(Hash)
      Severity: Major
      Found in lib/translation_io/flat_hash.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                      if no_key?(current_object, current_key)
                        current_object[current_key] = {}
                      end
        Severity: Major
        Found in lib/translation_io/flat_hash.rb - About 45 mins to fix

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

                def gsub_keys!(h, from_1, from_2, to_1, to_2)
          Severity: Minor
          Found in lib/translation_io/flat_hash.rb - About 35 mins to fix

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

                def configure(&block)
                  ENV['LANG'] = 'en_US.UTF-8' if ENV['LANG'].blank?
            
                  @config ||= Config.new
            
            
            Severity: Minor
            Found in lib/translation.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 run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                    def run(params)
                      TranslationIO.info "Generating POT file from YAML files."
            
                      all_translations = {}
            
            
            Severity: Minor
            Found in lib/translation_io/client/sync_operation/create_yaml_pot_file_step.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 run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def run
                    config = TranslationIO.config
            
                    source_files      = config.source_files
                    erb_source_files  = config.erb_source_files
            Severity: Minor
            Found in lib/translation_io/client/init_operation.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

            Severity
            Category
            Status
            Source
            Language