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'
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
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
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"
Method uninstall_bg
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def uninstall_bg
if Rails.env=="production"
cmd = Command.new("chmod 666 /var/run/docker.sock")
cmd.execute
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 uninstall_bg
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def uninstall_bg
if Rails.env=="production"
cmd = Command.new("chmod 666 /var/run/docker.sock")
cmd.execute
end
Method install_theme
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def install_theme(installer, source)
return if (installer.source_url.nil? or installer.source_url.blank?)
dir = 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 install_webapp
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def install_webapp(installer, source)
name = webapp_name(installer.url_name)
path = WEBAPP_PATH % 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
Avoid too many return
statements within this method. Open
return false
Method check_availability
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.check_availability
progress = Rails.cache.read("progress")
return true if progress.blank?
return true if progress == 999
- 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"