ksylvest/attached

View on GitHub

Showing 10 of 10 total issues

Method assign has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def assign(file, identifier = Identifier.generate)
      self.file = file

      if file
        extension ||= file.extension if file.respond_to? :extension
Severity: Minor
Found in lib/attached/attachment.rb - About 3 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

Class Attachment has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Attachment

    attr_reader :file
    attr_reader :name
    attr_reader :instance
Severity: Minor
Found in lib/attached/attachment.rb - About 2 hrs to fix

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

    module Attached
      module Storage
        class Google < Fog
    
          attr_reader :bucket
    Severity: Major
    Found in lib/attached/storage/google.rb and 2 other locations - About 2 hrs to fix
    lib/attached/storage/aws.rb on lines 4..50
    lib/attached/storage/rackspace.rb on lines 4..50

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 87.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

    module Attached
      module Storage
        class Rackspace < Fog
    
          attr_reader :container
    Severity: Major
    Found in lib/attached/storage/rackspace.rb and 2 other locations - About 2 hrs to fix
    lib/attached/storage/aws.rb on lines 4..50
    lib/attached/storage/google.rb on lines 3..48

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 87.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

    module Attached
      module Storage
        class AWS < Fog
    
          attr_reader :bucket
    Severity: Major
    Found in lib/attached/storage/aws.rb and 2 other locations - About 2 hrs to fix
    lib/attached/storage/google.rb on lines 3..48
    lib/attached/storage/rackspace.rb on lines 4..50

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 87.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

        def validates_attached_size(name, options = {})
    
          zero = (0.0 / 1.0)
          infi = (1.0 / 0.0)
    
    
    Severity: Minor
    Found in lib/attached.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 options has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def options(path)
            options = {}
            options[:content_type] = case File.extname(path)
            when /tiff/ then "image/tiff"
            when /tif/  then "image/tiff"
    Severity: Minor
    Found in lib/attached/storage/base.rb - About 1 hr to fix

      Method initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def initialize(file, options = {}, attachment = nil)
              super
              @path      = self.file.path
              @size      = options[:size]
              @quality   = options[:quality]
      Severity: Minor
      Found in lib/attached/processor/image.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 process has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def process
              result = Tempfile.new(["", self.extension])
              result.binmode
              begin
                parameters = []
      Severity: Minor
      Found in lib/attached/processor/image.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

      Avoid too many return statements within this method.
      Open

              when :local then return Attached::Storage::Local.new
      Severity: Major
      Found in lib/attached/storage.rb - About 30 mins to fix
        Severity
        Category
        Status
        Source
        Language