EmmanuelOga/ffaker

View on GitHub

Showing 16 of 44 total issues

Method process_token has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def process_token(tokens)
      return '' if tokens.empty?

      token = tokens.shift

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

    def url(*args, size: '300x300', format: 'png', bg_color: :random, text_color: :random, text: nil)
      if args.any?
        warn "Positional arguments for Image##{__method__} are deprecated. Please use keyword arguments."
        size = args[0]
        format = args[1] if args.size > 1
Severity: Minor
Found in lib/ffaker/image.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 body has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def body
      body = content_tag_for(:h1, words(2).capitalize)
      rand(0..3).times do
        body << content_tag_for(:p, fancy_string)
      end
Severity: Minor
Found in lib/ffaker/html_ipsum.rb - About 1 hr to fix

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

        def image(*args, slug: nil, size: '300x300', format: 'png', bgset: nil)
          if args.any?
            warn "Positional arguments for Avatar##{__method__} are deprecated. Please use keyword arguments."
            slug = args[0]
            size = args[1] if args.size > 1
    Severity: Minor
    Found in lib/ffaker/avatar.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 file has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def file(*args, size: '300x300', format: 'png', bg_color: :random, text_color: :random, text: nil)
          if args.any?
            warn "Positional arguments for Image##{__method__} are deprecated. Please use keyword arguments."
            size = args[0]
            format = args[1] if args.size > 1
    Severity: Minor
    Found in lib/ffaker/image.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 cover has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def cover(*args, slug: nil, size: '300x300', format: 'png', bgset: nil)
          if args.any?
            warn "Positional arguments for Book##{__method__} are deprecated. Please use keyword arguments."
            slug = args[0]
            size = args[1] if args.size > 1
    Severity: Minor
    Found in lib/ffaker/book.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 check_passed_params has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_passed_params(size, format, bgset)
          invalid_size_error unless size.match?(/^[0-9]+x[0-9]+$/)
          invalid_format_error unless SUPPORTED_FORMATS.include?(format)
          invalid_background_number unless bgset.nil? || (1..2).cover?(bgset.to_i)
        end
    Severity: Minor
    Found in lib/ffaker/avatar.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 raise_error_on_bad_arguments has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def raise_error_on_bad_arguments(from, to, gender)
          raise ArgumentError, 'Invalid from argument: from' unless to.is_a? ::Time
          raise ArgumentError, 'Invalid from argument: from' unless from.is_a? ::Time
          raise ArgumentError, 'Invalid argument: from > to' if from > to
          raise ArgumentError, 'Invalid argument: gender' unless GENDERS.include?(gender.to_s)
    Severity: Minor
    Found in lib/ffaker/ssn_se.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 document_verification_digits has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def document_verification_digits(verification_multipliers, document = nil)
          return false if document.nil?
    
          document_digits = document.to_s.scan(/[0-9]/).map(&:to_i)
          validation_digits = []
    Severity: Minor
    Found in lib/ffaker/identification_br.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 digits_sum has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def digits_sum(digits)
          sum = 0
          digits.chars.each_with_index do |char, index|
            if index.even?
              multiple = char.to_i * 2
    Severity: Minor
    Found in lib/ffaker/identification_ec.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 file_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def file_name(
          *args,
          dir: directory, name: Lorem.word.downcase, ext: extension, directory_separator: File::SEPARATOR
        )
          if args.any?
    Severity: Minor
    Found in lib/ffaker/filesystem.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 select_sex has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def select_sex(sex) # :nodoc:
          @fixed_sex ||= nil
          given_sex = @fixed_sex || sex
          raise ArgumentError, "Unknown sex #{given_sex}" unless GENDERS.include?(given_sex)
    
    
    Severity: Minor
    Found in lib/ffaker/name_cs.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 generate_range has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def generate_range(tokens)
          result = []
          while tokens.any?
            token = tokens.shift
            if token == DASH && tokens.first && result.last
    Severity: Minor
    Found in lib/ffaker/string.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 npi has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def npi(legacy: false)
          max = legacy ? 299_999_999 : 999_999_999
          base_npi = rand(100_000_000..max).to_s
    
          summed_digits = base_npi
    Severity: Minor
    Found in lib/ffaker/code.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 first_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def first_name(gender = :any)
          case gender
          when :any then rand(0..1).zero? ? first_name(:male) : first_name(:female)
          when :male then fetch_sample(MALE_FIRST_NAMES)
          when :female then fetch_sample(FEMALE_FIRST_NAMES)
    Severity: Minor
    Found in lib/ffaker/name_da.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 name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def name(gender = :any)
          case gender
          when :any then rand(0..1).zero? ? name(:male) : name(:female)
          when :male then fetch_sample(MALE_FIRST_NAMES)
          when :female then fetch_sample(FEMALE_FIRST_NAMES)
    Severity: Minor
    Found in lib/ffaker/name_mx.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