Class Backup
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class Api::Backup < ActiveRecord::Base
belongs_to :crowbar
attr_accessor :file
- Create a ticketCreate a ticket
Method save_archive
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def save_archive
if file.nil?
errors.add_on_blank :file
return false
end
- Create a ticketCreate a ticket
Method restore
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def restore(options = {})
background = options.fetch(:background, false)
from_upgrade = options.fetch(:from_upgrade, false)
if Crowbar::Backup::Restore.restore_steps_path.exist?
- Read upRead up
- Create a ticketCreate a ticket
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_archive
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def save_archive
if file.nil?
errors.add_on_blank :file
return false
end
- Read upRead up
- Create a ticketCreate a ticket
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_chef_file_extension
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validate_chef_file_extension
Dir.glob(data.join("knife", "**", "*")).each do |file|
next if Pathname.new(file).directory?
next if File.extname(file) == ".json"
errors.add(:base, I18n.t("backups.validation.non_json_file"))
- Read upRead up
- Create a ticketCreate a ticket
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"