VerdigrisTech/green-button-data

View on GitHub

Showing 43 of 43 total issues

File client_spec.rb has 548 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "spec_helper"

describe GreenButtonData::Client do
  let :config do
    {
Severity: Major
Found in spec/lib/green-button-data/client_spec.rb - About 1 day to fix

    File application_information_spec.rb has 310 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "spec_helper"
    
    describe GreenButtonData::ApplicationInformation do
      let(:all_url) { GreenButtonData.configuration.application_information_url }
      let(:find_url) { "#{all_url}2" }
    Severity: Minor
    Found in spec/lib/green-button-data/application_information_spec.rb - About 3 hrs to fix

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

        context "espi namespace" do
          let(:feed) { GreenButtonData::Feed }
          let :local_time_parameters do
            feed.parse(pge_local_time_parameters)
                .entries
      spec/lib/green-button-data/parser/local_time_parameter_spec.rb on lines 4..53

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

      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 :local_time_parameters do
            feed.parse(espi_local_time_parameters)
                .entries
      spec/lib/green-button-data/parser/local_time_parameter_spec.rb on lines 57..106

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

      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 :authorization do
            feed.parse(pge_authorization)
                .entries
      Severity: Major
      Found in spec/lib/green-button-data/parser/authorization_spec.rb and 1 other location - About 3 hrs to fix
      spec/lib/green-button-data/parser/authorization_spec.rb on lines 4..43

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

      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 :authorization do
            feed.parse(espi_authorization)
                .entries
      Severity: Major
      Found in spec/lib/green-button-data/parser/authorization_spec.rb and 1 other location - About 3 hrs to fix
      spec/lib/green-button-data/parser/authorization_spec.rb on lines 47..86

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

      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 :interval_block do
            feed.parse(espi_interval_block).entries.first.content.interval_block
          end
      Severity: Major
      Found in spec/lib/green-button-data/parser/interval_block_spec.rb and 1 other location - About 2 hrs to fix
      spec/lib/green-button-data/parser/interval_block_spec.rb on lines 40..71

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

      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 :interval_block do
            feed.parse(pge_interval_block).entries.last.content.interval_block
          end
      Severity: Major
      Found in spec/lib/green-button-data/parser/interval_block_spec.rb and 1 other location - About 2 hrs to fix
      spec/lib/green-button-data/parser/interval_block_spec.rb on lines 4..35

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

      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 4 locations. Consider refactoring.
      Open

        describe "#authorization" do
          let(:id) { 4 }
          let(:klazz) { GreenButtonData::Authorization }
          let(:authorization) { client.authorization id, token: token }
          let(:authorizations) { client.authorization token: token }
      Severity: Major
      Found in spec/lib/green-button-data/client_spec.rb and 3 other locations - About 2 hrs to fix
      spec/lib/green-button-data/client_spec.rb on lines 70..102
      spec/lib/green-button-data/client_spec.rb on lines 247..280
      spec/lib/green-button-data/client_spec.rb on lines 380..408

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

      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 4 locations. Consider refactoring.
      Open

        describe "#reading_type" do
          let(:id) { 11 }
          let(:klazz) { GreenButtonData::ReadingType }
          let(:reading_type) { client.reading_type id, token: token }
          let(:reading_types) { client.reading_type token: token }
      Severity: Major
      Found in spec/lib/green-button-data/client_spec.rb and 3 other locations - About 2 hrs to fix
      spec/lib/green-button-data/client_spec.rb on lines 70..102
      spec/lib/green-button-data/client_spec.rb on lines 107..135
      spec/lib/green-button-data/client_spec.rb on lines 247..280

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

      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 4 locations. Consider refactoring.
      Open

        describe "#local_time_parameters" do
          let(:id) { 1 }
          let(:klazz) { GreenButtonData::LocalTimeParameters }
          let(:local_time_parameters) {
            client.local_time_parameters id,
      Severity: Major
      Found in spec/lib/green-button-data/client_spec.rb and 3 other locations - About 2 hrs to fix
      spec/lib/green-button-data/client_spec.rb on lines 70..102
      spec/lib/green-button-data/client_spec.rb on lines 107..135
      spec/lib/green-button-data/client_spec.rb on lines 380..408

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

      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 4 locations. Consider refactoring.
      Open

        describe "#application_information" do
          let(:id) { 2 }
          let(:klazz) { GreenButtonData::ApplicationInformation }
          let(:application_information) {
            client.application_information id, token: token
      Severity: Major
      Found in spec/lib/green-button-data/client_spec.rb and 3 other locations - About 2 hrs to fix
      spec/lib/green-button-data/client_spec.rb on lines 107..135
      spec/lib/green-button-data/client_spec.rb on lines 247..280
      spec/lib/green-button-data/client_spec.rb on lines 380..408

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

      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 "no namespace" do
          let(:feed) { GreenButtonData::Feed }
          let :entries do
            feed.parse(espi_usage_point)
                .entries
      Severity: Major
      Found in spec/lib/green-button-data/parser/entry_spec.rb and 1 other location - About 1 hr to fix
      spec/lib/green-button-data/parser/entry_spec.rb on lines 31..54

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

      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 :entries do
            feed.parse(pge_usage_point)
                .entries
      Severity: Major
      Found in spec/lib/green-button-data/parser/entry_spec.rb and 1 other location - About 1 hr to fix
      spec/lib/green-button-data/parser/entry_spec.rb on lines 4..27

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

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

            def each_entry_content(feed)
              entry_content = nil
      
              feed.entries.each do |entry|
                match_data = resource_from_url(entry.self)
      Severity: Minor
      Found in lib/green-button-data/fetchable.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 to_h has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def to_h
            {
              authorization_server_authorization_endpoint:
                authorization_server_authorization_endpoint,
              authorization_server_registration_endpoint:
      Severity: Minor
      Found in lib/green-button-data/application_information.rb - About 1 hr to fix

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

            def pluralize
              result = self.dup
        
              if self.empty?
                return result
        Severity: Minor
        Found in lib/green-button-data/core_extensions/string.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

        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/authorization_spec.rb and 3 other locations - About 55 mins to fix
        spec/lib/green-button-data/application_information_spec.rb on lines 116..135
        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

        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/local_time_parameters_spec.rb and 3 other locations - About 55 mins to fix
        spec/lib/green-button-data/application_information_spec.rb on lines 116..135
        spec/lib/green-button-data/authorization_spec.rb on lines 12..25
        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

        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/reading_type_spec.rb and 3 other locations - About 55 mins to fix
        spec/lib/green-button-data/application_information_spec.rb on lines 116..135
        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

        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