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'
Class Installer
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class Installer
attr_reader :xcodes
def initialize
FileUtils.mkdir_p(CACHE_DIR)
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'
- Read upRead up
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'
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)
- Read upRead up
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,
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)
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
- Read upRead up
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|
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))
- Read upRead up
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|
- Read upRead up
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)
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)
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
- Read upRead up
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
- Read upRead up
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
Avoid too many return
statements within this method. Open
return 1 if !is_first_rc && is_second_rc
Avoid too many return
statements within this method. Open
return 1 if !is_first_gm && is_second_gm
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
- Read upRead up
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 a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def fetch(url: nil,
directory: nil,
cookies: nil,
output: nil,
progress: nil,
- Read upRead up
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 list_annotated
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def list_annotated(xcodes_list)
installed = installed_versions.map(&:appname_version)
xcodes_list.map do |x|
xcode_version = x.split(' ') # split version and "beta N", "for Lion"
- Read upRead up
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"