Showing 108 of 803 total issues
Method virtual_server_properties
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def virtual_server_properties(virtual_server)
params = [
{
:parameter => t('admin.virtual_servers.form.create_server.field.identity'),
:value => virtual_server.identity,
- 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 load_data
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def load_data
virtual_server = VirtualServer.find_by_id(params[:id])
redirect_to :controller => 'dashboard' and return if !virtual_server or !@current_user.can_control(virtual_server)
render :json => { :success => true, :data => {
- 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 get_stats
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_stats
[
[
'user.png',
t('admin.dashboard.stats_grid.parameter.panel_users'),
Method save_physically
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def save_physically
return false if !valid?
content = ""
content << 'ONBOOT="' + (start_on_boot ? "yes" : "no") + '"' + "\n"
Method create_backup
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.create_backup(virtual_server, ve_state, description)
orig_ve_state = virtual_server.state
if 'running' == orig_ve_state
case ve_state
when 'suspend' then virtual_server.suspend
Method owp_ConfigOptions
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function owp_ConfigOptions()
{
$nodes = array();
$serverTemplates = array();
$osTempates = array();
Method _owp_apiCall
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _owp_apiCall($method, $params = '')
{
$queryResult = mysql_query("SELECT * FROM `tblservers` WHERE `type` = 'owp' LIMIT 1");
$serverInfo = mysql_fetch_array($queryResult);
Method get_virtual_servers_map
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_virtual_servers_map(virtual_servers)
virtual_servers = virtual_servers.map do |virtual_server|
{
:id => virtual_server.id,
:identity => virtual_server.identity,
- 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 validate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def validate
return if 0 == IpPool.count or ip_address.blank? or !ip_address_changed?
return if 'auto' == ip_address
old_ips = ip_address_was.blank? ? [] : ip_address_was.split(' ')
- 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 collect_beancounters
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def collect_beancounters(hardware_server)
counters = hardware_server.rpc_client.exec('cat', "/proc/user_beancounters")['output'].split("\n")
# remove table titles
counters.shift; counters.shift
Method collect_cpu_usage
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def collect_cpu_usage(hardware_server)
ve_list = hardware_server.virtual_servers.find_all_by_state('running').map(&:identity).join(' ')
command = "for VE in #{ve_list}; do echo $VE `vzctl exec $VE 'cat /proc/stat | head -1'`; done"
counters = hardware_server.rpc_client.exec(command)['output'].split("\n")
Method clone_physically
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def clone_physically(orig_server)
return false if !valid?
path = '/etc/vz/conf'
hardware_server.rpc_client.exec("cp #{shellescape(path)}/#{shellescape(orig_server.identity.to_s)}.conf #{shellescape(path)}/#{shellescape(identity.to_s)}.conf")
- 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 save_limits
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def save_limits(limits)
orig_limits = get_limits
vzctl_params = ''
limits.each do |limit|
orig_limit = orig_limits.find { |item| item[:name] == limit['name'] }
- 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 connect
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def connect(root_password = '')
if !auth_key.blank?
begin
if !rpc_client.ping
self.errors.add :auth_key, :bad_auth
- 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 load_config
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def load_config
file = File.new(CONFIG_FILE, 'r')
while (line = file.gets)
key, value = line.split('=', 2).each { |v| v.strip! }
- 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 prepare_daemon_config
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def prepare_daemon_config(sftp, config_file)
if !sftp_file_readable(sftp, config_file)
upload_daemon_config(sftp, config_file)
else
sftp.file.open(config_file, "r") do |file|
- 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 objects_group_operation
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def objects_group_operation(model, operation, &access)
success = true
params[:ids].split(',').each do |id|
object = model.find(id)
- 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 collect_cpu_usage
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def collect_cpu_usage(hardware_server)
ve_list = hardware_server.virtual_servers.find_all_by_state('running').map(&:identity).join(' ')
command = "for VE in #{ve_list}; do echo $VE `vzctl exec $VE 'cat /proc/stat | head -1'`; done"
counters = hardware_server.rpc_client.exec(command)['output'].split("\n")
- 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 update
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def update
role = (params[:id].to_i > 0) ? Role.find_by_id(params[:id]) : Role.new
is_new = role.new_record?
role.attributes = params
- 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 get_ram_mb
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def get_ram_mb(limit)
return 0 if limit.blank?
limit = limit.include?(':') ? limit.split(":").last : limit
return 0 if ('unlimited' == limit)
- 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"