Showing 13 of 13 total issues
Class Attacher
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class Attacher
attr_reader :definition, :record, :errors
attr_accessor :remove
Presence = ->(val) { val if val != "" }
Method new
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def self.new(collection_name, collection_class:, name:, attachment:, append:, &block)
Module.new do
define_method :"#{name}_attachment_definition" do
collection_class.send("#{attachment}_attachment_definition")
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 attachment
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
def attachment(name, cache: :cache, store: :store, raise_errors: true, type: nil, extension: nil, content_type: nil)
definition = AttachmentDefinition.new(name,
cache: cache,
store: store,
raise_errors: raise_errors,
Function requests
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
var requests = [].map.call(input.files, function(file, index) {
function dispatchEvent(element, name, progress) {
var ev = document.createEvent('CustomEvent');
ev.initCustomEvent(name, true, false, { xhr: xhr, file: file, index: index, progress: progress });
element.dispatchEvent(ev);
Method new
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.new(collection_name, collection_class:, name:, attachment:, append:, &block)
Module.new do
define_method :"#{name}_attachment_definition" do
collection_class.send("#{attachment}_attachment_definition")
end
Method attachment
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def attachment(name, raise_errors: false, destroy: true, **options)
super(name, raise_errors: raise_errors, **options)
attacher = "#{name}_attacher"
Method download
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def download(url)
unless url.to_s.empty?
download = Refile::Download.new(url)
@metadata = {
size: download.size,
- 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 verify_uploadable
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def verify_uploadable(method)
mod = Module.new do
define_method(method) do |uploadable|
[:size, :read, :eof?, :rewind, :close].each do |m|
unless uploadable.respond_to?(m)
- 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 7 (exceeds 5 allowed). Consider refactoring. Open
def validate(attacher)
extension = attacher.extension.to_s.downcase
content_type = attacher.content_type.to_s.downcase
content_type = content_type.split(";").first unless content_type.empty?
- 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 file_url
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def file_url(file, *args, expires_at: nil, host: nil, prefix: nil, filename:, format: nil, force_download: nil)
return unless file
host ||= Refile.cdn_host
backend_name = Refile.backends.key(file.backend)
- 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 extract_content_type
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def extract_content_type(uploadable)
if uploadable.respond_to?(:content_type)
uploadable.content_type
else
filename = extract_filename(uploadable)
- 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 attachment
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def attachment(name, raise_errors: false, destroy: true, **options)
super(name, raise_errors: raise_errors, **options)
attacher = "#{name}_attacher"
- 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 download
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def download(uri)
uri = ensure_uri(uri)
follows_remaining = 10
begin
- 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"