grokify/ringcentral-sdk-ruby

View on GitHub

Showing 18 of 127 total issues

Class Subscription has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Subscription
      include Observable

      RENEW_HANDICAP = 60

Severity: Minor
Found in lib/ringcentral_sdk/rest/subscription.rb - About 2 hrs to fix

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

          def new_type_count(type)
            count = 0
            have_type = false
            changes = @doc.getAttr('body.changes')
            if changes.is_a?(Array) && !changes.empty?
    Severity: Minor
    Found in lib/ringcentral_sdk/rest/event.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 load_environment has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def load_environment
            Dotenv.load
            @server_url    = ENV['RINGCENTRAL_SERVER_URL']    if ENV.key? 'RINGCENTRAL_SERVER_URL'
            @app_key       = ENV['RINGCENTRAL_CLIENT_ID']     if ENV.key? 'RINGCENTRAL_CLIENT_ID'
            @app_secret    = ENV['RINGCENTRAL_CLIENT_SECRET'] if ENV.key? 'RINGCENTRAL_CLIENT_SECRET'
    Severity: Minor
    Found in lib/ringcentral_sdk/rest/configuration.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 get_department_members has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

            def get_department_members(department_id)
              department_id = department_id.to_s unless department_id.is_a? String
              if department_id !~ /^[0-9]+$/
                raise 'department_id parameter must be a positive integer'
              end
    Severity: Minor
    Found in lib/ringcentral_sdk/rest/cache/extensions.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 set_token has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def set_token(token)
            if token.is_a? Hash
              token = OAuth2::AccessToken.from_hash(@oauth2client, token)
            end
    
    
    Severity: Minor
    Found in lib/ringcentral_sdk/rest/client.rb - About 1 hr to fix

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

            def build_url(path)
              path = [path] unless path.is_a? Array
      
              unless path.empty?
                path0 = path[0].to_s
      Severity: Minor
      Found in lib/ringcentral_sdk/rest/simple_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 create_url has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def create_url(url, add_server = false, add_method = nil, add_token = false)
              built_url = ''
              has_http = !url.index('http://').nil? && !url.index('https://').nil?
      
              built_url += @config.server_url if add_server && !has_http
      Severity: Minor
      Found in lib/ringcentral_sdk/rest/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 inflate_retry has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def inflate_retry
              if !defined?(@retry) || @retry.nil?
                @retry = false
              elsif @retry.is_a? String
                @retry = @retry.to_s.strip.downcase == 'true' ? true : false
      Severity: Minor
      Found in lib/ringcentral_sdk/rest/configuration.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 _subscribe_at_pubnub has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def _subscribe_at_pubnub
              raise 'Subscription is not alive' unless alive?
      
              s_key = @_subscription['deliveryMode']['subscriberKey']
      
      
      Severity: Minor
      Found in lib/ringcentral_sdk/rest/subscription.rb - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

                if
                  (s.key?('deliveryMode') && s['deliveryMode']) \
                  && (s['deliveryMode'].key?('subscriberKey') && s['deliveryMode']['subscriberKey']) \
                  && (
                    s['deliveryMode'].key?('address') \
        Severity: Major
        Found in lib/ringcentral_sdk/rest/subscription.rb - About 1 hr to fix

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

                def send(request)
                  return @client.request(request) if request.is_a? RingCentralSdk::Helpers::Request
                  raise(ArgumentError, 'Request is not a ...Helpers::Request or Hash') unless request.is_a? Hash
          
                  verb = request.key?(:verb) ? request[:verb].to_s.downcase : 'get'
          Severity: Minor
          Found in lib/ringcentral_sdk/rest/simple_client.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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def create(opts)
                  req  = RingCentralSdk::REST::Request::Fax.new
                  meta = {}
          
                  skip = {text: 1, files: 1}
          Severity: Minor
          Found in lib/ringcentral_sdk/rest/messages.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 inflate_token has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def inflate_token
                  @token = nil unless defined? @token
          
                  if (@token.nil? || @token.empty?) && !token_file.nil? && !@token_file.empty?
                    @token = IO.read @token_file if File.exist? @token_file
          Severity: Minor
          Found in lib/ringcentral_sdk/rest/configuration.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 retrieve has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                  def retrieve(params = {}, retrieve_all = true)
                    @last_retrieved = Time.now.to_i
                    uri = URI.parse "account/#{@account_id}/extension"
                    uri.query = URI.encode_www_form(params) unless params.empty?
                    res = @client.http.get do |req|
          Severity: Minor
          Found in lib/ringcentral_sdk/rest/cache/extensions.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 set_token has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def set_token(token)
                  if token.is_a? Hash
                    token = OAuth2::AccessToken.from_hash(@oauth2client, token)
                  end
          
          
          Severity: Minor
          Found in lib/ringcentral_sdk/rest/client.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

          Avoid too many return statements within this method.
          Open

                  return delete(request) if verb == 'delete'
          Severity: Major
          Found in lib/ringcentral_sdk/rest/simple_client.rb - About 30 mins to fix

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

                    def initialize(opts = {})
                      @method = opts[:method]
                      @url = opts[:url]
                      @params = opts[:params]
                      @headers = opts[:headers]
            Severity: Minor
            Found in lib/ringcentral_sdk/rest/request/simple.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 inflate_retry_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def inflate_retry_options
                    if @retry == false
                      @retry_options = {}
                      return
                    end
            Severity: Minor
            Found in lib/ringcentral_sdk/rest/configuration.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

            Severity
            Category
            Status
            Source
            Language