Showing 112 of 112 total issues
File app.rb
has 460 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'tempfile'
require 'digest/md5'
require 'amahi_api'
require 'command'
require 'downloader'
File share.rb
has 398 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'command'
require 'platform'
require 'temp_cache'
class Share < ApplicationRecord
Method install_bg
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
def install_bg
# Change permissions of docker.sock file
if Rails.env=="production"
cmd = Command.new("chmod 666 /var/run/docker.sock")
cmd.execute
- 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
File platform.rb
has 374 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'downloader'
class Platform
# upstart conf file for an ubuntu system
File jquery.ui.templates.js
has 356 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*!
* jQuery Templates Plugin 1.0.0pre
* http://github.com/jquery/jquery-tmpl
* Requires jQuery 1.4.2
*
Method install_bg
has 103 lines of code (exceeds 25 allowed). Consider refactoring. Open
def install_bg
# Change permissions of docker.sock file
if Rails.env=="production"
cmd = Command.new("chmod 666 /var/run/docker.sock")
cmd.execute
Method create_config_file
has 102 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_config_file
root = "plugins/#{plural_name}"
# FIXME bug in thor?
# destination_root="#{Rails.root}/plugins/#{plural_name}"
Class App
has 32 methods (exceeds 20 allowed). Consider refactoring. Open
class App < ApplicationRecord
# App and Log storage path is different for both production and development environment.
BASE_PORT = 35000
if Rails.env == "production"
Class Share
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
class Share < ApplicationRecord
DEFAULT_SHARES_ROOT = '/var/hda/files'
SIGNATURE = "Amahi configuration"
Method share_conf
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def share_conf
ret = "[%s]\n" \
"\tcomment = %s\n" \
"\tpath = %s\n" \
"\twriteable = %s\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 set_platform
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def set_platform
if File.exist?('/etc/amahi-release')
line = nil
File.open("/etc/amahi-release", "r") do |issue|
line = issue.gets
- 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
Class Platform
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class Platform
# upstart conf file for an ubuntu system
UPSTART_CONF = "/etc/init/%s.conf"
Method platform_versions
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def platform_versions
platform = ""
hda_ctl = ""
if fedora? or centos?
open("|rpm -q hda-platform hda-ctl") do |f|
- 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 locate_search
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def locate_search(term, filter, page, rpp)
base = Share.basenames
# lines to skip
skip = (page - 1) * rpp
open locate_cache(term) do |l|
- 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
Class ApplicationController
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class ApplicationController < ActionController::Base
require 'ipaddr'
protect_from_forgery with: :exception
before_action :before_action_hook
File share_controller.rb
has 283 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'partition_utils'
class ShareController < ApplicationController
before_action :admin_required
Method read_lease
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def self.read_lease(file)
res = {}
return res unless File.exists?(file)
current = {}
File.foreach(file) do |l|
- 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
Class ShareController
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class ShareController < ApplicationController
before_action :admin_required
VALID_NAME = Regexp.new "\A\\w[\\w ]+\z"
# Disk Pool minimum free: default og 10GB, but for root,
Class SharesController
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class SharesController < ApplicationController
before_action :admin_required
before_action :get_share
Method header_pdc
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.header_pdc(domain)
short_domain = Setting.shares.value_by_name("workgroup") || 'workgroup'
debug = Setting.shares.value_by_name('debug') == '1'
admins = User.admins rescue ["no_such_user"]
ret = ["# This file is automatically generated for PDC setup.",