neonichu/xcode-install

View on GitHub

Showing 22 of 22 total issues

File install.rb has 610 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'fileutils'
require 'pathname'
require 'rexml/document'
require 'spaceship'
require 'json'
Severity: Major
Found in lib/xcode/install.rb - About 1 day to fix

    Class Installer has 28 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Installer
        attr_reader :xcodes
    
        def initialize
          FileUtils.mkdir_p(CACHE_DIR)
    Severity: Minor
    Found in lib/xcode/install.rb - About 3 hrs to fix

      Method install_dmg has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def install_dmg(dmg_path, suffix = '', switch = true, clean = true)
            prompt = "Please authenticate for Xcode installation.\nPassword: "
            xcode_path = "/Applications/Xcode#{suffix}.app"
      
            if dmg_path.extname == '.xip'
      Severity: Minor
      Found in lib/xcode/install.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_dmg has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def install_dmg(dmg_path, suffix = '', switch = true, clean = true)
            prompt = "Please authenticate for Xcode installation.\nPassword: "
            xcode_path = "/Applications/Xcode#{suffix}.app"
      
            if dmg_path.extname == '.xip'
      Severity: Minor
      Found in lib/xcode/install.rb - About 2 hrs to fix

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

            def poll_file(command_string:, progress_log_file:, progress: nil, progress_block: nil)
              # Non-blocking call of Open3
              # We're not using the block based syntax, as the bacon testing
              # library doesn't seem to support writing tests for it
              stdin, stdout, stderr, wait_thr = Open3.popen3(command_string)
        Severity: Minor
        Found in lib/xcode/install.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 fetch has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def fetch(url: nil,
                      directory: nil,
                      cookies: nil,
                      output: nil,
                      progress: nil,
        Severity: Minor
        Found in lib/xcode/install.rb - About 1 hr to fix

          Method install_version has 9 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def install_version(version, switch = true, clean = true, install = true, progress = true, url = nil, show_release_notes = true, progress_block = nil, retry_download_count = 3)
          Severity: Major
          Found in lib/xcode/install.rb - About 1 hr to fix

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

                def compare_versions(first, second)
                  # Sort by version number
                  numeric_comparation = first.to_f <=> second.to_f
                  return numeric_comparation if numeric_comparation != 0
            
            
            Severity: Minor
            Found in lib/xcode/install.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 validate! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                  def validate!
                    super
            
                    help! 'A VERSION argument is required.' unless @version
                    if @installer.installed?(@version) && !@force
            Severity: Minor
            Found in lib/xcode/install/install.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 prereleases has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def prereleases
                  body = spaceship.send(:request, :get, '/download/').body
            
                  links = body.scan(%r{<a.+?href="(.+?/Xcode.+?/Xcode_(.+?)\.(dmg|xip))".*>(.*)</a>})
                  links = links.map do |link|
            Severity: Minor
            Found in lib/xcode/install.rb - About 1 hr to fix

              Method download has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def download(version, progress, url = nil, progress_block = nil, retry_download_count = 3)
                    xcode = find_xcode_version(version) if url.nil?
                    return if url.nil? && xcode.nil?
              
                    dmg_file = Pathname.new(File.basename(url || xcode.path))
              Severity: Minor
              Found in lib/xcode/install.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 prereleases has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def prereleases
                    body = spaceship.send(:request, :get, '/download/').body
              
                    links = body.scan(%r{<a.+?href="(.+?/Xcode.+?/Xcode_(.+?)\.(dmg|xip))".*>(.*)</a>})
                    links = links.map do |link|
              Severity: Minor
              Found in lib/xcode/install.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 download has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def download(version, progress, url = nil, progress_block = nil, retry_download_count = 3)
              Severity: Minor
              Found in lib/xcode/install.rb - About 35 mins to fix

                Method get_dmg has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def get_dmg(version, progress = true, url = nil, progress_block = nil, retry_download_count = 3)
                Severity: Minor
                Found in lib/xcode/install.rb - About 35 mins to fix

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

                      def get_dmg(version, progress = true, url = nil, progress_block = nil, retry_download_count = 3)
                        if url
                          path = Pathname.new(url)
                          return path if path.exist?
                        end
                  Severity: Minor
                  Found in lib/xcode/install.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 install has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def install(progress, should_install)
                        dmg_path = download(progress)
                        fail Informative, "Failed to download #{@name}." if dmg_path.nil?
                  
                        return unless should_install
                  Severity: Minor
                  Found in lib/xcode/install.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

                  Avoid too many return statements within this method.
                  Open

                        return -1 if is_first_rc && !is_second_rc
                  Severity: Major
                  Found in lib/xcode/install.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                          return 1 if !is_first_rc && is_second_rc
                    Severity: Major
                    Found in lib/xcode/install.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                            return 1 if !is_first_gm && is_second_gm
                      Severity: Major
                      Found in lib/xcode/install.rb - About 30 mins to fix

                        Method find_xcode_version has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def find_xcode_version(version)
                              # By checking for the name and the version we have the best success rate
                              # Sometimes the user might pass
                              #   "4.3 for Lion"
                              # or they might pass an actual Gem::Version
                        Severity: Minor
                        Found in lib/xcode/install.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