tstmedia/active_zuora

View on GitHub

Showing 16 of 19 total issues

Method add_extra_customizations has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def add_extra_customizations
      # We can't know everything from the wsdl, like which fields are
      # usable in queries.  This function does some final customizations
      # based on the existing Zuora documentation.
      # Also, it's possible classes customized here weren't defined
Severity: Minor
Found in lib/active_zuora/generator.rb - About 3 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 Relation has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Relation

    attr_accessor :selected_field_names, :filters, :order_attribute, :order_direction

    attr_reader :zobject_class
Severity: Minor
Found in lib/active_zuora/relation.rb - About 2 hrs to fix

    Method add_extra_customizations has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def add_extra_customizations
          # We can't know everything from the wsdl, like which fields are
          # usable in queries.  This function does some final customizations
          # based on the existing Zuora documentation.
          # Also, it's possible classes customized here weren't defined
    Severity: Major
    Found in lib/active_zuora/generator.rb - About 2 hrs to fix

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

            def has_many(items, options={})
              class_name = options[:class_name] || nested_class_name(items.to_s.singularize.camelize)
              foreign_key = options[:foreign_key] || :"#{zuora_object_name.underscore}_id"
              conditions = options[:conditions]
              # :order => :name
      Severity: Minor
      Found in lib/active_zuora/has_many_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 generate_classes has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def generate_classes
      
            # Defines the classes based on the wsdl document.
            # Assumes the following namespaces in the wsdl.
            # xmlns="http://schemas.xmlsoap.org/wsdl/"
      Severity: Minor
      Found in lib/active_zuora/generator.rb - About 1 hr to fix

        Method belongs_to has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def belongs_to(item, options={})
                class_name = options[:class_name] || nested_class_name(item.to_s.camelize)
                foreign_key = options[:foreign_key] || :"#{item}_id"
                # Add the field if it doesn't already exist.
                field foreign_key, :string unless field? foreign_key
        Severity: Minor
        Found in lib/active_zuora/belongs_to_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 belongs_to has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def belongs_to(item, options={})
                class_name = options[:class_name] || nested_class_name(item.to_s.camelize)
                foreign_key = options[:foreign_key] || :"#{item}_id"
                # Add the field if it doesn't already exist.
                field foreign_key, :string unless field? foreign_key
        Severity: Minor
        Found in lib/active_zuora/belongs_to_associations.rb - About 1 hr to fix

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

              def add_obvious_associations
                # When a zuora class has a field called InvoiceId, it's a safe
                # assuption that it references the an Invoice.
                # Build those associations automatically.
                @classes.each do |zuora_class|
          Severity: Minor
          Found in lib/active_zuora/generator.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_save has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

                def process_save(zobjects, action)
                  unless [:create, :update].include? action
                    raise "Invalid action type for saving. Must be create or update." 
                  end
          
          
          Severity: Minor
          Found in lib/active_zuora/persistence.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 generate_classes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def generate_classes
          
                # Defines the classes based on the wsdl document.
                # Assumes the following namespaces in the wsdl.
                # xmlns="http://schemas.xmlsoap.org/wsdl/"
          Severity: Minor
          Found in lib/active_zuora/generator.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_save has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def process_save(zobjects, action)
                  unless [:create, :update].include? action
                    raise "Invalid action type for saving. Must be create or update." 
                  end
          
          
          Severity: Minor
          Found in lib/active_zuora/persistence.rb - About 1 hr to fix

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

                def where_statement
                  return '' if @filters.empty?
                  tokens = []
                  @filters.each do |logical_operator, conditions|
                    if conditions.is_a?(Hash)
            Severity: Minor
            Found in lib/active_zuora/relation.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 query has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def query(&block)
                  # Keep querying until all pages are retrieved.
                  # Throws an exception for an invalid query.
                  response = zobject_class.connection.request(:query){ |soap| soap.body = { :query_string => to_zql } }
                  query_response = response[:query_response]
            Severity: Minor
            Found in lib/active_zuora/relation.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 escape_filter_value has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def escape_filter_value(value)
                  if value.nil?
                    "null"
                  elsif value.is_a?(String)
                    "'#{value.gsub("'","\\\\'")}'"
            Severity: Minor
            Found in lib/active_zuora/relation.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 sort_records! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def sort_records!(records)
                  return records unless order_attribute.present?
                  records.sort! do |a, b|
                    if a.nil?
                      -1
            Severity: Minor
            Found in lib/active_zuora/relation.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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def create
                  return false unless new_record? && valid?
                  result = self.class.connection.request(:create) do |soap|
                    soap.body do |xml|
                      build_xml(xml, soap, 
            Severity: Minor
            Found in lib/active_zuora/persistence.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