sparkapi/spark_api

View on GitHub

Showing 27 of 40 total issues

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

      def request(method, path, body, options)
        escaped_path = Addressable::URI.escape(path)
        connection = @client.connection
        connection.headers.merge!(options.delete(:override_headers) || {})
        request_opts = {
Severity: Minor
Found in lib/spark_api/authentication/api_auth.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 save! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def save!(arguments={})
        # The long-term idea is that any setting in the user's account could be updated by including
        # an attribute and calling PUT /my/account, but for now only the GetEmailUpdates attribute 
        # is supported
        
Severity: Minor
Found in lib/spark_api/models/account.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 find_and_expand_all has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def self.find_and_expand_all(fields, arguments={}, max_list_size=1000)
        returns = {}
        
        # find all standard fields, but expand only the location fields
        # TODO: when _expand support is added to StandardFields API, use the following
Severity: Minor
Found in lib/spark_api/models/standard_fields.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 editable? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def editable?(editable_settings = [])
        settings = Array(editable_settings)
        editable = attributes.include?("Permissions") && self.Permissions["Editable"] == true
        if editable
          settings.each{ |setting| editable = false unless self.Permissions["EditableSettings"][setting.to_s] == true }
Severity: Minor
Found in lib/spark_api/models/listing.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 process_request_body has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def process_request_body(body)
      if body.is_a?(Hash) || body.is_a?(Array)
        body.empty? ? nil : {"D" => body }.to_json
      else
        body
Severity: Minor
Found in lib/spark_api/request.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 create_session has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def create_session(token_params)
          SparkApi.logger.debug { "[oauth2] create_session to #{provider.access_uri} params #{token_params}" }
          uri = URI.parse(provider.access_uri)
          request_path = "#{uri.path}"
          response = oauth_access_connection("#{uri.scheme}://#{uri.host}").post(request_path, "#{token_params}").body
Severity: Minor
Found in lib/spark_api/authentication/oauth2_impl/grant_type_base.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 on_complete has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def on_complete(env)
          body = MultiJson.decode(env[:body])
          SparkApi.logger.debug { "[oauth2] Response Body: #{body.inspect}" }

          unless body.is_a?(Hash)
Severity: Minor
Found in lib/spark_api/authentication/oauth2_impl/faraday_middleware.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