sparkapi/spark_api

View on GitHub

Showing 27 of 40 total issues

Method request has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    def request(method, path, body, options)
      unless authenticated?
        authenticate
      end

Severity: Minor
Found in lib/spark_api/request.rb - About 5 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_date_start_and_end_times has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

      def parse_date_start_and_end_times(attributes)
        # Transform the date strings
        unless attributes['Date'].nil? || attributes['Date'].empty?
          date = Date.strptime attributes['Date'], '%m/%d/%Y'
          ['StartTime','EndTime'].each do |time|
Severity: Minor
Found in lib/spark_api/models/subresource.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

Class Listing has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Listing < Base 
      extend Finders
      attr_accessor :photos, :videos, :virtual_tours, :documents, :open_houses, :tour_of_homes, :rental_calendars, :floplans
      attr_accessor :constraints
      self.element_name="listings"
Severity: Minor
Found in lib/spark_api/models/listing.rb - About 3 hrs to fix

    Method setup_options has 88 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def self.setup_options(stdout,arguments)
            env_options = {
              :oauth2            => false,
              :endpoint          => ENV[OPTIONS_ENV[:endpoint]],
              # OAUTH2 Options
    Severity: Major
    Found in lib/spark_api/cli.rb - About 3 hrs to fix

      Class Base has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class Base
            extend Paginate
            include Dirty
      
            attr_accessor :attributes, :errors, :parent
      Severity: Minor
      Found in lib/spark_api/models/base.rb - About 2 hrs to fix

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

              def method_missing(method_symbol, *arguments)
                method_name = method_symbol.to_s
        
                if method_name =~ /(=|\?|_will_change!)$/
                  case $1
        Severity: Minor
        Found in lib/spark_api/models/base.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 on_complete has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            def on_complete(env)
              env[:body] = decompress_body(env)
        
              body = MultiJson.decode(env[:body])
              SparkApi.logger.debug{ "Response Body: #{body.inspect}" }
        Severity: Minor
        Found in lib/spark_api/faraday_middleware.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 request has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def request(method, path, body, options)
              unless authenticated?
                authenticate
              end
        
        
        Severity: Major
        Found in lib/spark_api/request.rb - About 2 hrs to fix

          Method on_complete has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def on_complete(env)
                env[:body] = decompress_body(env)
          
                body = MultiJson.decode(env[:body])
                SparkApi.logger.debug{ "Response Body: #{body.inspect}" }
          Severity: Major
          Found in lib/spark_api/faraday_middleware.rb - About 2 hrs to fix

            File listing.rb has 257 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            module SparkApi
              module Models
                class Listing < Base 
                  extend Finders
                  attr_accessor :photos, :videos, :virtual_tours, :documents, :open_houses, :tour_of_homes, :rental_calendars, :floplans
            Severity: Minor
            Found in lib/spark_api/models/listing.rb - About 2 hrs to fix

              Method initialize has 51 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def initialize(attributes={})
                      @photos = []
                      @videos = []
                      @virtual_tours = []
                      @rental_calendars = []
              Severity: Major
              Found in lib/spark_api/models/listing.rb - About 2 hrs to fix

                Method parse_date_start_and_end_times has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def parse_date_start_and_end_times(attributes)
                        # Transform the date strings
                        unless attributes['Date'].nil? || attributes['Date'].empty?
                          date = Date.strptime attributes['Date'], '%m/%d/%Y'
                          ['StartTime','EndTime'].each do |time|
                Severity: Minor
                Found in lib/spark_api/models/subresource.rb - About 1 hr to fix

                  Method initialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def initialize(attributes={})
                          @photos = []
                          @videos = []
                          @virtual_tours = []
                          @rental_calendars = []
                  Severity: Minor
                  Found in lib/spark_api/models/listing.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 primary_img has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def primary_img(typ)
                          if @images.is_a?(Array)
                            matches = @images.select {|i| i.Type == typ}
                            matches.sort do |a,b| 
                              if a.Name.nil? && !b.Name.nil?
                  Severity: Minor
                  Found in lib/spark_api/models/account.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 connection has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def connection(force_ssl = false)
                        opts = {
                          :headers => headers
                        }
                        if(force_ssl || self.ssl)
                  Severity: Minor
                  Found in lib/spark_api/connection.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 request has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def request(method, path, body, options={})
                          escaped_path = Addressable::URI.escape(path)
                          connection = @client.connection(true)  # SSL Only!
                          connection.headers.merge!(options.delete(:override_headers) || {})
                          connection.headers.merge!(self.auth_header)
                  Severity: Minor
                  Found in lib/spark_api/authentication/oauth2.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 method_missing has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def method_missing(method_symbol, *arguments)
                          method_name = method_symbol.to_s
                  
                          if method_name =~ /(=|\?)$/
                            case $1
                  Severity: Minor
                  Found in lib/spark_api/models/listing.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 vimeo_video_code has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def vimeo_video_code
                          html = self.ObjectHtml
                          if html.match(/(src=)('|")((https:)?\/\/player\.vimeo\.com\/video\/)/)
                            new_url = html.split(/(src=')|(src=")/)
                            if new_url[2]
                  Severity: Minor
                  Found in lib/spark_api/models/video.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 load_file has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def load_file(file)
                          @file = file
                          @name = File.basename(file, ".yml")
                  
                          erb_file = ERB.new(File.read(file)).result
                  Severity: Minor
                  Found in lib/spark_api/configuration/yaml.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 respond_to? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def respond_to?(method_symbol, include_all=false)
                          if super
                            return true
                          else
                            method_name = method_symbol.to_s
                  Severity: Minor
                  Found in lib/spark_api/models/base.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

                  Severity
                  Category
                  Status
                  Source
                  Language