xively/xively-rb

View on GitHub

Showing 43 of 67 total issues

Method generate_json has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def generate_json(options={})
          if self.permissions
            s = self.permissions.collect { |s|
              if s.resources
                res = s.resources.collect { |r| { :feed_id => r.feed_id, :datastream_id => r.datastream_id, :datastream_trigger_id => r.datastream_trigger_id }.delete_if_nil_value
Severity: Minor
Found in lib/xively-rb/templates/json/key_defaults.rb - About 1 hr to fix

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

            def csv_2(options)
              csv = []
              options[:depth] = 4 if options[:full]
              case options[:depth].to_i
              when 4
    Severity: Minor
    Found in lib/xively-rb/templates/csv/datastream_defaults.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 initialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(input = {}, csv_version = nil, format = nil)
          raise InvalidFormatError, "Unknown format specified, currently we can only parse JSON, XML or CSV." unless [nil,:json,:xml,:csv].include?(format)
          if input.is_a? Hash
            self.attributes = input
          elsif format == :json || (format.nil? && input.strip[0...1].to_s == "{")
    Severity: Minor
    Found in lib/xively-rb/datastream.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 csv_2 has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def csv_2(options)
              csv = []
              if options[:full]
                datastreams.collect do |datastream|
                  if datastream.datapoints.any?
    Severity: Minor
    Found in lib/xively-rb/templates/csv/feed_defaults.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 from_csv has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def from_csv(csv, csv_version = nil)
              begin
                rows = Xively::CSV.parse(csv.strip)
              rescue Exception => e
                # this might be a FasterCSV or CSV exception depending on whether
    Severity: Minor
    Found in lib/xively-rb/parsers/csv/datastream_defaults.rb - About 1 hr to fix

      Method extract_datastreams has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def extract_datastreams(rows)
                row_sizes = rows.collect { |row| row.size }.uniq
                row_ids = rows.collect { |row| row.first.to_s.strip }.uniq
      
                raise InvalidCSVError, "CSV is invalid. Incorrect number of fields" if row_sizes.max > 3 || row_sizes.min <= 1
      Severity: Minor
      Found in lib/xively-rb/parsers/csv/feed_defaults.rb - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

                        environment.location({:disposition => location_disposition, :exposure => location_exposure, :domain => location_domain}.delete_if_nil_value) do |location|
                          location.name location_name
                          location.lat location_lat
                          location.lon location_lon
                          location.ele location_ele
        Severity: Major
        Found in lib/xively-rb/templates/xml/feed_defaults.rb - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                            environment.location({:disposition => env.location_disposition, :exposure => env.location_exposure, :domain => env.location_domain}.delete_if_nil_value) do |location|
                              location.name env.location_name
                              location.lat env.location_lat
                              location.lon env.location_lon
                              location.ele env.location_ele
          Severity: Major
          Found in lib/xively-rb/templates/xml/search_result_defaults.rb - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                      !options[:include_blank] ? (hash.delete_if_nil_value if location_disposition || location_name || location_exposure || location_domain || location_ele || location_lat || location_lon) : hash
            Severity: Major
            Found in lib/xively-rb/templates/json/feed_defaults.rb - About 1 hr to fix

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

                      def transform_1_0_0(hash)
                        hash["updated"] = hash["updated"]
                        hash["created"] = hash["created"]
                        hash["status"] = hash["status"]
                        hash["tags"] = join_tags(hash["tags"])
              Severity: Minor
              Found in lib/xively-rb/parsers/json/feed_defaults.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 from_xml has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                      def from_xml(xml)
                        begin
                          xml = Nokogiri::XML(xml) do |config|
                            config.strict.nonet
                          end
              Severity: Minor
              Found in lib/xively-rb/parsers/xml/trigger_defaults.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 transform_0_6_alpha has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                      def transform_0_6_alpha(hash)
                        hash["retrieved_at"] = hash["updated"]
                        hash["state"] = hash["status"]
                        if hash["datastreams"]
                          hash["datastreams"] = hash["datastreams"].collect do |datastream|
              Severity: Minor
              Found in lib/xively-rb/parsers/json/feed_defaults.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 generate_json has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                      def generate_json(options={})
                        if self.permissions
                          s = self.permissions.collect { |s|
                            if s.resources
                              res = s.resources.collect { |r| { :feed_id => r.feed_id, :datastream_id => r.datastream_id, :datastream_trigger_id => r.datastream_trigger_id }.delete_if_nil_value
              Severity: Minor
              Found in lib/xively-rb/templates/json/key_defaults.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 a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def initialize(input = {}, format = nil)
                    raise InvalidFormatError, "Unknown format specified, currently we can only parse JSON or XML." unless [nil,:json,:xml].include?(format)
                    if input.is_a?(Hash)
                      self.attributes = input
                    elsif format == :json || (format.nil? && input.strip[0...1].to_s == "{")
              Severity: Minor
              Found in lib/xively-rb/key.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 from_xml has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                      def from_xml(xml)
                        begin
                          xml = Nokogiri::XML(xml) do |config|
                            config.strict.nonet
                          end
              Severity: Minor
              Found in lib/xively-rb/parsers/xml/key_defaults.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def initialize(input = {}, format = nil)
                    raise InvalidFormatError, "Unknown format specified, currently we can only parse JSON or XML." unless [nil,:json,:xml].include?(format)
                    if input.is_a?(Hash)
                      self.attributes = input
                    elsif format == :json || (format.nil? && input.strip[0...1].to_s == "{")
              Severity: Minor
              Found in lib/xively-rb/trigger.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 from_xml has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                      def from_xml(xml)
                        begin
                          parsed = MultiXml.parse(xml)
                          raise InvalidXMLError, "Missing 'environment' node from base node" if parsed['eeml'].nil? || !parsed['eeml'].key?('environment')
                          return {} if parsed['eeml']['environment'].nil?
              Severity: Minor
              Found in lib/xively-rb/parsers/xml/datastream_defaults.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 from_xml has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                      def from_xml(xml)
                        begin
                          parsed = MultiXml.parse(xml)
                          raise InvalidXMLError, "Missing 'environment' node from base node" if parsed['eeml'].nil? || !parsed['eeml'].key?('environment')
                          return {} if parsed['eeml']['environment'].nil?
              Severity: Minor
              Found in lib/xively-rb/parsers/xml/feed_defaults.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def initialize(input = {}, format = nil)
                    raise InvalidFormatError, "Unknown format specified, currently we can only parse JSON or XML." unless [nil,:json,:xml].include?(format)
                    if input.is_a? Hash
                      self.attributes = input
                    elsif format == :json || (format.nil? && input.strip[0...1].to_s == "{")
              Severity: Minor
              Found in lib/xively-rb/datapoint.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 generate_json has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                      def generate_json(version, options={})
                        if version == "1.0.0"
                          output = json_100(options)
                        elsif version == "0.6-alpha"
                          output = json_06alpha(options)
              Severity: Minor
              Found in lib/xively-rb/templates/json/datastream_defaults.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