xively/xively-rb

View on GitHub

Showing 67 of 67 total issues

Method xml_0_5_1 has a Cognitive Complexity of 106 (exceeds 5 allowed). Consider refactoring.
Open

        def xml_0_5_1(options={})
          builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
            xml.eeml(_eeml_0_5_1) do |eeml|
              eeml.environment(:updated => updated.iso8601(6), :created => created.iso8601(6), :id => id, :creator => creator) do |environment|
                environment.title title unless title.blank?
Severity: Minor
Found in lib/xively-rb/templates/xml/feed_defaults.rb - About 2 days 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 65 (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 => 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 day 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_0_5_1 has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
Open

        def xml_0_5_1
          builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
            xml.eeml(_eeml_0_5_1.merge({"xmlns:opensearch" => "http://a9.com/-/spec/opensearch/1.1/"})) do |eeml|
              eeml['opensearch'].totalResults totalResults
              eeml['opensearch'].startIndex startIndex
Severity: Minor
Found in lib/xively-rb/templates/xml/search_result_defaults.rb - About 1 day 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 30 (exceeds 5 allowed). Consider refactoring.
Open

        def xml_5
          builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
            xml.eeml(_eeml_5.merge({"xmlns:opensearch" => "http://a9.com/-/spec/opensearch/1.1/"})) do |eeml|
              eeml['opensearch'].totalResults totalResults
              eeml['opensearch'].startIndex startIndex
Severity: Minor
Found in lib/xively-rb/templates/xml/search_result_defaults.rb - About 4 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 xml_0_5_1 has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

        def xml_0_5_1(options={})
          builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
            xml.eeml(_eeml_0_5_1) do |eeml|
              eeml.environment(:updated => updated.iso8601(6), :id => feed_id, :creator => feed_creator) do |environment|
                environment.data(:id => id) do |data|
Severity: Minor
Found in lib/xively-rb/templates/xml/datastream_defaults.rb - About 3 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 from_csv has a Cognitive Complexity of 20 (exceeds 5 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 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

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

                  environment.data(:id => ds.id) do |data|
                    parse_tag_string(ds.tags).each do |tag|
                      data.tag tag
                    end if ds.tags
                    data.current_value ds.current_value, :at => ds.updated.iso8601(6)
Severity: Major
Found in lib/xively-rb/templates/xml/feed_defaults.rb and 1 other location - About 2 hrs to fix
lib/xively-rb/templates/xml/search_result_defaults.rb on lines 48..63

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 96.

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

                    environment.data(:id => ds.id) do |data|
                      parse_tag_string(ds.tags).each do |tag|
                        data.tag tag
                      end if ds.tags
                      data.current_value ds.current_value, :at => ds.updated.iso8601(6)
Severity: Major
Found in lib/xively-rb/templates/xml/search_result_defaults.rb and 1 other location - About 2 hrs to fix
lib/xively-rb/templates/xml/feed_defaults.rb on lines 48..63

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 96.

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

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

    def valid?
      pass = true
      [:id].each do |attr|
        if self.send(attr).blank?
          errors[attr] = ["can't be blank"]
Severity: Minor
Found in lib/xively-rb/datastream.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 parse_tag_string has a Cognitive Complexity of 16 (exceeds 5 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 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 xml_0_5_1 has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def xml_0_5_1
          builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
            xml.eeml(_eeml_0_5_1.merge({"xmlns:opensearch" => "http://a9.com/-/spec/opensearch/1.1/"})) do |eeml|
              eeml['opensearch'].totalResults totalResults
              eeml['opensearch'].startIndex startIndex
Severity: Minor
Found in lib/xively-rb/templates/xml/search_result_defaults.rb - About 2 hrs to fix

    Method xml_0_5_1 has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def xml_0_5_1(options={})
              builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
                xml.eeml(_eeml_0_5_1) do |eeml|
                  eeml.environment(:updated => updated.iso8601(6), :created => created.iso8601(6), :id => id, :creator => creator) 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

      Identical blocks of code found in 2 locations. 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: Major
      Found in lib/xively-rb/parsers/xml/feed_defaults.rb and 1 other location - About 1 hr to fix
      lib/xively-rb/parsers/xml/datastream_defaults.rb on lines 7..19

      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 70.

      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

              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: Major
      Found in lib/xively-rb/parsers/xml/datastream_defaults.rb and 1 other location - About 1 hr to fix
      lib/xively-rb/parsers/xml/feed_defaults.rb on lines 7..19

      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 70.

      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

      Method extract_datastreams has a Cognitive Complexity of 13 (exceeds 5 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

      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 valid? has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def valid?
            pass = true
            [:id].each do |attr|
              if self.send(attr).blank?
                errors[attr] = ["can't be blank"]
      Severity: Minor
      Found in lib/xively-rb/datastream.rb - About 1 hr to fix

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

                            environment.data(:id => ds.id) do |data|
                              parse_tag_string(ds.tags).each do |tag|
                                data.tag tag
                              end if ds.tags
                              data.value ds.current_value, {:minValue => ds.min_value, :maxValue => ds.max_value}.delete_if_nil_value
        Severity: Major
        Found in lib/xively-rb/templates/xml/search_result_defaults.rb and 1 other location - About 1 hr to fix
        lib/xively-rb/templates/xml/feed_defaults.rb on lines 91..100

        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 62.

        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

                          environment.data(:id => ds.id) do |data|
                            parse_tag_string(ds.tags).each do |tag|
                              data.tag tag
                            end if ds.tags
                            data.value ds.current_value, {:minValue => ds.min_value, :maxValue => ds.max_value}.delete_if_nil_value
        Severity: Major
        Found in lib/xively-rb/templates/xml/feed_defaults.rb and 1 other location - About 1 hr to fix
        lib/xively-rb/templates/xml/search_result_defaults.rb on lines 96..105

        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 62.

        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

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

                def xml_5
                  builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
                    xml.eeml(_eeml_5.merge({"xmlns:opensearch" => "http://a9.com/-/spec/opensearch/1.1/"})) do |eeml|
                      eeml['opensearch'].totalResults totalResults
                      eeml['opensearch'].startIndex startIndex
        Severity: Minor
        Found in lib/xively-rb/templates/xml/search_result_defaults.rb - About 1 hr to fix

          Method transform_1_0_0 has 35 lines of code (exceeds 25 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 1 hr to fix
            Severity
            Category
            Status
            Source
            Language