PredictionIO/PredictionIO-Ruby-SDK

View on GitHub

Showing 4 of 6 total issues

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

    def initialize(uri, threads = 1, timeout = 60)
      @packages = Queue.new
      @counter_lock = Mutex.new
      @connections = 0
      @timeout = timeout
Severity: Minor
Found in lib/predictionio/connection.rb - About 7 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 initialize has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def initialize(uri, threads = 1, timeout = 60)
      @packages = Queue.new
      @counter_lock = Mutex.new
      @connections = 0
      @timeout = timeout
Severity: Major
Found in lib/predictionio/connection.rb - About 2 hrs to fix

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

      class EventClient
        # Raised when an event is not created after a synchronous API call.
        class NotCreatedError < StandardError; end
    
        # Create a new PredictionIO Event Client with defaults:
    Severity: Minor
    Found in lib/predictionio/event_client.rb - About 2 hrs to fix

      Method sync_events has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def sync_events(sync_m, *args)
            if args[0].is_a?(PredictionIO::AsyncResponse)
              response = args[0].get
            else
              response = send(sync_m, *args).get
      Severity: Minor
      Found in lib/predictionio/engine_client.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

      Severity
      Category
      Status
      Source
      Language