jrbeilke/teamsupport

View on GitHub

Showing 17 of 17 total issues

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

    def initialize(attrs = {})
      # Workaround for dealing with TeamSupport API inconsistently sending ID for objects
      unless attrs[:ID]
        attrs[:ID] = attrs.fetch(:OrganizationID) if attrs[:OrganizationID]

Severity: Minor
Found in lib/teamsupport/identity.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 perform_request_with_objects_from_collection has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def perform_request_with_objects_from_collection(request_method, path, options, klass, collection_name) # rubocop:disable Metrics/ParameterLists
Severity: Minor
Found in lib/teamsupport/rest/utils.rb - About 35 mins to fix

    Method perform_request_with_object_from_collection has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def perform_request_with_object_from_collection(request_method, path, options, klass, collection_name) # rubocop:disable Metrics/ParameterLists
    Severity: Minor
    Found in lib/teamsupport/rest/utils.rb - About 35 mins to fix

      This conditional expression can just be replaced by @attrs[:IsKnowledgeBase] == 'True'.
      Open

            @attrs[:IsKnowledgeBase] == 'True' ? true : false
      Severity: Minor
      Found in lib/teamsupport/ticket.rb by rubocop

      This cop checks for redundant returning of true/false in conditionals.

      Example:

      # bad
      x == y ? true : false
      
      # bad
      if x == y
        true
      else
        false
      end
      
      # good
      x == y
      
      # bad
      x == y ? false : true
      
      # good
      x != y

      %w-literals should be delimited by [ and ].
      Open

        spec.require_paths = %w(lib)
      Severity: Minor
      Found in teamsupport.gemspec by rubocop

      This cop enforces the consistent usage of %-literal delimiters.

      Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

      Example:

      # Style/PercentLiteralDelimiters:
      #   PreferredDelimiters:
      #     default: '[]'
      #     '%i':    '()'
      
      # good
      %w[alpha beta] + %i(gamma delta)
      
      # bad
      %W(alpha #{beta})
      
      # bad
      %I(alpha beta)

      Add an empty line after magic comments.
      Open

      lib = File.expand_path('../lib', __FILE__)
      Severity: Minor
      Found in teamsupport.gemspec by rubocop

      Checks for a newline after the final magic comment.

      Example:

      # good
      # frozen_string_literal: true
      
      # Some documentation for Person
      class Person
        # Some code
      end
      
      # bad
      # frozen_string_literal: true
      # Some documentation for Person
      class Person
        # Some code
      end

      %w-literals should be delimited by [ and ].
      Open

        spec.licenses      = %w(MIT)
      Severity: Minor
      Found in teamsupport.gemspec by rubocop

      This cop enforces the consistent usage of %-literal delimiters.

      Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

      Example:

      # Style/PercentLiteralDelimiters:
      #   PreferredDelimiters:
      #     default: '[]'
      #     '%i':    '()'
      
      # good
      %w[alpha beta] + %i(gamma delta)
      
      # bad
      %W(alpha #{beta})
      
      # bad
      %I(alpha beta)

      This conditional expression can just be replaced by @attrs[:IsVisibleOnPortal] == 'True'.
      Open

            @attrs[:IsVisibleOnPortal] == 'True' ? true : false
      Severity: Minor
      Found in lib/teamsupport/ticket.rb by rubocop

      This cop checks for redundant returning of true/false in conditionals.

      Example:

      # bad
      x == y ? true : false
      
      # bad
      if x == y
        true
      else
        false
      end
      
      # good
      x == y
      
      # bad
      x == y ? false : true
      
      # good
      x != y

      Use %i or %I for an array of symbols.
      Open

      task default: [:spec, :rubocop, :verify_measurements]
      Severity: Minor
      Found in Rakefile by rubocop

      This cop can check for array literals made up of symbols that are not using the %i() syntax.

      Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

      Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

      Example: EnforcedStyle: percent (default)

      # good
      %i[foo bar baz]
      
      # bad
      [:foo, :bar, :baz]

      Example: EnforcedStyle: brackets

      # good
      [:foo, :bar, :baz]
      
      # bad
      %i[foo bar baz]

      required_ruby_version (2.0, declared in teamsupport.gemspec) and TargetRubyVersion (2.1, declared in .rubocop.yml) should be equal.
      Open

        spec.required_ruby_version = '>= 2.0.0'
      Severity: Minor
      Found in teamsupport.gemspec by rubocop

      Checks that required_ruby_version of gemspec and TargetRubyVersion of .rubocop.yml are equal. Thereby, RuboCop to perform static analysis working on the version required by gemspec.

      Example:

      # When `TargetRubyVersion` of .rubocop.yml is `2.3`.
      
      # bad
      Gem::Specification.new do |spec|
        spec.required_ruby_version = '>= 2.2.0'
      end
      
      # bad
      Gem::Specification.new do |spec|
        spec.required_ruby_version = '>= 2.4.0'
      end
      
      # good
      Gem::Specification.new do |spec|
        spec.required_ruby_version = '>= 2.3.0'
      end
      
      # good
      Gem::Specification.new do |spec|
        spec.required_ruby_version = '>= 2.3'
      end
      
      # good
      Gem::Specification.new do |spec|
        spec.required_ruby_version = ['>= 2.3.0', '< 2.5.0']
      end

      Unnecessary utf-8 encoding comment.
      Open

      # coding: utf-8
      Severity: Minor
      Found in teamsupport.gemspec by rubocop

      This conditional expression can just be replaced by @attrs[:HasPortalAccess] == 'True'.
      Open

            @attrs[:HasPortalAccess] == 'True' ? true : false
      Severity: Minor
      Found in lib/teamsupport/customer.rb by rubocop

      This cop checks for redundant returning of true/false in conditionals.

      Example:

      # bad
      x == y ? true : false
      
      # bad
      if x == y
        true
      else
        false
      end
      
      # good
      x == y
      
      # bad
      x == y ? false : true
      
      # good
      x != y

      This conditional expression can just be replaced by @attrs[:IsActive] == 'True'.
      Open

            @attrs[:IsActive] == 'True' ? true : false
      Severity: Minor
      Found in lib/teamsupport/customer.rb by rubocop

      This cop checks for redundant returning of true/false in conditionals.

      Example:

      # bad
      x == y ? true : false
      
      # bad
      if x == y
        true
      else
        false
      end
      
      # good
      x == y
      
      # bad
      x == y ? false : true
      
      # good
      x != y

      Use each_key instead of keys.each.
      Open

                object.keys.each do |key|
      Severity: Minor
      Found in lib/teamsupport/rest/request.rb by rubocop

      This cop checks for uses of each_key and each_value Hash methods.

      Note: If you have an array of two-element arrays, you can put parentheses around the block arguments to indicate that you're not working with a hash, and suppress RuboCop offenses.

      Example:

      # bad
      hash.keys.each { |k| p k }
      hash.values.each { |v| p v }
      hash.each { |k, _v| p k }
      hash.each { |_k, v| p v }
      
      # good
      hash.each_key { |k| p k }
      hash.each_value { |v| p v }

      This conditional expression can just be replaced by @attrs[:NeedsIndexing] == 'True'.
      Open

            @attrs[:NeedsIndexing] == 'True' ? true : false
      Severity: Minor
      Found in lib/teamsupport/customer.rb by rubocop

      This cop checks for redundant returning of true/false in conditionals.

      Example:

      # bad
      x == y ? true : false
      
      # bad
      if x == y
        true
      else
        false
      end
      
      # good
      x == y
      
      # bad
      x == y ? false : true
      
      # good
      x != y

      This conditional expression can just be replaced by @attrs[:IsClosed] == 'True'.
      Open

            @attrs[:IsClosed] == 'True' ? true : false
      Severity: Minor
      Found in lib/teamsupport/ticket.rb by rubocop

      This cop checks for redundant returning of true/false in conditionals.

      Example:

      # bad
      x == y ? true : false
      
      # bad
      if x == y
        true
      else
        false
      end
      
      # good
      x == y
      
      # bad
      x == y ? false : true
      
      # good
      x != y

      %w-literals should be delimited by [ and ].
      Open

        spec.files         = %w(.yardopts CHANGELOG.md CONTRIBUTING.md LICENSE.md README.md teamsupport.gemspec) + Dir['lib/**/*.rb']
      Severity: Minor
      Found in teamsupport.gemspec by rubocop

      This cop enforces the consistent usage of %-literal delimiters.

      Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

      Example:

      # Style/PercentLiteralDelimiters:
      #   PreferredDelimiters:
      #     default: '[]'
      #     '%i':    '()'
      
      # good
      %w[alpha beta] + %i(gamma delta)
      
      # bad
      %W(alpha #{beta})
      
      # bad
      %I(alpha beta)
      Severity
      Category
      Status
      Source
      Language