ging/social_stream

View on GitHub
presence/lib/OpenTok/OpenTokSDK.rb

Summary

Maintainability
B
6 hrs
Test Coverage

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

    def generate_token(opts = {})
      {:session_id=>nil, :create_time=>nil, :expire_time=>nil, :role=>nil, :connection_data=>nil}.merge!(opts)

      create_time = opts[:create_time].nil? ? Time.now  :  opts[:create_time]
      session_id = opts[:session_id].nil? ? '' : opts[:session_id]
Severity: Minor
Found in presence/lib/OpenTok/OpenTokSDK.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 generate_token has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def generate_token(opts = {})
      {:session_id=>nil, :create_time=>nil, :expire_time=>nil, :role=>nil, :connection_data=>nil}.merge!(opts)

      create_time = opts[:create_time].nil? ? Time.now  :  opts[:create_time]
      session_id = opts[:session_id].nil? ? '' : opts[:session_id]
Severity: Minor
Found in presence/lib/OpenTok/OpenTokSDK.rb - About 1 hr to fix

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

        def do_request(api_url, params, token=nil)
    
          url = URI.parse(@api_url + api_url)
          if not params.empty?
            req = Net::HTTP::Post.new(url.path)
    Severity: Minor
    Found in presence/lib/OpenTok/OpenTokSDK.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 do_request has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def do_request(api_url, params, token=nil)
    
          url = URI.parse(@api_url + api_url)
          if not params.empty?
            req = Net::HTTP::Post.new(url.path)
    Severity: Minor
    Found in presence/lib/OpenTok/OpenTokSDK.rb - About 1 hr to fix

      There are no issues that match your filters.

      Category
      Status