viktorasl/xlocalize

View on GitHub

Showing 14 of 14 total issues

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

    def purelyze(locale, targets, excl_prefix, project, filer_ui_duplicates=false, exclude_units)
      locale_file_name = locale_file_name(locale)
      doc = Nokogiri::XML(File.open(locale_file_name))

      puts "Removing all files not matching required targets" if $VERBOSE
Severity: Minor
Found in lib/xlocalize/executor.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 export_master has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def export_master(wti, project, targets, excl_prefix, master_lang, exclude_units=[], no_cryptic)
      master_file_name = locale_file_name(master_lang)

      File.delete(master_file_name) if File.exist?(master_file_name)

Severity: Minor
Found in lib/xlocalize/executor.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 push_master_file has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def push_master_file(wti, master_lang, master_file_name)
      # Pushing master file to WebtranslateIt
      begin
        puts "Uploading master file to WebtranslateIt"
        file = File.open(master_file_name, 'r')
Severity: Minor
Found in lib/xlocalize/executor.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 import_plurals_if_needed has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def import_plurals_if_needed(locale)
      plurals_fname = "#{locale}_plurals.yaml"
      return if !File.exist?(plurals_fname)
      puts "Importing translations from #{plurals_fname}" if $VERBOSE
      plurals_yml = YAML.load_file(plurals_fname)
Severity: Minor
Found in lib/xlocalize/executor.rb - About 1 hr to fix

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

        def define_export_cmd
          command :export do |c|
            c.syntax = 'xlocalize export [options]'
            c.description = 'Export localized strings from Xcode project'
            c.option '--wti_key STRING', String, 'Webtranslateit API key'
    Severity: Minor
    Found in lib/xlocalize.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 initialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(key, http = Net::HTTP.new("webtranslateit.com", 443))
          @key = key
    
          @http = http
          @http.use_ssl = true
    Severity: Minor
    Found in lib/xlocalize/webtranslateit.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 export_master has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def export_master(wti, project, targets, excl_prefix, master_lang, exclude_units=[], no_cryptic)
          master_file_name = locale_file_name(master_lang)
    
          File.delete(master_file_name) if File.exist?(master_file_name)
    
    
    Severity: Minor
    Found in lib/xlocalize/executor.rb - About 1 hr to fix

      Method localized_filename has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def localized_filename(file_name, locale)
            parts = file_name.split('/')
      
            # WebTranslateIt uses _ for Language_Country separator e.g. pt_PT
            # but Xcode uses - e.g. pt-PT
      Severity: Minor
      Found in lib/xlocalize/executor.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 export_master has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def export_master(wti, project, targets, excl_prefix, master_lang, exclude_units=[], no_cryptic)
      Severity: Major
      Found in lib/xlocalize/executor.rb - About 50 mins to fix

        Method purelyze has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def purelyze(locale, targets, excl_prefix, project, filer_ui_duplicates=false, exclude_units)
        Severity: Minor
        Found in lib/xlocalize/executor.rb - About 45 mins to fix

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

              def merge_on_top_of(original_doc)
                #original_doc = Nokogiri::XML(wti.pull(master_lang)['xliff'])
                original_xliff = original_doc.at_css('xliff')
                doc = self#Nokogiri::XML(File.open(master_file_name))
                doc.xpath("//xmlns:file").each { |node|
          Severity: Minor
          Found in lib/xlocalize/xliff.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 push_master_plurals has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def push_master_plurals(plurals_file)
                if @plurals_file_id.nil?
                  if $VERBOSE
                    $stderr.puts 'Creating plurals file'
                  end
          Severity: Minor
          Found in lib/xlocalize/webtranslateit.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 filter_duplicate_storyboard_xib_files has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def filter_duplicate_storyboard_xib_files
                all_files = self.xpath("//xmlns:file").map { |node| Pathname.new(node["original"]).split.last.to_s }
                self.xpath("//xmlns:file").each do |node|
                  fname = Pathname.new(node["original"]).split.last.to_s
                  if fname.end_with?(".strings")
          Severity: Minor
          Found in lib/xlocalize/xliff.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 filter_plurals has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def filter_plurals(project)
                plurals = {}
                self.xpath("//xmlns:file").each { |node|
                  fname = node["original"]
                  next if !fname.end_with?(".strings")
          Severity: Minor
          Found in lib/xlocalize/xliff.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