smugglys/translatomatic

View on GitHub

Showing 22 of 745 total issues

Class Base has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Base
      # @return [Hash<Symbol,Object] Options used in the constructor
      attr_reader :options

      # @return [Locale] The locale of the contents of this resource file
Severity: Minor
Found in lib/translatomatic/resource_file/base.rb - About 3 hrs to fix

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

      class Text
        # @return [String] The text content
        attr_reader :value
    
        # @return [Translatomatic::Locale] The text locale
    Severity: Minor
    Found in lib/translatomatic/text.rb - About 2 hrs to fix

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

          def detect_path_locale(path)
            return nil unless path
            tag = nil
            basename = path.sub_ext('').basename.to_s
            directory = path.dirname.basename.to_s
      Severity: Minor
      Found in lib/translatomatic/path_utils.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 display has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def display(file = nil, *keys)
              run do
                source_files = parse_list(file, conf.get(:source_files))
                locales = conf.get(:target_locales, for_file: file)
                source_files.each do |path|
      Severity: Minor
      Found in lib/translatomatic/cli/main.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 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def find(path, options = {})
              files = []
              include_dot_directories = options[:include_dot_directories]
              path = Pathname.new(path) unless path.is_a?(Pathname)
              path.find do |file|
      Severity: Minor
      Found in lib/translatomatic/resource_file.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 init_pomap has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def init_pomap(po)
              po.entries.each_with_index do |entry, i|
                # skip PO file header if present
                # TODO: update PO-Revision-Date, Last-Provider ?
                next if entry.msgid == '' && i.zero?
      Severity: Minor
      Found in lib/translatomatic/resource_file/po.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
            fail_count = 0
            begin
              yield
            rescue StandardError => e
      Severity: Minor
      Found in lib/translatomatic/retry_executor.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 create_request has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def create_request
              klass = Net::HTTP.const_get(@method.to_s.classify)
              request = klass.new(@uri)
              request['User-Agent'] = USER_AGENT
      
      
      Severity: Minor
      Found in lib/translatomatic/http/request.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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(attributes = {})
            attributes.each do |k, v|
              raise "unrecognised attribute #{k}" unless constructor_option?(k)
              instance_variable_set("@#{k}", v)
            end
      Severity: Minor
      Found in lib/translatomatic/option.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 modify_path_locale has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def modify_path_locale(path, target_locale, preferred_separator = '.')
            basename = basename_stripped(path)
      
            extlist = extension_list(path)
            if extlist.length >= 2 && (loc_idx = find_extension_locale(extlist))
      Severity: Minor
      Found in lib/translatomatic/path_utils.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 share has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def share(collection)
              return if collection.empty?
      
              tmx = Translatomatic::TMX::Document.from_collection(collection)
              available = Translatomatic::Provider.available(@options)
      Severity: Minor
      Found in lib/translatomatic/translation/sharer.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 options_from_object has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.options_from_object(object)
            if object.is_a?(Translatomatic::Option)
              [object]
            elsif object.respond_to?(:options)
              options_from_object(object.options)
      Severity: Minor
      Found in lib/translatomatic/option.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 cast has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def cast(value, type, options = {})
            value = value[0] if value.is_a?(Array) && !array_type?(type)
      
            case type
            when :boolean
      Severity: Minor
      Found in lib/translatomatic/type_cast.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 process_string has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def process_string(string)
            if @max_length && @length + string.length >= @max_length
              raise t('translator.string_too_long') if @batch.empty?
              yield_batch { |batch| yield batch }
            end
      Severity: Minor
      Found in lib/translatomatic/string_batcher.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(options = {})
            @env = options[:database_env] || DEFAULT_ENV
            @db_config = database_config(@env, options)
            env_config = @db_config
            unless env_config[@env]
      Severity: Minor
      Found in lib/translatomatic/database.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 wrap_notranslate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def wrap_notranslate(texts)
              return texts unless use_notranslate? && texts.any?(&:preserve_regex)
              texts.collect do |text|
                if text.preserve_regex
                  text.gsub(text.preserve_regex) do |i|
      Severity: Minor
      Found in lib/translatomatic/translation/munging.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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def set(key, value)
              super(key, value)
      
              if @pomap.include?(key)
                po_property = @pomap[key]
      Severity: Minor
      Found in lib/translatomatic/resource_file/po.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 save_database_translations has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def save_database_translations(translations)
              return unless @use_db
              ActiveRecord::Base.transaction do
                from = db_locale(@from_locale)
                to = db_locale(@to_locale)
      Severity: Minor
      Found in lib/translatomatic/translation/fetcher.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 paramify has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def paramify(object)
              return object if object.is_a?(Param) || object.is_a?(FileParam)
              raise 'invalid multipart parameter' unless object.is_a?(Hash)
              object[:filename] ? FileParam.new(object) : Param.new(object)
            end
      Severity: Minor
      Found in lib/translatomatic/http/request.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 parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def parse(tag, validate = true)
              return nil if tag.nil?
      
              locale = tag
              unless tag.is_a?(Translatomatic::Locale)
      Severity: Minor
      Found in lib/translatomatic/locale.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