rogercampos/saviour

View on GitHub
lib/saviour/file.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Class File has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

  class File
    attr_reader :persisted_path, :source, :storage

    def initialize(uploader_klass, model, attached_as, persisted_path = nil)
      @uploader_klass, @model, @attached_as = uploader_klass, model, attached_as
Severity: Minor
Found in lib/saviour/file.rb - About 2 hrs to fix

    Method write has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def write(before_write: nil)
          raise(MissingSource, "You must provide a source to read from before trying to write") unless @source
    
          __maybe_with_tmpfile(source_type, @source) do |tmpfile|
            contents, path = case source_type
    Severity: Minor
    Found in lib/saviour/file.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 assign has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def assign(object)
          raise(SourceError, "given object to #assign or #<attach_as>= must respond to `read`") if object && !object.respond_to?(:read)
    
          followers = @model.class.followers_per_leader_config[@attached_as]
    
    
    Severity: Minor
    Found in lib/saviour/file.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 == has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def ==(another_file)
          return false unless another_file.is_a?(Saviour::File)
          return false unless another_file.persisted? == persisted?
    
          if persisted?
    Severity: Minor
    Found in lib/saviour/file.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