qiniu/ruby-sdk

View on GitHub

Showing 39 of 47 total issues

Method _resumable_put_block has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

        def _resumable_put_block(bucket,
                                 uptoken,
                                 fh,
                                 block_index,
                                 block_size,
Severity: Minor
Found in lib/qiniu/resumable_upload.rb - About 4 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 send_request_with has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

      def send_request_with url, data = nil, options = {}
        options[:method] = Config.settings[:method] unless options[:method]
        options[:content_type] = Config.settings[:content_type] unless options[:content_type]
        header_options = {
          :accept => :json,
Severity: Minor
Found in lib/qiniu/utils.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

Method http_request has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

      def http_request url, data = nil, options = {}
        retry_times = 0
        begin
          retry_times += 1
          send_request_with url, data, options
Severity: Minor
Found in lib/qiniu/utils.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

File resumable_upload.rb has 272 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'zlib'
require 'yaml'
require 'tmpdir'
require 'fileutils'
require 'mime/types'
Severity: Minor
Found in lib/qiniu/resumable_upload.rb - About 2 hrs to fix

    Method _resumable_put_block has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def _resumable_put_block(bucket,
                                     uptoken,
                                     fh,
                                     block_index,
                                     block_size,
    Severity: Major
    Found in lib/qiniu/resumable_upload.rb - About 2 hrs to fix

      Method _resumable_put has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

              def _resumable_put(bucket,
                                 uptoken,
                                 fh,
                                 checksums,
                                 progresses,
      Severity: Minor
      Found in lib/qiniu/resumable_upload.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 upload_buffer_with_token has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

            def upload_buffer_with_token(uptoken,
                                    buf,
                                    key = nil,
                                    x_vars = nil,
                                    opts = {})
      Severity: Minor
      Found in lib/qiniu/upload.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 generate_signature has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

              def generate_signature
                params = {:scope => @scope, :deadline => Time.now.to_i + @expires_in}
                params[:callbackUrl] = @callback_url if !@callback_url.nil? && !@callback_url.empty?
                params[:callbackBody] = @callback_body if !@callback_body.nil? && !@callback_body.empty?
                params[:callbackBodyType] = @callback_body_type if !@callback_body_type.nil? && !@callback_body_type.empty?
      Severity: Minor
      Found in lib/qiniu/tokens/upload_token.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 _generate_action_params has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def _generate_action_params(local_file,
                                        bucket,
                                        key = nil,
                                        mime_type = nil,
                                        custom_meta = nil,
      Severity: Minor
      Found in lib/qiniu/upload.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 upload_buffer_with_token has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def upload_buffer_with_token(uptoken,
                                    buf,
                                    key = nil,
                                    x_vars = nil,
                                    opts = {})
      Severity: Minor
      Found in lib/qiniu/upload.rb - About 1 hr to fix

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

              def send_request_with url, data = nil, options = {}
                options[:method] = Config.settings[:method] unless options[:method]
                options[:content_type] = Config.settings[:content_type] unless options[:content_type]
                header_options = {
                  :accept => :json,
        Severity: Minor
        Found in lib/qiniu/utils.rb - About 1 hr to fix

          Method _mkfile has 10 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  def _mkfile(uphost,
                              uptoken,
                              entry_uri,
                              fsize,
                              checksums,
          Severity: Major
          Found in lib/qiniu/resumable_upload.rb - About 1 hr to fix

            Method _resumable_upload has 10 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    def _resumable_upload(uptoken,
                                          fh,
                                          fsize,
                                          bucket,
                                          key,
            Severity: Major
            Found in lib/qiniu/resumable_upload.rb - About 1 hr to fix

              Method resumable_upload_with_token has 9 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      def resumable_upload_with_token(uptoken,
                                            local_file,
                                            bucket,
                                            key = nil,
                                            mime_type = nil,
              Severity: Major
              Found in lib/qiniu/resumable_upload.rb - About 1 hr to fix

                Method _resumable_put_block has 9 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        def _resumable_put_block(bucket,
                                                 uptoken,
                                                 fh,
                                                 block_index,
                                                 block_size,
                Severity: Major
                Found in lib/qiniu/resumable_upload.rb - About 1 hr to fix

                  Method upload_with_token has 9 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                        def upload_with_token(uptoken,
                                              local_file,
                                              bucket,
                                              key = nil,
                                              mime_type = nil,
                  Severity: Major
                  Found in lib/qiniu/upload.rb - About 1 hr to fix

                    Method upload_file has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def upload_file opts = {}
                            uncontained_opts = [:uptoken, :file, :bucket, :key] - opts.keys
                            raise MissingArgsError, uncontained_opts unless uncontained_opts.empty?
                    
                            source_file = opts[:file]
                    Severity: Minor
                    Found in lib/qiniu.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 upload_file has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def upload_file opts = {}
                            uncontained_opts = [:uptoken, :file, :bucket, :key] - opts.keys
                            raise MissingArgsError, uncontained_opts unless uncontained_opts.empty?
                    
                            source_file = opts[:file]
                    Severity: Minor
                    Found in lib/qiniu.rb - About 1 hr to fix

                      Method _resumable_put has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              def _resumable_put(bucket,
                                                 uptoken,
                                                 fh,
                                                 checksums,
                                                 progresses,
                      Severity: Minor
                      Found in lib/qiniu/resumable_upload.rb - About 1 hr to fix

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

                              def upload_with_token_2(uptoken,
                                                      local_file,
                                                      key = nil,
                                                      x_vars = nil,
                                                      opts = {})
                        Severity: Minor
                        Found in lib/qiniu/upload.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

                        Severity
                        Category
                        Status
                        Source
                        Language