VerdigrisTech/green-button-data

View on GitHub

Showing 43 of 43 total issues

Similar blocks of code found in 4 locations. Consider refactoring.
Open

  before do
    GreenButtonData.configure do |config|
      config.base_url = "https://services.greenbuttondata.org/DataCustodian/" +
                        "espi/1_1/resource/"

Severity: Major
Found in spec/lib/green-button-data/application_information_spec.rb and 3 other locations - About 55 mins to fix
spec/lib/green-button-data/authorization_spec.rb on lines 12..25
spec/lib/green-button-data/local_time_parameters_spec.rb on lines 18..37
spec/lib/green-button-data/reading_type_spec.rb on lines 24..38

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

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

      def build_query_params(options)
        params = {}

        options.each do |key, value|
          if key == :published_min || key == :published_max
Severity: Minor
Found in lib/green-button-data/fetchable.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 dst_datetime has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def dst_datetime(dst_rule, year, month, weekday, day, hour, seconds)
Severity: Major
Found in lib/green-button-data/dst.rb - About 50 mins to fix

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

        def usage_summary(id = nil, options = {})
          if id.is_a? Hash
            options = id
            id = nil
          end
    Severity: Minor
    Found in lib/green-button-data/client.rb and 1 other location - About 50 mins to fix
    lib/green-button-data/client.rb on lines 83..101

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

    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

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

      context "PG&E namespace" do
        let(:feed) { GreenButtonData::Feed }
        let :usage_point do
          feed.parse(espi_usage_point).entries.first.content.usage_point
        end
    Severity: Minor
    Found in spec/lib/green-button-data/parser/usage_point_spec.rb and 1 other location - About 50 mins to fix
    spec/lib/green-button-data/parser/usage_point_spec.rb on lines 4..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 43.

    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

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

        def meter_reading(id = nil, options = {})
          if id.is_a? Hash
            options = id
            id = nil
          end
    Severity: Minor
    Found in lib/green-button-data/client.rb and 1 other location - About 50 mins to fix
    lib/green-button-data/client.rb on lines 155..173

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

    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

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

      context "espi namespace" do
        let(:feed) { GreenButtonData::Feed }
        let :usage_point do
          feed.parse(espi_usage_point).entries.first.content.usage_point
        end
    Severity: Minor
    Found in spec/lib/green-button-data/parser/usage_point_spec.rb and 1 other location - About 50 mins to fix
    spec/lib/green-button-data/parser/usage_point_spec.rb on lines 23..38

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

    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

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

      describe '#has_address?' do
        context 'when ServiceLocation' do
          it 'returns true' do
            expect(service_location.has_address?).to be_truthy
          end
    Severity: Minor
    Found in spec/lib/green-button-data/retail_customer_spec.rb and 1 other location - About 50 mins to fix
    spec/lib/green-button-data/retail_customer_spec.rb on lines 130..142

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

    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

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

      describe '#has_agreement_id_map?' do
        context 'when CustomerAgreement' do
          it 'returns true' do
            expect(customer_agreement.has_agreement_id_map?).to be_truthy
          end
    Severity: Minor
    Found in spec/lib/green-button-data/retail_customer_spec.rb and 1 other location - About 50 mins to fix
    spec/lib/green-button-data/retail_customer_spec.rb on lines 96..108

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

    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 validate_dst_rules has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def validate_dst_rules(dst_rule, month, weekday, day, hour, seconds)
    Severity: Minor
    Found in lib/green-button-data/dst.rb - About 45 mins to fix

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

            def fetch(url = nil, options = nil)
              url or raise ArgumentError.new "url is required to fetch data"
      
              connection_options = {}
      
      
      Severity: Minor
      Found in lib/green-button-data/fetchable.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

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

      describe GreenButtonData::Parser::Customer do
        context 'PG&E namespace' do
          let(:feed) { GreenButtonData::Feed }
          let :customer do
            feed.parse(pge_retail_customer).entries[0].content.customer
      Severity: Minor
      Found in spec/lib/green-button-data/parser/customer_spec.rb and 1 other location - About 40 mins to fix
      spec/lib/green-button-data/parser/customer_account_spec.rb on lines 3..13

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

      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

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

      describe GreenButtonData::Parser::CustomerAccount do
        context 'PG&E namespace' do
          let(:feed) { GreenButtonData::Feed }
          let :customer_account do
            feed.parse(pge_retail_customer).entries[2].content.customer_account
      Severity: Minor
      Found in spec/lib/green-button-data/parser/customer_account_spec.rb and 1 other location - About 40 mins to fix
      spec/lib/green-button-data/parser/customer_spec.rb on lines 3..13

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

      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 dst_datetime has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def dst_datetime(dst_rule, year, month, weekday, day, hour, seconds)
            if dst_rule == 1
              # Rule 1: DST starts/ends on Day of Week on or after the Day of Month
              day_of_month = DateTime.new year, month, day
              day_offset = if weekday >= day_of_month.wday
      Severity: Minor
      Found in lib/green-button-data/dst.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

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

          def interval_block_bulk(id = nil, options = {})
            if id.is_a? Hash
              options = id
              id = nil
            end
      Severity: Minor
      Found in lib/green-button-data/client.rb and 2 other locations - About 35 mins to fix
      lib/green-button-data/client.rb on lines 215..231
      lib/green-button-data/client.rb on lines 235..251

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

      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

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

          def retail_customer_bulk(id = nil, options = {})
            if id.is_a? Hash
              options = id
              id = nil
            end
      Severity: Minor
      Found in lib/green-button-data/client.rb and 2 other locations - About 35 mins to fix
      lib/green-button-data/client.rb on lines 195..211
      lib/green-button-data/client.rb on lines 215..231

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

      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

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

          def usage_summary_bulk(id = nil, options = {})
            if id.is_a? Hash
              options = id
              id = nil
            end
      Severity: Minor
      Found in lib/green-button-data/client.rb and 2 other locations - About 35 mins to fix
      lib/green-button-data/client.rb on lines 195..211
      lib/green-button-data/client.rb on lines 235..251

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

      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 get_resource has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_resource(url, id = nil, klazz = nil, options = {})
            klazz ||= Entry.class_from_name Entry.class_name_from_url url
      
            # Merge request options
            options[:token] ||= token if token
      Severity: Minor
      Found in lib/green-button-data/client.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 sanitize_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def sanitize_options(options)
            options.delete(:interval_block_id) if options.has_key? :interval_block_id
            options.delete(:meter_reading_id) if options.has_key? :meter_reading_id
            options.delete(:subscription_id) if options.has_key? :subscription_id
            options.delete(:usage_point_id) if options.has_key? :usage_point_id
      Severity: Minor
      Found in lib/green-button-data/client.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_a has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def to_a
            result = []
      
            @interval_readings.each do |interval_reading|
              reading = {
      Severity: Minor
      Found in lib/green-button-data/interval_block.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