danascheider/json_test_data

View on GitHub

Showing 6 of 6 total issues

json Gem for Ruby Unsafe Object Creation Vulnerability (additional fix)
Open

    json (1.8.6)
Severity: Critical
Found in Gemfile.lock by bundler-audit

Advisory: CVE-2020-10663

Criticality: High

URL: https://www.ruby-lang.org/en/news/2020/03/19/json-dos-cve-2020-10663/

Solution: upgrade to >= 2.3.0

Regular Expression Denial of Service in Addressable templates
Open

    addressable (2.5.2)
Severity: Critical
Found in Gemfile.lock by bundler-audit

Advisory: CVE-2021-32740

Criticality: High

URL: https://github.com/advisories/GHSA-jxhc-q857-3j6g

Solution: upgrade to >= 2.8.0

Cyclomatic complexity for generate_object is too high. [7/6]
Open

      def generate_object(object)
        obj = {}

        if object.has_key?(:oneOf)
          schema_to_be_used = object.fetch(:oneOf).sample
Severity: Minor
Found in lib/json_test_data/json_schema.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Cyclomatic complexity for generate_data is too high. [7/6]
Open

      def generate_data(obj, key)
        return handler.get_data(key, obj) if handler && handler.manages_key?(key)

        case obj.fetch(:type)
        when "number"
Severity: Minor
Found in lib/json_test_data/json_schema.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

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

      def generate_object(object)
        obj = {}

        if object.has_key?(:oneOf)
          schema_to_be_used = object.fetch(:oneOf).sample
Severity: Minor
Found in lib/json_test_data/json_schema.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 step_size has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def step_size
      return @step_size ||= is_int? ? 1 : 0.5 unless minimum && maximum

      @step_size ||= Number.between(min: minimum, max: maximum, integer: type == :integer) / 3
      is_int? ? @step_size.to_i : @step_size.round(2)
Severity: Minor
Found in lib/json_test_data/data_structures/number.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