senseobservationsystems/commonsense-ruby-lib

View on GitHub

Showing 14 of 19 total issues

Class Session has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Session
    attr_accessor :logger, :base_uri

    def initialize(opts={})
      options = {
Severity: Minor
Found in lib/cs/session.rb - About 3 hrs to fix

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

        def process_param_integer(name, value, param_option)
          if value.kind_of?(Integer)
            retval = value
            retval = process_valid_values(name, value, param_option) if param_option[:valid_values]
            maximum = param_option[:maximum]
    Severity: Minor
    Found in lib/cs/parameter_processor.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def initialize(consumer_key, consumer_secret, access_token, access_token_secret, uri=nil)
    Severity: Minor
    Found in lib/cs/auth/oauth.rb - About 35 mins to fix

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

          def execute(type, path, body, headers, &block)
      Severity: Minor
      Found in lib/cs/session.rb - About 35 mins to fix

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

            def retry_on_509(&block)
              while true
                response = yield
                if response_code == 509
                  waitfor = Random.new.rand(30..45)
        Severity: Minor
        Found in lib/cs/session.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 parse_data_structure has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def parse_data_structure
                if self.data_type == "json"
                  if self.data_structure && self.data_structure.kind_of?(String)
                    self.data_structure = JSON.parse(self.data_structure) rescue nil
                  end
        Severity: Minor
        Found in lib/cs/end_point/sensor.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 parse_response has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def parse_response(response)
                @response_body = response.content_type == "application/json" ? (JSON(response.body) rescue nil) : response.body
                @response_code = response.code.to_i
        
                @response_headers = response.to_hash
        Severity: Minor
        Found in lib/cs/auth/oauth.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 each_batch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def each_batch(params={}, &block)
              check_session!
              options = get_options(params)
        
              self.page ||= 0;
        Severity: Minor
        Found in lib/cs/relation.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_param_boolean has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def process_param_boolean(name, value, param_option)
              retval = nil
        
              if value.nil?
                retval = param_option[:default] ? param_option[:default] : nil
        Severity: Minor
        Found in lib/cs/parameter_processor.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_batch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def process_batch(batch)
                sensors = {}
                batch.each do |point|
                  next if point.nil? || point.sensor_id.nil?
                  sensor_id = point.sensor_id
        Severity: Minor
        Found in lib/cs/collection/sensor_data_collection.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 get_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_options(input={})
              options = {}
        
              self.class.parameters.each do |name, param_option|
                value = self.parameter(name) # get value from object
        Severity: Minor
        Found in lib/cs/relation.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 retrieve! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def retrieve!
              check_session!
              raise Error::ResourceIdError unless @id
        
              res = session.get(get_url)
        Severity: Minor
        Found in lib/cs/end_point.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_or_new has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def find_or_new(attribute)
              check_session!
        
              self.each do |resource|
                found = true
        Severity: Minor
        Found in lib/cs/relation.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 to_cs_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def to_cs_value
                param = self.to_h(false)
                param.delete(:sensor_id)
                value = param[:value]
                if value
        Severity: Minor
        Found in lib/cs/end_point/sensor_data.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