ruboto/ruboto

View on GitHub
lib/ruboto/util/setup.rb

Summary

Maintainability
F
1 wk
Test Coverage

File setup.rb has 675 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'ruboto/sdk_versions'
require 'ruboto/util/verify'

module Ruboto
  module Util
Severity: Major
Found in lib/ruboto/util/setup.rb - About 1 day to fix

    Method config_path has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

          def config_path(accept_all)
            unless @missing_paths.empty?
              puts "\nYou are missing some paths.  Execute these lines to add them:\n\n"
              if windows?
                @missing_paths.each do |path|
    Severity: Minor
    Found in lib/ruboto/util/setup.rb - About 4 hrs 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 check_for_haxm has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

          def check_for_haxm
            case android_package_os_id
            when MAC_OS_X
              @haxm_kext_loc = '/Library/Extensions/intelhaxm.kext'
              found = File.exist?(@haxm_kext_loc)
    Severity: Minor
    Found in lib/ruboto/util/setup.rb - About 4 hrs 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 install_haxm has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

          def install_haxm(accept_all, custom_version=nil)
            haxm_file_override =  "IntelHAXM_#{custom_version}.dmg" unless custom_version.nil?
            if @haxm_installer_loc && (@haxm_kext_loc.nil? || haxm_old?)
              if @haxm_kext_loc.nil?
                puts 'HAXM not installed.'
    Severity: Minor
    Found in lib/ruboto/util/setup.rb - About 4 hrs 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 install_ant has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

          def install_ant(accept_all)
            case android_package_os_id
            when MAC_OS_X
            when LINUX
              install_package(accept_all, 'ant', 'Apache ANT')
    Severity: Minor
    Found in lib/ruboto/util/setup.rb - About 2 hrs 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 install_java has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

          def install_java(accept_all)
            case android_package_os_id
            when MAC_OS_X
            when LINUX
              install_package(accept_all, 'default-jdk', 'Default Java Development Kit')
    Severity: Minor
    Found in lib/ruboto/util/setup.rb - About 2 hrs 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 get_tools_version has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

          def get_tools_version(type='tool', repo_url = REPOSITORY_URL, host_os = nil)
            require 'rexml/document'
            require 'open-uri'
    
            doc = REXML::Document.new(open(repo_url))
    Severity: Minor
    Found in lib/ruboto/util/setup.rb - About 2 hrs 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 install_package has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

          def install_package(accept_all, package_name, pretty_name)
            case android_package_os_id
            when LINUX
              puts "#{pretty_name} was not found."
              installer = package_installer
    Severity: Minor
    Found in lib/ruboto/util/setup.rb - About 2 hrs 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 config_path has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def config_path(accept_all)
            unless @missing_paths.empty?
              puts "\nYou are missing some paths.  Execute these lines to add them:\n\n"
              if windows?
                @missing_paths.each do |path|
    Severity: Major
    Found in lib/ruboto/util/setup.rb - About 2 hrs to fix

      Method install_all has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def install_all(accept_all, api_levels, upgrade_haxm)
              install_java(accept_all) unless @java_loc && @javac_loc
              install_ant(accept_all) unless @ant_loc
              install_android_sdk(accept_all) unless @android_loc
      
      
      Severity: Minor
      Found in lib/ruboto/util/setup.rb - About 2 hrs 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 install_ant has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def install_ant(accept_all)
              case android_package_os_id
              when MAC_OS_X
              when LINUX
                install_package(accept_all, 'ant', 'Apache ANT')
      Severity: Major
      Found in lib/ruboto/util/setup.rb - About 2 hrs to fix

        Method install_java has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def install_java(accept_all)
                case android_package_os_id
                when MAC_OS_X
                when LINUX
                  install_package(accept_all, 'default-jdk', 'Default Java Development Kit')
        Severity: Minor
        Found in lib/ruboto/util/setup.rb - About 1 hr to fix

          Method install_android_sdk has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

                def install_android_sdk(accept_all)
                  unless @android_loc
                    puts 'Android package installer not found.'
                    unless accept_all
                      print 'Would you like to download and install it? (Y/n): '
          Severity: Minor
          Found in lib/ruboto/util/setup.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 check_for_haxm has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def check_for_haxm
                  case android_package_os_id
                  when MAC_OS_X
                    @haxm_kext_loc = '/Library/Extensions/intelhaxm.kext'
                    found = File.exist?(@haxm_kext_loc)
          Severity: Minor
          Found in lib/ruboto/util/setup.rb - About 1 hr to fix

            Method install_haxm has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def install_haxm(accept_all, custom_version=nil)
                    haxm_file_override =  "IntelHAXM_#{custom_version}.dmg" unless custom_version.nil?
                    if @haxm_installer_loc && (@haxm_kext_loc.nil? || haxm_old?)
                      if @haxm_kext_loc.nil?
                        puts 'HAXM not installed.'
            Severity: Minor
            Found in lib/ruboto/util/setup.rb - About 1 hr to fix

              Method install_package has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def install_package(accept_all, package_name, pretty_name)
                      case android_package_os_id
                      when LINUX
                        puts "#{pretty_name} was not found."
                        installer = package_installer
              Severity: Minor
              Found in lib/ruboto/util/setup.rb - About 1 hr to fix

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

                      def which(cmd)
                        exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
                        ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
                          exts.each do |ext|
                            exe = File.join(path, "#{cmd}#{ext}")
                Severity: Minor
                Found in lib/ruboto/util/setup.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 check_for has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                      def check_for(cmd, pretty_name=nil, alt_dir=nil)
                        rv = which(cmd)
                        rv = nil if rv && rv.empty?
                
                        if rv
                Severity: Minor
                Found in lib/ruboto/util/setup.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 install_android_sdk has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def install_android_sdk(accept_all)
                        unless @android_loc
                          puts 'Android package installer not found.'
                          unless accept_all
                            print 'Would you like to download and install it? (Y/n): '
                Severity: Minor
                Found in lib/ruboto/util/setup.rb - About 1 hr to fix

                  Method update_sdk has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def update_sdk(update_cmd, accept_all)
                          if accept_all
                            IO.popen(update_cmd, 'r+', external_encoding: Encoding::BINARY) do |cmd_io|
                              begin
                                output = ''.encode(Encoding::BINARY)
                  Severity: Minor
                  Found in lib/ruboto/util/setup.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 install_android_tools has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def install_android_tools(accept_all)
                          if @android_loc and (@dx_loc.nil? || @adb_loc.nil? || @emulator_loc.nil? || @haxm_installer_loc.nil?)
                            puts 'Android tools not found.'
                            unless accept_all
                              print 'Would you like to download and install them? (Y/n): '
                  Severity: Minor
                  Found in lib/ruboto/util/setup.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 check_for_android_platform has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def check_for_android_platform(api_level)
                          @platform_sdk_loc[api_level] = File.expand_path "#{android_package_directory}/platforms/#{api_level}"
                          found = File.exist? @platform_sdk_loc[api_level]
                          @platform_sdk_loc[api_level] = nil unless found
                          puts "#{'%-25s' % "Platform SDK #{api_level}"}: #{(found ? 'Found' : 'Not found')}"
                  Severity: Minor
                  Found in lib/ruboto/util/setup.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 store_cookie has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def store_cookie(response)
                          return unless response['set-cookie']
                          header = response['set-cookie']
                          header.gsub! /expires=.{3},/, ''
                          header.split(',').each do |cookie|
                  Severity: Minor
                  Found in lib/ruboto/util/setup.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 process_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def process_response(response)
                          store_cookie(response)
                          if response.code == '302'
                            redirect_url = response['location']
                            puts "Following redirect to #{redirect_url}"
                  Severity: Minor
                  Found in lib/ruboto/util/setup.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_download has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def process_download(filename, uri)
                          body = ''
                          Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https', verify_mode: OpenSSL::SSL::VERIFY_NONE).request_get(uri.path) do |response|
                            unless response.is_a?(Net::HTTPSuccess)
                              raise "Download failed: #{response.code} #{response.message}: #{response.body if response.response_body_permitted?}"
                  Severity: Minor
                  Found in lib/ruboto/util/setup.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 android_package_directory has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def android_package_directory
                          return ENV['ANDROID_SDK'] if ENV['ANDROID_SDK']
                          return ENV['ANDROID_HOME'] if ENV['ANDROID_HOME']
                          adb_location = which('adb')
                          return File.dirname(File.dirname(Pathname.new(adb_location).realpath)) if adb_location
                  Severity: Minor
                  Found in lib/ruboto/util/setup.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

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

                              if Dir.exist?(ENV['JAVA_HOME'])
                                @javac_loc = "#{ENV['JAVA_HOME'].gsub('\\', '/')}/bin/javac"
                                puts "Setting the JAVA_HOME environment variable to #{ENV['JAVA_HOME']}"
                                system %Q{setx JAVA_HOME "#{ENV['JAVA_HOME']}"}
                                @missing_paths << "#{File.dirname(@javac_loc)}"
                  Severity: Minor
                  Found in lib/ruboto/util/setup.rb and 1 other location - About 40 mins to fix
                  lib/ruboto/util/setup.rb on lines 471..475

                  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 37.

                  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

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

                              if Dir.exist?(ENV['ANT_HOME'])
                                @ant_loc = "#{ENV['ANT_HOME'].gsub('\\', '/')}/bin/ant"
                                puts "Setting the ANT_HOME environment variable to #{ENV['ANT_HOME']}"
                                system %Q{setx ANT_HOME "#{ENV['ANT_HOME']}"}
                                @missing_paths << "#{File.dirname(@ant_loc)}"
                  Severity: Minor
                  Found in lib/ruboto/util/setup.rb and 1 other location - About 40 mins to fix
                  lib/ruboto/util/setup.rb on lines 408..412

                  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 37.

                  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

                  There are no issues that match your filters.

                  Category
                  Status