lanej/zendesk2

View on GitHub

Showing 52 of 52 total issues

Method mock has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def mock
    user_id = cistern.serial_id

    user = params.fetch('user')
    organization_id = user['organization_id']
Severity: Minor
Found in lib/zendesk2/create_user.rb - About 2 hrs to fix

    Method mock has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def mock
        comment = params.fetch('ticket').delete('comment')
    
        body = find!(:tickets, ticket_id).merge!(ticket_params)
    
    
    Severity: Minor
    Found in lib/zendesk2/update_ticket.rb - About 1 hr to fix

      Method mock has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def mock
          create_params = view_params
      
          if Zendesk2.blank?(create_params['title'])
            error!(:invalid, details: { 'base' => [{ 'title' => 'Title: cannot be blank' }] })
      Severity: Minor
      Found in lib/zendesk2/create_view.rb - About 1 hr to fix

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

          def mock
            body = find!(:views, view_id)
        
            update_params = view_params
        
        
        Severity: Minor
        Found in lib/zendesk2/update_view.rb - About 1 hr to fix

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

            def mock
              identity = cistern.serial_id
          
              locale = params['locale'] ||= 'en-us'
              position = data[:help_center_sections].values.select { |a| a['category_id'] == category_id }.size
          Severity: Minor
          Found in lib/zendesk2/help_center/create_help_center_section.rb - About 1 hr to fix

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

              def mock
                terms = Hash[query.split(' ').map { |t| t.split(':') }]
                terms.delete('type') # context already provided
            
                collection = searchable_collection(terms)
            Severity: Minor
            Found in lib/zendesk2/search_user.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 data has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.data
                @data ||= Hash.new do |h, k|
                  h[k] = {
                    brands: {},
                    categories: {},
            Severity: Minor
            Found in lib/zendesk2/mock.rb - About 1 hr to fix

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

                def initialize(options = {})
                  url = options[:url] || Zendesk2.defaults[:url]
              
                  @url = (URI.parse(url).to_s if url)
              
              
              Severity: Minor
              Found in lib/zendesk2/real.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 page has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def page(collection, options = {})
                  url_params = options[:params] || params
                  page_params = page_params!(params)
              
                  page_size  = (page_params.delete('per_page') || 50).to_i
              Severity: Minor
              Found in lib/zendesk2/request.rb - About 1 hr to fix

                Method mock has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def mock
                    identity = cistern.serial_id
                
                    locale = params['locale'] ||= 'en-us'
                    position = data[:help_center_articles].values.select { |a| a['section_id'] == section_id }.size
                Severity: Minor
                Found in lib/zendesk2/help_center/create_help_center_article.rb - About 1 hr to fix

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

                    def get!(identity_or_hash)
                      scoped_attributes = self.class.scopes.inject({}) { |a, e| a.merge(e.to_s => send(e)) }
                  
                      if identity_or_hash.is_a?(Hash)
                        scoped_attributes.merge!(identity_or_hash)
                  Severity: Minor
                  Found in lib/zendesk2/paged_collection.rb and 1 other location - About 55 mins to fix
                  lib/zendesk2/collection.rb on lines 88..99

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

                  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

                    def mock
                      identity = cistern.serial_id
                  
                      record = {
                        'id'         => identity,
                  Severity: Minor
                  Found in lib/zendesk2/create_category.rb and 1 other location - About 55 mins to fix
                  lib/zendesk2/create_forum.rb on lines 17..29

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

                  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

                    def mock
                      identity = cistern.serial_id
                  
                      record = {
                        'id'         => identity,
                  Severity: Minor
                  Found in lib/zendesk2/create_forum.rb and 1 other location - About 55 mins to fix
                  lib/zendesk2/create_category.rb on lines 13..25

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

                  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

                    def get!(identity_or_hash)
                      scoped_attributes = self.class.scopes.inject({}) { |a, e| a.merge(e.to_s => public_send(e)) }
                  
                      if identity_or_hash.is_a?(Hash)
                        scoped_attributes.merge!(identity_or_hash)
                  Severity: Minor
                  Found in lib/zendesk2/collection.rb and 1 other location - About 55 mins to fix
                  lib/zendesk2/paged_collection.rb on lines 126..138

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

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

                    def mock
                      comment = params.fetch('ticket').delete('comment')
                  
                      body = find!(:tickets, ticket_id).merge!(ticket_params)
                  
                  
                  Severity: Minor
                  Found in lib/zendesk2/update_ticket.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 mock has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def mock
                      terms = Hash[query.split(' ').map { |t| t.split(':') }]
                      terms.delete('type') # context already provided
                  
                      collection = data[:organizations].values
                  Severity: Minor
                  Found in lib/zendesk2/search_organization.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 search_by_string has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def search_by_string(terms)
                      additional_terms = []
                      additional_terms = ["type:#{self.class.search_type}"] if self.class.search_type
                      additional_terms += self.class.scopes.inject([]) do |r, k|
                        val = public_send(k)
                  Severity: Minor
                  Found in lib/zendesk2/searchable.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 page has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def page(collection, options = {})
                      url_params = options[:params] || params
                      page_params = page_params!(params)
                  
                      page_size  = (page_params.delete('per_page') || 50).to_i
                  Severity: Minor
                  Found in lib/zendesk2/request.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 mock has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def mock(_params = {})
                      view = find!(:views, view_id)
                  
                      operators = Array(view['conditions']['all']).map do |c|
                        operator = 'is' == c.fetch('operator') ? :eql? : :!=
                  Severity: Minor
                  Found in lib/zendesk2/get_view_tickets.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

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

                      operators = Array(view['conditions']['all']).map do |c|
                        operator = 'is' == c.fetch('operator') ? :eql? : :!=
                        key      = c.fetch('field')
                        value    = c.fetch('value').to_s
                  
                  
                  Severity: Minor
                  Found in lib/zendesk2/get_view_tickets.rb and 1 other location - About 30 mins to fix
                  lib/zendesk2/get_view_tickets.rb on lines 29..34

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

                  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