translation/rails

View on GitHub

Showing 32 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

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                      @yaml_file_paths.each do |file_path|
                        TranslationIO.info file_path, 2, 2
                        file_translations = TranslationIO.yaml_load(File.read(file_path))
            
                        if file_translations.present? && file_translations.values.all? { |value| value.present? }
            lib/translation_io/client/sync_operation/create_yaml_pot_file_step.rb on lines 15..21

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 31.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                      @yaml_file_paths.each do |file_path|
                        TranslationIO.info file_path, 2, 2
                        file_translations = TranslationIO.yaml_load(File.read(file_path))
            
                        if file_translations.present? && file_translations.values.all? { |value| value.present? }
            lib/translation_io/client/init_operation/create_yaml_po_files_step.rb on lines 19..25

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 31.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Severity
            Category
            Status
            Source
            Language