xively/xively-rb

View on GitHub

Showing 67 of 67 total issues

Method transform_0_6_alpha has 33 lines of code (exceeds 25 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 1 hr to fix

    Method from_xml has 33 lines of code (exceeds 25 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 1 hr to fix

      Method xml_5 has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def xml_5(options={})
                builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
                  xml.eeml(_eeml_5) do |eeml|
                    eeml.environment(:updated => updated.iso8601, :id => id, :creator => "http://www.haque.co.uk") do |environment|
                      environment.title title unless title.blank?
      Severity: Minor
      Found in lib/xively-rb/templates/xml/feed_defaults.rb - About 1 hr to fix

        Method initialize has a Cognitive Complexity of 11 (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/feed.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 xml_5 has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

                def xml_5(options={})
                  builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
                    xml.eeml(_eeml_5) do |eeml|
                      eeml.environment(:updated => updated.iso8601, :id => feed_id, :creator => "http://www.haque.co.uk") do |environment|
                        environment.data(:id => id) do |data|
        Severity: Minor
        Found in lib/xively-rb/templates/xml/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 parse_tag_string has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def parse_tag_string(string)
              return [] if string.blank?
              string = string.join(',') if string.is_a?(Array)
              tags = []
              quoted_mode = false
        Severity: Minor
        Found in lib/xively-rb/helpers.rb - About 1 hr to fix

          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

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                            if location = hash.delete("location")
                              hash["location_disposition"] = location["disposition"]
                              hash["location_domain"] = location["domain"]
                              hash["location_ele"] = location["ele"]
                              hash["location_exposure"] = location["exposure"]
                Severity: Major
                Found in lib/xively-rb/parsers/json/feed_defaults.rb and 1 other location - About 1 hr to fix
                lib/xively-rb/parsers/json/feed_defaults.rb on lines 50..57

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 48.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                          if location = hash.delete("location")
                            hash["location_disposition"] = location["disposition"]
                            hash["location_domain"] = location["domain"]
                            hash["location_ele"] = location["ele"]
                            hash["location_exposure"] = location["exposure"]
                Severity: Major
                Found in lib/xively-rb/parsers/json/feed_defaults.rb and 1 other location - About 1 hr to fix
                lib/xively-rb/parsers/json/feed_defaults.rb on lines 89..96

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 48.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                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

                      Identical blocks of code found in 3 locations. 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: Major
                      Found in lib/xively-rb/key.rb and 2 other locations - About 55 mins to fix
                      lib/xively-rb/datapoint.rb on lines 28..36
                      lib/xively-rb/trigger.rb on lines 28..36

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 46.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Identical blocks of code found in 3 locations. 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: Major
                      Found in lib/xively-rb/datapoint.rb and 2 other locations - About 55 mins to fix
                      lib/xively-rb/key.rb on lines 36..44
                      lib/xively-rb/trigger.rb on lines 28..36

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 46.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Identical blocks of code found in 3 locations. 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: Major
                      Found in lib/xively-rb/trigger.rb and 2 other locations - About 55 mins to fix
                      lib/xively-rb/datapoint.rb on lines 28..36
                      lib/xively-rb/key.rb on lines 36..44

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 46.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Severity
                      Category
                      Status
                      Source
                      Language