elabs/refile

View on GitHub

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 != "" }
Severity: Minor
Found in lib/refile/attacher.rb - About 3 hrs to fix

    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
    Severity: Minor
    Found in lib/refile/attachment/multiple_attachments.rb - About 2 hrs to fix

    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,
    Severity: Major
    Found in lib/refile/attachment.rb - About 2 hrs to fix

      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);
      Severity: Minor
      Found in app/assets/javascripts/refile.js - About 1 hr to fix

        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
        Severity: Minor
        Found in lib/refile/attachment/multiple_attachments.rb - About 1 hr to fix

          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"
          
          
          Severity: Minor
          Found in lib/refile/attachment/active_record.rb - About 1 hr to fix

            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,
            Severity: Minor
            Found in lib/refile/attacher.rb - About 1 hr to fix

            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)
            Severity: Minor
            Found in lib/refile/backend_macros.rb - About 55 mins to fix

            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?
            
            
            Severity: Minor
            Found in lib/refile/attachment_definition.rb - About 35 mins to fix

            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)
            Severity: Minor
            Found in lib/refile.rb - About 35 mins to fix

            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)
            Severity: Minor
            Found in lib/refile.rb - About 35 mins to fix

            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"
            
            
            Severity: Minor
            Found in lib/refile/attachment/active_record.rb - About 25 mins to fix

            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
            Severity: Minor
            Found in lib/refile/download.rb - About 25 mins to fix

            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

            Severity
            Category
            Status
            Source
            Language