Class ImageSyncService
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
class ImageSyncService
attr_reader :targets, :source, :storage, :asset_path
def initialize source: nil, targets: [], asset_path: nil, storage: nil
@source = source # path
Method load
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def load
unassigned = Resource.unassigned.image
objects =
unassigned.map do |r|
info = Memory.find_by(short_name: r[:props]['short_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 info
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def info file
imageinfo = `identify "#{esc(file)}" 2>&1`.strip
fileinfo = `file -- "#{esc(file)}" 2>&1`.strip
unless /(?<type>GIF|JPEG|WEBP|PNG|BMP3?) (?<width>\d+)x(?<height>\d+)/ =~ imageinfo
- 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
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def load
unassigned = Resource.unassigned.image
objects =
unassigned.map do |r|
info = Memory.find_by(short_name: r[:props]['short_name'])
Method attrs
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def attrs
@attrs ||=
folders.map do |folder|
fbase = File.basename(folder)
target_path = File.join(now.strftime("%Y"), now.strftime("%m"), now.strftime("%Y%m%d%H%M%S"))
Method copy
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def copy source, target, type, kind, scheme
Method validates
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validates scheme
scheme[:attrs].each do |a|
duped = duped(a)
error("Invalid height of image file #{a[:source]}") if a[:kind] == :invalid
- 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 initialize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def initialize source: nil, targets: [], asset_path: nil, storage: nil
@source = source # path
@targets = targets # paths
@asset_path = asset_path || '/images'
@storage = Rails.root.join(storage || 'public/images')
- 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
dynamic constant assignment
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
KEYS = %i(short_name comment imageinfo fileinfo kind width height hash event)
- Exclude checks
unexpected token kDO_BLOCK
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
Dir.chdir(resource_path) do
- Exclude checks
unexpected token tRBRACK
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
[type&.downcase&.to_sym, imageinfo, fileinfo, kind, width.to_i, height.to_i]
- Exclude checks
unexpected token error
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
time = Resource.order(updated_at: :desc).first&.updated_at || Time.at(0) # last for updated_at or settingize
- Exclude checks
unexpected token kEND
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
end
- Exclude checks
unexpected token error
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
[type&.downcase&.to_sym, imageinfo, fileinfo, kind, width.to_i, height.to_i]
- Exclude checks
unexpected token kDO_BLOCK
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
Dir['.schemes/**/*.yaml'].select do |f|
- Exclude checks