smugglys/translatomatic

View on GitHub

Showing 745 of 745 total issues

Complex method Translatomatic::PathUtils#modify_path_locale (76.9)
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 by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

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

    Complex method Translatomatic::CLI::Database#search (51.2)
    Open

          def search(string, locale = nil)
            run do
              db = Translatomatic::Database.new(options)
    
              # find all matching texts
    Severity: Minor
    Found in lib/translatomatic/cli/database.rb by flog

    Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

    You can read more about ABC metrics or the flog tool

    Complex method Translatomatic::PathUtils#detect_path_locale (48.6)
    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 by flog

    Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

    You can read more about ABC metrics or the flog tool

    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

      Complex method Translatomatic::ResourceFile::Plist::Parser#parse (42.4)
      Open

              def parse(xml, options = {})
                @converters = {
                  'integer' => proc { |node| node.content.to_i },
                  'real'    => proc { |node| node.content.to_f },
                  'string'  => proc { |node| node.content.to_s },

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Complex method Translatomatic::CLI::Translate#string (40.1)
      Open

            def string(text, *locales)
              run do
                all_conf = conf.all
                source_locale = conf.get(:source_locale) || Locale.default.to_s
                target_locales = determine_target_locales(locales)
      Severity: Minor
      Found in lib/translatomatic/cli/translate.rb by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Complex method Translatomatic::HTTP::Request#create_request (32.3)
      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 by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Complex method Translatomatic::CLI::Main#display (31.9)
      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 by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Complex method Translatomatic::EscapedUnicode::unescape_char (31.8)
      Open

            def unescape_char(c)
              c.downcase!
              bytes = EMPTY_8BIT_STRING.dup
              i = 0
              while c[i] == '\\' && c[i + 1] == 'u'
      Severity: Minor
      Found in lib/translatomatic/escaped_unicode.rb by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      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

      Complex method Translatomatic::ResourceFile::find (27.8)
      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 by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      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

      Complex method Translatomatic::StringEscaping::unescape (25.4)
      Open

              return nil if value.nil?
              regex = /\\(?:([nevfbart\\])|0?x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4}))/
              value.gsub(regex) do
                if Regexp.last_match(3)
                  [Regexp.last_match(3).to_s.hex].pack('U*')
      Severity: Minor
      Found in lib/translatomatic/string_escaping.rb by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      Complex method Translatomatic::CLI::Main#display_properties (25.2)
      Open

            def display_properties(source, keys)
              puts t('cli.file_source', file: source)
              rows = []
              keys = source.properties.keys if keys.empty?
              keys.each do |key|
      Severity: Minor
      Found in lib/translatomatic/cli/main.rb by flog

      Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

      You can read more about ABC metrics or the flog tool

      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

      Severity
      Category
      Status
      Source
      Language