mrkamel/swift_client

View on GitHub

Showing 12 of 12 total issues

Method authenticate_v3 has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

  def authenticate_v3
    raise(AuthenticationError, "auth_url missing") unless options[:auth_url]
    raise(AuthenticationError, "username in combination with domain/domain_id is deprecated, please use user_domain/user_domain_id instead") if options[:username] && (options[:domain] || options[:domain_id]) && !options[:user_domain] && !options[:user_domain_id]

    auth = { "auth" => { "identity" => {} } }
Severity: Minor
Found in lib/swift_client.rb - About 5 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 SwiftClient has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

class SwiftClient
  class AuthenticationError < StandardError; end
  class OptionError < StandardError; end
  class EmptyNameError < StandardError; end
  class TempUrlKeyMissing < StandardError; end
Severity: Minor
Found in lib/swift_client.rb - About 4 hrs to fix

    File swift_client.rb has 258 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "swift_client/version"
    require "swift_client/null_cache"
    
    require "httparty"
    require "mime-types"
    Severity: Minor
    Found in lib/swift_client.rb - About 2 hrs to fix

      Method put_object has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def put_object(object_name, data_or_io, container_name, headers = {}, options = {})
          raise(EmptyNameError) if object_name.empty? || container_name.empty?
      
          mime_type = MIME::Types.of(object_name).first
      
      
      Severity: Minor
      Found in lib/swift_client.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 authenticate_v3 has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def authenticate_v3
          raise(AuthenticationError, "auth_url missing") unless options[:auth_url]
          raise(AuthenticationError, "username in combination with domain/domain_id is deprecated, please use user_domain/user_domain_id instead") if options[:username] && (options[:domain] || options[:domain_id]) && !options[:user_domain] && !options[:user_domain_id]
      
          auth = { "auth" => { "identity" => {} } }
      Severity: Minor
      Found in lib/swift_client.rb - About 1 hr to fix

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

          def authenticate_v2
            [:auth_url, :storage_url].each do |key|
              raise(AuthenticationError, "#{key} missing") unless options[key]
            end
        
        
        Severity: Minor
        Found in lib/swift_client.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 request has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def request(method, path, opts = {}, &block)
            headers = (opts[:headers] || {}).dup
            headers["X-Auth-Token"] = auth_token
            headers["Accept"] ||= "application/json" unless opts.delete(:json) == false
        
        
        Severity: Minor
        Found in lib/swift_client.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 paginate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def paginate(method, *args, query, options)
            return enum_for(:paginate, method, *args, query, options) unless block_given?
        
            marker = nil
        
        
        Severity: Minor
        Found in lib/swift_client.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 put_object has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def put_object(object_name, data_or_io, container_name, headers = {}, options = {})
        Severity: Minor
        Found in lib/swift_client.rb - About 35 mins to fix

          Method authenticate_v1 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def authenticate_v1
              [:auth_url, :username, :api_key].each do |key|
                raise(AuthenticationError, "#{key} missing") unless options[key]
              end
          
          
          Severity: Minor
          Found in lib/swift_client.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

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

            def post_object(object_name, container_name, headers = {}, options = {})
              raise(EmptyNameError) if object_name.empty? || container_name.empty?
          
              request :post, "/#{container_name}/#{object_name}", options.merge(:headers => headers)
          Severity: Minor
          Found in lib/swift_client.rb and 1 other location - About 20 mins to fix
          lib/swift_client.rb on lines 132..135

          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 27.

          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 2 locations. Consider refactoring.
          Open

            def post_head(object_name, container_name, _headers = {}, options = {})
              raise(EmptyNameError) if object_name.empty? || container_name.empty?
          
              request :post, "/#{container_name}/#{object_name}", options.merge(headers: _headers)
          Severity: Minor
          Found in lib/swift_client.rb and 1 other location - About 20 mins to fix
          lib/swift_client.rb on lines 114..117

          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 27.

          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

          Severity
          Category
          Status
          Source
          Language