dominicsayers/name_tamer

View on GitHub

Showing 29 of 29 total issues

File string.rb has 481 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class String
  unless respond_to? :presence
    def presence
      self unless empty?
    end
Severity: Minor
Found in lib/name_tamer/string.rb - About 7 hrs to fix

File constants.rb has 433 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module NameTamer
  NONBREAKING_SPACE = "\u00a0"
  ASCII_SPACE = ' '
  ADFIX_JOINERS = "[#{ASCII_SPACE}-]"
  SLUG_DELIMITER = '-'
Severity: Minor
Found in lib/name_tamer/constants.rb - About 6 hrs to fix

Class Name has 32 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Name
    # References:
    # http://www.w3.org/International/questions/qa-personal-names
    # https://github.com/berkmancenter/namae
    # https://github.com/mericson/people
Severity: Minor
Found in lib/name_tamer/name.rb - About 4 hrs to fix

Method remove_adfixes has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def remove_adfixes
      if @last_name.nil?
        # Our name is still in one part, not two
        loop do
          @nice_name = remove_outermost_adfix(:suffix, @nice_name)
Severity: Minor
Found in lib/name_tamer/name.rb - About 3 hrs 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

Class String has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

class String
  unless respond_to? :presence
    def presence
      self unless empty?
    end
Severity: Minor
Found in lib/name_tamer/string.rb - About 3 hrs to fix

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

    def contact_type_from(args)
      args_ct = args[:contact_type]
      return unless args_ct

      ct = args_ct.is_a?(Symbol) ? args_ct : args_ct.dup
Severity: Minor
Found in lib/name_tamer/name.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 remove_middle_names has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def remove_middle_names
      return unless @contact_type == :person

      first_name, parts = find_first_usable_name(@simple_name.split)
      last_name, = find_last_usable_name(parts)
Severity: Minor
Found in lib/name_tamer/name.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 name_wrangle_single_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def name_wrangle_single_name
      lowercase = @nice_name.downcase
      uppercase = @nice_name.upcase
      fix_case = false

Severity: Minor
Found in lib/name_tamer/name.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

Freeze mutable objects assigned to constants.
Open

  ALPHA = 'A-Za-z'
Severity: Minor
Found in lib/name_tamer/constants.rb by rubocop

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

Freeze mutable objects assigned to constants.
Open

  DIGIT = '0-9'
Severity: Minor
Found in lib/name_tamer/constants.rb by rubocop

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

Freeze mutable objects assigned to constants.
Open

  SUBDELIMS = '!$&\'\(\)\*+,;='
Severity: Minor
Found in lib/name_tamer/constants.rb by rubocop

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

Avoid comma after the last item of an array. (https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas)
Open

    'Service Company',
Severity: Minor
Found in lib/name_tamer/string.rb by rubocop

This cop checks for trailing comma in array and hash literals.

Example: EnforcedStyleForMultiline: consistent_comma

# bad
a = [1, 2,]

# good
a = [
  1, 2,
  3,
]

# good
a = [
  1,
  2,
]

Example: EnforcedStyleForMultiline: comma

# bad
a = [1, 2,]

# good
a = [
  1,
  2,
]

Example: EnforcedStyleForMultiline: no_comma (default)

# bad
a = [1, 2,]

# good
a = [
  1,
  2
]

Freeze mutable objects assigned to constants.
Open

  ASCII_SPACE = ' '
Severity: Minor
Found in lib/name_tamer/constants.rb by rubocop

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

Freeze mutable objects assigned to constants.
Open

  IUNRESERVED = "#{ALPHA}#{DIGIT}\\-\\._~#{UCSCHAR}"
Severity: Minor
Found in lib/name_tamer/constants.rb by rubocop

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

Freeze mutable objects assigned to constants.
Open

  ISEGMENT_NZ_NC = "#{IUNRESERVED}#{SUBDELIMS}@" # pct-encoded not needed
Severity: Minor
Found in lib/name_tamer/constants.rb by rubocop

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

Freeze mutable objects assigned to constants.
Open

  NONBREAKING_SPACE = "\u00a0"
Severity: Minor
Found in lib/name_tamer/string.rb by rubocop

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

Freeze mutable objects assigned to constants.
Open

  ASCII_SPACE = ' '
Severity: Minor
Found in lib/name_tamer/string.rb by rubocop

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

Freeze mutable objects assigned to constants.
Open

  VERSION = '0.6.1'
Severity: Minor
Found in lib/name_tamer/version.rb by rubocop

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

Avoid comma after the last item of an array. (https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas)
Open

        'V.M.D.',
Severity: Minor
Found in lib/name_tamer/constants.rb by rubocop

This cop checks for trailing comma in array and hash literals.

Example: EnforcedStyleForMultiline: consistent_comma

# bad
a = [1, 2,]

# good
a = [
  1, 2,
  3,
]

# good
a = [
  1,
  2,
]

Example: EnforcedStyleForMultiline: comma

# bad
a = [1, 2,]

# good
a = [
  1,
  2,
]

Example: EnforcedStyleForMultiline: no_comma (default)

# bad
a = [1, 2,]

# good
a = [
  1,
  2
]

Avoid comma after the last item of an array. (https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas)
Open

        'U.D.',
Severity: Minor
Found in lib/name_tamer/constants.rb by rubocop

This cop checks for trailing comma in array and hash literals.

Example: EnforcedStyleForMultiline: consistent_comma

# bad
a = [1, 2,]

# good
a = [
  1, 2,
  3,
]

# good
a = [
  1,
  2,
]

Example: EnforcedStyleForMultiline: comma

# bad
a = [1, 2,]

# good
a = [
  1,
  2,
]

Example: EnforcedStyleForMultiline: no_comma (default)

# bad
a = [1, 2,]

# good
a = [
  1,
  2
]
Severity
Category
Status
Source
Language