gooddata/gooddata-ruby

View on GitHub
lib/gooddata/rest/connection.rb

Summary

Maintainability
F
4 days
Test Coverage

File connection.rb has 551 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'terminal-table'
require 'securerandom'
require 'monitor'
require 'thread_safe'
require 'rest-client'
Severity: Major
Found in lib/gooddata/rest/connection.rb - About 1 day to fix

    Class Connection has 38 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Connection
          include MonitorMixin
    
          HTTPS_PROTOCOL = 'https://'
          HTTP_PROTOCOL = 'http://'
    Severity: Minor
    Found in lib/gooddata/rest/connection.rb - About 5 hrs to fix

      Method process_response has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

            def process_response(options = {}, &block)
              retries = options[:tries] || Helpers::GD_MAX_RETRY
              process = options[:process]
              dont_reauth = options[:dont_reauth]
              options = options.reject { |k, _| [:process, :dont_reauth].include?(k) }
      Severity: Minor
      Found in lib/gooddata/rest/connection.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 connect has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def connect(username, password, options = {})
              server = options[:server] || Helpers::AuthHelper.read_server
              options = DEFAULT_LOGIN_PAYLOAD.merge(options)
              headers = options[:headers] || {}
      
      
      Severity: Minor
      Found in lib/gooddata/rest/connection.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 retryable has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

              def retryable(options = {}, &_block)
                opts = { :tries => 12, :on => RETRYABLE_ERRORS }.merge(options)
      
                retry_exception = opts[:on]
                retries = opts[:tries]
      Severity: Minor
      Found in lib/gooddata/rest/connection.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 download has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

            def download(what, where, options = {})
              # handle the path (directory) given in what
              ilast_slash = what.rindex('/')
              if ilast_slash.nil?
                what_dir = ''
      Severity: Minor
      Found in lib/gooddata/rest/connection.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 connect has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def connect(username, password, options = {})
              server = options[:server] || Helpers::AuthHelper.read_server
              options = DEFAULT_LOGIN_PAYLOAD.merge(options)
              headers = options[:headers] || {}
      
      
      Severity: Minor
      Found in lib/gooddata/rest/connection.rb - About 1 hr to fix

        Method download has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def download(what, where, options = {})
                # handle the path (directory) given in what
                ilast_slash = what.rindex('/')
                if ilast_slash.nil?
                  what_dir = ''
        Severity: Minor
        Found in lib/gooddata/rest/connection.rb - About 1 hr to fix

          Method process_response has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def process_response(options = {}, &block)
                  retries = options[:tries] || Helpers::GD_MAX_RETRY
                  process = options[:process]
                  dont_reauth = options[:dont_reauth]
                  options = options.reject { |k, _| [:process, :dont_reauth].include?(k) }
          Severity: Minor
          Found in lib/gooddata/rest/connection.rb - About 1 hr to fix

            Method stats_table has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def stats_table(values = stats)
                    sorted = values.sort_by { |_k, v| v[:avg] }
                    Terminal::Table.new :headings => %w(title avg min max total calls) do |t|
                      overall = {
                        :avg => 0,
            Severity: Minor
            Found in lib/gooddata/rest/connection.rb - About 1 hr to fix

              Method add_stat_record has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def add_stat_record(method, path, delta, time_stamp, request_id)
                      synchronize do
                        orig_title = "#{method.to_s.upcase} #{path}"
                        title = "#{method.to_s.upcase} #{path}"
              
              
              Severity: Minor
              Found in lib/gooddata/rest/connection.rb - About 1 hr to fix

                Method retryable has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        def retryable(options = {}, &_block)
                          opts = { :tries => 12, :on => RETRYABLE_ERRORS }.merge(options)
                
                          retry_exception = opts[:on]
                          retries = opts[:tries]
                Severity: Minor
                Found in lib/gooddata/rest/connection.rb - About 1 hr to fix

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

                        def add_stat_record(method, path, delta, time_stamp, request_id)
                          synchronize do
                            orig_title = "#{method.to_s.upcase} #{path}"
                            title = "#{method.to_s.upcase} #{path}"
                  
                  
                  Severity: Minor
                  Found in lib/gooddata/rest/connection.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 add_stat_record has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                        def add_stat_record(method, path, delta, time_stamp, request_id)
                  Severity: Minor
                  Found in lib/gooddata/rest/connection.rb - About 35 mins to fix

                    Method request has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                          def request(method, uri, data, options = {}, &user_block)
                    Severity: Minor
                    Found in lib/gooddata/rest/connection.rb - About 35 mins to fix

                      Method profile has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                            def profile(method, path, request_id, stats_on, &block)
                      Severity: Minor
                      Found in lib/gooddata/rest/connection.rb - About 35 mins to fix

                        Method format_error has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def format_error(e, params = {})
                                return e unless e.respond_to?(:response)
                                error = MultiJson.load(e.response)
                                message = GoodData::Helpers.interpolate_error_message(error)
                                if error && error['error'] && error['error']['errorClass'] == 'com.gooddata.security.authorization.AuthorizationFailedException'
                        Severity: Minor
                        Found in lib/gooddata/rest/connection.rb - About 35 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 stats_table has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def stats_table(values = stats)
                                sorted = values.sort_by { |_k, v| v[:avg] }
                                Terminal::Table.new :headings => %w(title avg min max total calls) do |t|
                                  overall = {
                                    :avg => 0,
                        Severity: Minor
                        Found in lib/gooddata/rest/connection.rb - About 35 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 enrich_error_message has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def enrich_error_message(exception)
                                begin
                                  return exception unless exception.response
                        
                                  response = JSON.parse(exception.response.body, symbolize_names: true)
                        Severity: Minor
                        Found in lib/gooddata/rest/connection.rb - About 35 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 request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def request(method, uri, data, options = {}, &user_block)
                                request_id = options[:request_id] || generate_request_id
                                log_info(options.merge(request_id: request_id))
                                stats_on = options[:stats_on]
                        
                        
                        Severity: Minor
                        Found in lib/gooddata/rest/connection.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

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

                              def disconnect
                                # TODO: Wrap somehow
                                url = @auth['state']
                        
                                begin
                        Severity: Minor
                        Found in lib/gooddata/rest/connection.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