carrierwaveuploader/carrierwave

View on GitHub
lib/carrierwave/uploader/versions.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Method build_version has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def build_version(name, options)
          if !versions.has_key?(name)
            uploader = Class.new(self)
            const_set("Uploader#{uploader.object_id}".tr('-', '_'), uploader)
            uploader.version_names += [name]
Severity: Minor
Found in lib/carrierwave/uploader/versions.rb - About 1 hr to fix

    Method version_exists? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

          def version_exists?(name)
            name = name.to_sym
    
            return false unless self.class.versions.has_key?(name)
    
    
    Severity: Minor
    Found in lib/carrierwave/uploader/versions.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 source_versions_of has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def source_versions_of(requested_names)
            versions.inject([]) do |sources, (name, uploader)|
              next sources unless requested_names.include?(name)
              next sources unless source_name = uploader.class.version_options[:from_version]
    
    
    Severity: Minor
    Found in lib/carrierwave/uploader/versions.rb - About 45 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 url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def url(*args)
            if (version = args.first) && version.respond_to?(:to_sym)
              raise ArgumentError, "Version #{version} doesn't exist!" if versions[version.to_sym].nil?
              # recursively proxy to version
              versions[version.to_sym].url(*args[1..-1])
    Severity: Minor
    Found in lib/carrierwave/uploader/versions.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

    There are no issues that match your filters.

    Category
    Status