EmmanuelOga/ffaker

View on GitHub

Showing 44 of 44 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

      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
        format = args[2] if args.size > 2
Severity: Major
Found in lib/ffaker/book.rb and 2 other locations - About 45 mins to fix
lib/ffaker/avatar.rb on lines 11..16
lib/ffaker/filesystem.rb on lines 24..29

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 40.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

      if args.any?
        warn "Positional arguments for Filesystem##{__method__} are deprecated. Please use keyword arguments."
        dir = args[0]
        name = args[1] if args.size > 1
        ext = args[2] if args.size > 2
Severity: Major
Found in lib/ffaker/filesystem.rb and 2 other locations - About 45 mins to fix
lib/ffaker/avatar.rb on lines 11..16
lib/ffaker/book.rb on lines 34..39

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 40.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

      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
        format = args[2] if args.size > 2
Severity: Major
Found in lib/ffaker/avatar.rb and 2 other locations - About 45 mins to fix
lib/ffaker/book.rb on lines 34..39
lib/ffaker/filesystem.rb on lines 24..29

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 40.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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 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 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 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 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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def e164_home_work_phone_number
      phone_prefix = home_work_phone_prefix
      case phone_prefix.size
      when 2 then FFaker.numerify("#{e164_country_code}#{phone_prefix[1]}#######")
      when 3 then FFaker.numerify("#{e164_country_code}#{phone_prefix[1, 2]}######")
Severity: Minor
Found in lib/ffaker/phone_number_cu.rb and 1 other location - About 35 mins to fix
lib/ffaker/phone_number_cu.rb on lines 77..81

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 34.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    def international_home_work_phone_number
      phone_prefix = home_work_phone_prefix
      case phone_prefix.size
      when 2 then FFaker.numerify("#{international_country_code}#{phone_prefix[1]} ### ####")
      when 3 then FFaker.numerify("#{international_country_code}#{phone_prefix[1, 2]} ## ####")
Severity: Minor
Found in lib/ffaker/phone_number_cu.rb and 1 other location - About 35 mins to fix
lib/ffaker/phone_number_cu.rb on lines 100..104

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 34.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. 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 and 1 other location - About 25 mins to fix
lib/ffaker/name_da.rb on lines 28..34

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 30.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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 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

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

Similar blocks of code found in 2 locations. 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 and 1 other location - About 25 mins to fix
lib/ffaker/name_mx.rb on lines 69..74

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 30.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    MASS_UNITS = [
      { name: 'grains', abbreviation: 'gr' },
      { name: 'ounces', abbreviation: 'oz' },
      { name: 'pounds', abbreviation: 'lb' },
      { name: 'hundredweight', abbreviation: 'cwt' },
Severity: Minor
Found in lib/ffaker/unit_english.rb and 1 other location - About 20 mins to fix
lib/ffaker/unit_english.rb on lines 10..16

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    LENGTH_UNITS = [
      { name: 'inch', abbreviation: 'in' },
      { name: 'foot', abbreviation: 'ft' },
      { name: 'yard', abbreviation: 'yd' },
      { name: 'furlong', abbreviation: 'fur' },
Severity: Minor
Found in lib/ffaker/unit_english.rb and 1 other location - About 20 mins to fix
lib/ffaker/unit_english.rb on lines 17..23

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 28.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Severity
Category
Status
Source
Language