zendesk/zendesk_api_client_rb

View on GitHub

Showing 43 of 43 total issues

Method define_has_many_getter has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def define_has_many_getter(association)
          klass = association[:class]

          define_method association[:name] do |*args|
            instance_opts = args.last.is_a?(Hash) ? args.pop : {}
Severity: Minor
Found in lib/zendesk_api/associations.rb - About 1 hr to fix

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

        def save!(options = {})
          return false if respond_to?(:destroyed?) && destroyed?
    
          if new_record? && !options[:force_update]
            method = :post
    Severity: Minor
    Found in lib/zendesk_api/actions.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 get_klass has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def get_klass(statement)
        statement.traverse do |node|
          if node.type == :assoc && node.jump(:kw).source == "class"
            node.traverse do |value|
              if value.type == :const_path_ref || value.type == :var_ref
    Severity: Minor
    Found in util/resource_handler.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 traverse_hash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def traverse_hash(hash)
              hash.keys.each do |key|
                if hash[key].is_a?(File)
                  set_file(hash, key, false)
                elsif hash[key].is_a?(Hash)
    Severity: Minor
    Found in lib/zendesk_api/middleware/request/upload.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 call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def call(environment)
              return @app.call(environment) unless [:get, :head].include?(environment[:method])
    
              # send known etag
              cached = @cache.read(cache_key(environment))
    Severity: Minor
    Found in lib/zendesk_api/middleware/request/etag_cache.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 clear_changes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def clear_changes
            each do |k, v|
              if v.respond_to?(:clear_changes)
                v.clear_changes
              elsif v.is_a?(Array)
    Severity: Minor
    Found in lib/zendesk_api/track_changes.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 set_token_auth has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def set_token_auth
          return if config.password || config.token.nil?
    
          if config.username.nil?
            raise ArgumentError, "you need to provide a username when using API token auth"
    Severity: Minor
    Found in lib/zendesk_api/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 _save has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def _save(method = :save)
            return self unless @resources
    
            @client.connection.post(path) do |req|
              req.body = { :tags => @resources.reject(&:destroyed?).map(&:id) }
    Severity: Minor
    Found in lib/zendesk_api/resources.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(client, attributes = {})
          raise "Expected a Hash for attributes, got #{attributes.inspect}" unless attributes.is_a?(Hash)
    
          @association = attributes.delete(:association) || Association.new(:class => self.class)
          @global_params = attributes.delete(:global) || {}
    Severity: Minor
    Found in lib/zendesk_api/resource.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 extract_id has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def extract_id(instance, options, original_options)
          if options[:with_id] && !@options[:class].ancestors.include?(SingularResource)
            if instance && instance.id
              instance.id
            elsif options[:id]
    Severity: Minor
    Found in lib/zendesk_api/association.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 update_many! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def update_many!(client, ids_or_attributes, attributes = {})
          association = attributes.delete(:association) || Association.new(:class => self)
    
          response = client.connection.put("#{association.generate_path}/update_many") do |req|
            if attributes == {}
    Severity: Minor
    Found in lib/zendesk_api/actions.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 get_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_response(path)
          @error = nil
          @client.connection.send(@verb || "get", path) do |req|
            opts = @options.delete_if { |_, v| v.nil? }
    
    
    Severity: Minor
    Found in lib/zendesk_api/collection.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 _side_load has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def _side_load(name, klass, resources)
          associations = klass.associated_with(name)
    
          associations.each do |association|
            association.side_load(resources, @included[name])
    Severity: Minor
    Found in lib/zendesk_api/sideloading.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 define_has_many_setter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def define_has_many_setter(association)
              define_method "#{association[:name]}=" do |resources|
                if resources.is_a?(Array)
                  wrapped = resources.map { |attr| wrap_resource(attr, association) }
                  send(association[:name]).replace(wrapped)
    Severity: Minor
    Found in lib/zendesk_api/associations.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 changes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def changes
            (@changes ||= self.class.superclass.new).tap do |changes|
              each do |k, v|
                if v.respond_to?(:changed?) && v.changed?
                  changes[k] = v.changes
    Severity: Minor
    Found in lib/zendesk_api/track_changes.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 _save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def _save(method = :save)
          return self unless @resources
    
          result = true
    
    
    Severity: Minor
    Found in lib/zendesk_api/collection.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 == has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def ==(other)
          return false unless other
    
          return true if other.object_id == object_id
    
    
    Severity: Minor
    Found in lib/zendesk_api/resource.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def initialize(app, options = {})
              super(app)
              @logger = options[:logger]
              @error_codes = options.key?(:retry_codes) && options[:retry_codes] ? options[:retry_codes] : DEFAULT_ERROR_CODES
              @retry_on_exception = options.key?(:retry_on_exception) && options[:retry_on_exception] ? options[:retry_on_exception] : false
    Severity: Minor
    Found in lib/zendesk_api/middleware/request/retry.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 regular_writer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def regular_writer(key, value)
            if has_key?(key) && self[key] == value
              value
            else
              changes[key] = value
    Severity: Minor
    Found in lib/zendesk_api/track_changes.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 find! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def find!(client, options = {})
            @client = client # so we can use client.logger in rescue
    
            raise ArgumentError, "No :id given" unless options[:id] || options["id"] || ancestors.include?(SingularResource)
            association = options.delete(:association) || Association.new(:class => self)
    Severity: Minor
    Found in lib/zendesk_api/actions.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