VerdigrisTech/green-button-data

View on GitHub

Showing 13 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

      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

        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

          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

            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

            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