ruby-json-schema/json-schema

View on GitHub

Showing 91 of 97 total issues

Method initialize_schema has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def initialize_schema(schema, default_validator)
      if schema.is_a?(String)
        begin
          # Build a fake URI for this
          schema_uri = JSON::Util::URI.parse(fake_uuid(schema))
Severity: Minor
Found in lib/json-schema/validator.rb - About 1 hr to fix

    Method validate has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def self.validate(current_schema, data, fragments, processor, validator, options = {})
            errors = Hash.new { |hsh, k| hsh[k] = [] }
    
            validation_error_count = 0
            one_of = current_schema.schema['oneOf']
    Severity: Minor
    Found in lib/json-schema/attributes/oneof.rb - About 1 hr to fix

      Method initialize has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def initialize
              super
              @attributes = {
                'type' => JSON::Schema::TypeAttribute,
                'disallow' => JSON::Schema::DisallowAttribute,
      Severity: Minor
      Found in lib/json-schema/validators/draft3.rb - About 1 hr to fix

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

              def self.get_extended_uri_and_schema(s, current_schema, validator)
                uri, schema = nil, nil
        
                if s.is_a?(Hash)
                  uri = current_schema.uri
        Severity: Minor
        Found in lib/json-schema/attributes/extends.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 validate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.validate(current_schema, data, fragments, processor, validator, options = {})
                if data.is_a?(String)
                  error_message = "The property '#{build_fragment(fragments)}' must be a date in the format of YYYY-MM-DD"
                  if REGEXP.match(data)
                    begin
        Severity: Minor
        Found in lib/json-schema/attributes/formats/date.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 validate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.validate(current_schema, data, fragments, processor, validator, options = {})
                # Create a hash to hold errors that are generated during validation
                errors = Hash.new { |hsh, k| hsh[k] = [] }
                valid = false
        
        
        Severity: Minor
        Found in lib/json-schema/attributes/anyof.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 validate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.validate(current_schema, data, fragments, processor, validator, options = {})
                return unless data.is_a?(Hash)
        
                current_schema.schema['dependencies'].each do |property, dependency_value|
                  next unless data.has_key?(property.to_s)
        Severity: Minor
        Found in lib/json-schema/attributes/dependencies.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 initialize has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def initialize
                super
                @attributes = {
                  'type' => JSON::Schema::TypeAttribute,
                  'disallow' => JSON::Schema::DisallowAttribute,
        Severity: Minor
        Found in lib/json-schema/validators/draft2.rb - About 1 hr to fix

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

                def json_backend=(backend)
                  if defined?(MultiJson)
                    backend = backend == 'json' ? 'json_gem' : backend
                    MultiJson.respond_to?(:use) ? MultiJson.use(backend) : MultiJson.engine = backend
                  else
          Severity: Minor
          Found in lib/json-schema/validator.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 validate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.validate(current_schema, data, fragments, processor, validator, options = {})
                  return unless data.is_a?(Array)
          
                  schema = current_schema.schema
                  return unless schema['items'].is_a?(Array)
          Severity: Minor
          Found in lib/json-schema/attributes/additionalitems.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 normalize_ref has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.normalize_ref(ref, base)
                  ref_uri = parse(ref)
                  base_uri = parse(base)
          
                  ref_uri.defer_validation do
          Severity: Minor
          Found in lib/json-schema/util/uri.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 validate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.validate(current_schema, data, fragments, processor, validator, options = {})
                  return unless data.is_a?(String)
          
                  begin
                    ip = IPAddr.new(data)
          Severity: Minor
          Found in lib/json-schema/attributes/formats/ip.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 initialize has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def initialize
                  super
                  @attributes = {
                    'type' => JSON::Schema::TypeAttribute,
                    'disallow' => JSON::Schema::DisallowAttribute,
          Severity: Minor
          Found in lib/json-schema/validators/draft1.rb - About 1 hr to fix

            Method get_referenced_uri_and_schema has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def self.get_referenced_uri_and_schema(s, current_schema, validator)
                    uri, schema = nil, nil
            
                    temp_uri = JSON::Util::URI.normalize_ref(s['$ref'], current_schema.uri)
            
            
            Severity: Minor
            Found in lib/json-schema/attributes/ref.rb - About 1 hr to fix

              Method parse has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def parse(s)
                      if defined?(MultiJson)
                        begin
                          MultiJson.respond_to?(:adapter) ? MultiJson.load(s) : MultiJson.decode(s)
                        rescue MultiJson::ParseError => e
              Severity: Minor
              Found in lib/json-schema/validator.rb - About 1 hr to fix

                Method validate_dependency has 8 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                      def self.validate_dependency(schema, data, property, value, fragments, processor, attribute, options)
                Severity: Major
                Found in lib/json-schema/attributes/dependencies.rb - About 1 hr to fix

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

                        def self.remove_valid_properties(extra_properties, current_schema, validator)
                          schema = current_schema.schema
                  
                          if schema['properties']
                            extra_properties = extra_properties - schema['properties'].keys
                  Severity: Minor
                  Found in lib/json-schema/attributes/additionalproperties.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 parse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def self.parse(uri)
                          if uri.is_a?(Addressable::URI)
                            uri.dup
                          else
                            @parse_cache ||= {}
                  Severity: Minor
                  Found in lib/json-schema/util/uri.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 validate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def self.validate(current_schema, data, fragments, processor, validator, options = {})
                          schema = current_schema.schema
                          return unless data.is_a?(Hash) && (schema['type'].nil? || schema['type'] == 'object')
                  
                          extra_properties = remove_valid_properties(data.keys, current_schema, validator)
                  Severity: Minor
                  Found in lib/json-schema/attributes/additionalproperties.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 validate has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                        def self.validate(current_schema, data, fragments, processor, validator, options = {})
                  Severity: Minor
                  Found in lib/json-schema/attributes/formats/date_time_v4.rb - About 45 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language