dougyouch/schema

View on GitHub

Showing 17 of 21 total issues

Method as_json has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    def as_json(opts = {})
      self.class.schema.each_with_object({}) do |(field_name, field_options), memo|
        unless field_options[:alias_of]
          value = public_send(field_options[:getter])
          next if value.nil? && !opts[:include_nils]
Severity: Minor
Found in lib/schema/model.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

Method update_attributes_with_array has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def update_attributes_with_array(array, mapped_headers, offset = nil)
      self.class.schema.each do |_, field_options|
        next unless (mapped_field = mapped_headers[field_options[:name]])

        if offset
Severity: Minor
Found in lib/schema/arrays.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 to_a has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def to_a
      data = []
      self.class.schema.each do |_, field_options|
        next if field_options[:alias_of]

Severity: Minor
Found in lib/schema/arrays.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_schema has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def create_schema(base_schema, data, error_name = nil)
        if data.is_a?(Hash)
          unless (schema_class = get_schema_class(base_schema, data))
            add_parsing_error(base_schema, error_name, UNKNOWN) if base_schema.class.capture_unknown_attributes?
            return nil
Severity: Minor
Found in lib/schema/associations/schema_creator.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 largest_number_of_indexes_from_map has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def largest_number_of_indexes_from_map(mapped_model)
      size = 0
      mapped_model.each do |_, info|
        if info[:indexes]
          size = info[:indexes].size if info[:indexes] && info[:indexes].size > size
Severity: Minor
Found in lib/schema/arrays.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 get_field_names has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def get_field_names(mapped_headers, header_prefix = nil, mapped = true)
        fields = []
        schema.each do |field_name, field_options|
          next if field_options[:alias_of]

Severity: Minor
Found in lib/schema/array_headers.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 update_model_attributes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def update_model_attributes(schema, data)
      data.each do |key, value|
        unless schema.key?(key)
          parsing_errors.add(key, ::Schema::ParsingErrors::UNKNOWN_ATTRIBUTE) if self.class.capture_unknown_attributes?
          next
Severity: Minor
Found in lib/schema/model.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 map_headers_to_has_many_associations has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def map_headers_to_has_many_associations(headers, mapped_headers)
        schema.each do |field_name, field_options|
          next unless field_options[:type] == :has_many

          get_header_prefixes(field_name, field_options).each do |header_prefix|
Severity: Minor
Found in lib/schema/array_headers.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 update_nested_has_one_associations_from_array has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def update_nested_has_one_associations_from_array(array, mapped_headers, current_offset = nil)
      self.class.schema.each do |_, field_options|
        next unless field_options[:type] == :has_one
        next unless (mapped_model = mapped_headers[field_options[:name]])

Severity: Minor
Found in lib/schema/arrays.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 update_nested_has_many_associations_from_array has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def update_nested_has_many_associations_from_array(array, mapped_headers)
      self.class.schema.each do |_, field_options|
        next unless field_options[:type] == :has_many
        next unless (mapped_model = mapped_headers[field_options[:name]])

Severity: Minor
Found in lib/schema/arrays.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 map_headers_to_fields has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def map_headers_to_fields(headers, mapped_headers, header_prefix)
        schema.each do |field_name, field_options|
          if header_prefix
            unless (indexes = find_indexes_for_field(headers, field_options, header_prefix)).empty?
              mapped_headers[field_options[:alias_of] || field_name] = { indexes: indexes }
Severity: Minor
Found in lib/schema/array_headers.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 update_associations has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def update_associations(schema, data)
      data.each do |key, value|
        next unless schema.key?(key)
        next unless schema[key][:association]

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

      def get_model_field_names(field_name, field_options, mapped_headers, header_prefix, mapped)
Severity: Minor
Found in lib/schema/array_headers.rb - About 35 mins to fix

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

          def self.convert_array_values(model, field_name, parsing_errors, data, schema_options)
    Severity: Minor
    Found in lib/schema/parsers/array.rb - About 35 mins to fix

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

            def self.parse_string_array(model, field_name, parsing_errors, value, schema_options)
      Severity: Minor
      Found in lib/schema/parsers/array.rb - About 35 mins to fix

        Method map_headers_to_has_one_associations has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def map_headers_to_has_one_associations(headers, mapped_headers, header_prefix)
                schema.each do |field_name, field_options|
                  next unless field_options[:type] == :has_one
        
                  mapped_model = get_mapped_model(field_options, headers, header_prefix)
        Severity: Minor
        Found in lib/schema/array_headers.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 parse_integer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def parse_integer(field_name, parsing_errors, value)
                case value
                when Integer
                  value
                when String
        Severity: Minor
        Found in lib/schema/parsers/common.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