zendesk/zendesk_api_client_rb

View on GitHub

Showing 39 of 39 total issues

File resources.rb has 699 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module ZendeskAPI
  # @internal The following are redefined later, but needed by some circular resources (e.g. Ticket -> User, User -> Ticket)

  class Ticket < Resource; end
  class Forum < Resource; end
Severity: Major
Found in lib/zendesk_api/resources.rb - About 1 day to fix

    Class Collection has 44 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Collection
        include ZendeskAPI::Sideloading
    
        # Options passed in that are automatically converted from an array to a comma-separated list.
        SPECIALLY_JOINED_PARAMS = [:ids, :only]
    Severity: Minor
    Found in lib/zendesk_api/collection.rb - About 6 hrs to fix

      Method create_verb has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

            def create_verb(method_verb)
              define_method method_verb do |method|
                define_method "#{method}!" do |*method_args|
                  opts = method_args.last.is_a?(Hash) ? method_args.pop : {}
      
      
      Severity: Minor
      Found in lib/zendesk_api/verbs.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

      File collection.rb has 315 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'zendesk_api/resource'
      require 'zendesk_api/resources'
      
      module ZendeskAPI
        # Represents a collection of resources. Lazily loaded, resources aren't
      Severity: Minor
      Found in lib/zendesk_api/collection.rb - About 3 hrs to fix

        Method set_file has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

                def set_file(hash, key, top_level)
                  return unless hash.key?(key)
        
                  file = if hash[key].is_a?(Hash) && hash[key].key?(:file)
                    hash[key].delete(:file)
        Severity: Minor
        Found in lib/zendesk_api/middleware/request/upload.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 define_has_many_getter has a Cognitive Complexity of 16 (exceeds 5 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 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 build_connection has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def build_connection
              Faraday.new(config.options) do |builder|
                # response
                builder.use ZendeskAPI::Middleware::Response::RaiseError
                builder.use ZendeskAPI::Middleware::Response::Callback, self
        Severity: Minor
        Found in lib/zendesk_api/client.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 _all has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def _all(start_page = @options["page"], bang = false, &block)
              raise(ArgumentError, "must pass a block") unless block
        
              page(start_page)
              clear_cache
        Severity: Minor
        Found in lib/zendesk_api/collection.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 save_associations has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def save_associations
              self.class.associations.each do |association_data|
                association_name = association_data[:name]
        
                next unless send("#{association_name}_used?") && association = send(association_name)
        Severity: Minor
        Found in lib/zendesk_api/actions.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 process has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def process
            many = statement.jump(:ident).source == "has_many"
        
            klass = get_klass(statement)
        
        
        Severity: Minor
        Found in util/resource_handler.rb - About 1 hr to fix

          Method generate_path has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def generate_path(*args)
                options = SilentMash.new(:with_id => true)
                if args.last.is_a?(Hash)
                  original_options = args.pop
                  options.merge!(original_options)
          Severity: Minor
          Found in lib/zendesk_api/association.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 define_has_getter has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

                  def define_has_getter(association)
                    klass = association[:class] # shorthand
          
                    define_method association[:name] do |*args|
                      instance_options = args.last.is_a?(Hash) ? args.pop : {}
          Severity: Minor
          Found in lib/zendesk_api/associations.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 create_verb has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def create_verb(method_verb)
                  define_method method_verb do |method|
                    define_method "#{method}!" do |*method_args|
                      opts = method_args.last.is_a?(Hash) ? method_args.pop : {}
          
          
          Severity: Minor
          Found in lib/zendesk_api/verbs.rb - About 1 hr to fix

            Method set_file has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def set_file(hash, key, top_level)
                      return unless hash.key?(key)
            
                      file = if hash[key].is_a?(Hash) && hash[key].key?(:file)
                        hash[key].delete(:file)
            Severity: Minor
            Found in lib/zendesk_api/middleware/request/upload.rb - About 1 hr to fix

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

                      def call(env)
                        original_env = env.dup
                        response = @app.call(env)
              
                        if ERROR_CODES.include?(response.env[:status])
              Severity: Minor
              Found in lib/zendesk_api/middleware/request/retry.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_connection has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def build_connection
                    Faraday.new(config.options) do |builder|
                      # response
                      builder.use ZendeskAPI::Middleware::Response::RaiseError
                      builder.use ZendeskAPI::Middleware::Response::Callback, self
              Severity: Minor
              Found in lib/zendesk_api/client.rb - About 1 hr to fix

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

                  def process
                    many = statement.jump(:ident).source == "has_many"
                
                    klass = get_klass(statement)
                
                
                Severity: Minor
                Found in util/resource_handler.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 method_missing has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    def method_missing(method, *args, &block)
                      method = method.to_s
                      options = args.last.is_a?(Hash) ? args.pop : {}
                
                      @resource_cache[method] ||= { :class => nil, :cache => ZendeskAPI::LRUCache.new }
                Severity: Minor
                Found in lib/zendesk_api/client.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 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

                  Severity
                  Category
                  Status
                  Source
                  Language