Soylent/jschema

View on GitHub

Showing 3 of 14 total issues

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

      def build(schema_id, parent_schema, id)
        if parent_schema
          if parent_schema.uri.absolute?
            new_uri_part = schema_id ||
              join_fragments(parent_schema.uri.fragment, id)
Severity: Minor
Found in lib/jschema/schema_uri.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 validate_instance has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def validate_instance(instance)
        instance.each do |field, value|
          schemas = schemas_for(field)

          if schemas.empty? && @additional_properties == false
Severity: Minor
Found in lib/jschema/validator/properties.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 validate_instance has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def validate_instance(instance)
        @dependencies.each do |property, validator|
          if instance.key?(property)
            errors = validate_against_dependency(instance, validator, property)
            return errors.first unless errors.empty?
Severity: Minor
Found in lib/jschema/validator/dependencies.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