Showing 4 of 4 total issues

Method sex has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def sex(options = {})
      options = {
        format: :default
      }.merge(options)

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

    def initialize(args = nil)
      if args.nil?
        @number = Generator.generate
      else
        case args
Severity: Minor
Found in lib/egn/egn.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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def validate
      return false unless @egn.length == 10
      return false unless Date.valid_date?(@year, @month, @day)
      
      # Gregorian calendar adoption in 1916 in Bulgaria
Severity: Minor
Found in lib/egn/validator.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

Method validate! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def validate!(options)
      raise ArgumentError, 'Year out of bounds' if options[:year] && !(1800..2099).include?(options[:year])
      raise ArgumentError, 'Month out of bounds' if options[:month] && !(1..12).include?(options[:month])
      raise ArgumentError, 'Day out of bounds' if options[:day] && !(1..31).include?(options[:day])
      raise ArgumentError, "Gender should be one of #{genders}" if options[:gender] && !genders.include?(options[:gender])
Severity: Minor
Found in lib/egn/generator.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