daddyz/phonelib

View on GitHub

Showing 280 of 280 total issues

Missing magic comment # frozen_string_literal: true.
Open

source "http://rubygems.org"
Severity: Minor
Found in gemfiles/Gemfile by rubocop

This cop is designed to help upgrade to Ruby 3.0. It will add the comment # frozen_string_literal: true to the top of files to enable frozen string literals. Frozen string literals may be default in Ruby 3.0. The comment will be added below a shebang and encoding comment. The frozen string literal comment is only valid in Ruby 2.3+.

Example: EnforcedStyle: when_needed (default)

# The `when_needed` style will add the frozen string literal comment
# to files only when the `TargetRubyVersion` is set to 2.3+.
# bad
module Foo
  # ...
end

# good
# frozen_string_literal: true

module Foo
  # ...
end

Example: EnforcedStyle: always

# The `always` style will always add the frozen string literal comment
# to a file, regardless of the Ruby version or if `freeze` or `<<` are
# called on a string literal.
# bad
module Bar
  # ...
end

# good
# frozen_string_literal: true

module Bar
  # ...
end

Example: EnforcedStyle: never

# The `never` will enforce that the frozen string literal comment does
# not exist in a file.
# bad
# frozen_string_literal: true

module Baz
  # ...
end

# good
module Baz
  # ...
end

Line is too long. [92/80]
Open

  s.files = Dir['{lib,tasks}/**/*'] + Dir['data/*.dat'] + %w(MIT-LICENSE Rakefile README.md)
Severity: Minor
Found in phonelib.gemspec by rubocop

Missing magic comment # frozen_string_literal: true.
Open

# Validator class for phone validations
Severity: Minor
Found in lib/validators/phone_validator.rb by rubocop

This cop is designed to help upgrade to Ruby 3.0. It will add the comment # frozen_string_literal: true to the top of files to enable frozen string literals. Frozen string literals may be default in Ruby 3.0. The comment will be added below a shebang and encoding comment. The frozen string literal comment is only valid in Ruby 2.3+.

Example: EnforcedStyle: when_needed (default)

# The `when_needed` style will add the frozen string literal comment
# to files only when the `TargetRubyVersion` is set to 2.3+.
# bad
module Foo
  # ...
end

# good
# frozen_string_literal: true

module Foo
  # ...
end

Example: EnforcedStyle: always

# The `always` style will always add the frozen string literal comment
# to a file, regardless of the Ruby version or if `freeze` or `<<` are
# called on a string literal.
# bad
module Bar
  # ...
end

# good
# frozen_string_literal: true

module Bar
  # ...
end

Example: EnforcedStyle: never

# The `never` will enforce that the frozen string literal comment does
# not exist in a file.
# bad
# frozen_string_literal: true

module Baz
  # ...
end

# good
module Baz
  # ...
end

Line is too long. [94/80]
Open

    countries = options[:countries].is_a?(Array) ? options[:countries] : [options[:countries]]
Severity: Minor
Found in lib/validators/phone_validator3.rb by rubocop

Line is too long. [116/80]
Open

    # eagerly initialize the gem, loads data into memory. not required, initialization is done lazily otherwise, but
Severity: Minor
Found in lib/phonelib/core.rb by rubocop

Line is too long. [133/80]
Open

    # @return [Boolean] Flag defines whether to ignore plus for country reset during validations in case country prefix doesn't match
Severity: Minor
Found in lib/phonelib/core.rb by rubocop

Replace class var @@phone_data with a class instance var.
Open

      @@phone_data ||= load_data.freeze
Severity: Minor
Found in lib/phonelib/core.rb by rubocop

This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

Replace class var @@parse_special with a class instance var.
Open

      @@parse_special = special
Severity: Minor
Found in lib/phonelib/core.rb by rubocop

This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

Replace class var @@ignore_plus with a class instance var.
Open

    @@ignore_plus = false
Severity: Minor
Found in lib/phonelib/core.rb by rubocop

This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

Replace class var @@vanity_conversion with a class instance var.
Open

    @@vanity_conversion = false
Severity: Minor
Found in lib/phonelib/core.rb by rubocop

This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

Unused block argument - k. If it's necessary, use _ or _k as an argument name to indicate that it won't be used.
Open

      @@all_int_prefixes ||= phone_data.map {|k,v| v[:international_prefix] }.select { |v| v != '' }.compact.uniq.join('|').freeze
Severity: Minor
Found in lib/phonelib/core.rb by rubocop

This cop checks for unused block arguments.

Example:

# bad

do_something do |used, unused|
  puts used
end

do_something do |bar|
  puts :foo
end

define_method(:foo) do |bar|
  puts :baz
end

Example:

#good

do_something do |used, _unused|
  puts used
end

do_something do
  puts :foo
end

define_method(:foo) do |_bar|
  puts :baz
end

Missing top-level class documentation comment.
Open

    class Phonelib::Railtie < Rails::Railtie
Severity: Minor
Found in lib/phonelib.rb by rubocop

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

Example:

# bad
class Person
  # ...
end

# good
# Description/Explanation of Person class
class Person
  # ...
end

Replace class var @@extension_separate_symbols with a class instance var.
Open

      @@extension_separate_symbols = separator
Severity: Minor
Found in lib/phonelib/core.rb by rubocop

This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

Freeze mutable objects assigned to constants.
Open

    FILE_EXT_DATA = 'data/extended_data.dat'
Severity: Minor
Found in lib/phonelib/core.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

Line is too long. [98/80]
Open

      return analyze_single_country(phone, countries.first, passed_country) if countries.size == 1
Severity: Minor
Found in lib/phonelib/phone_analyzer.rb by rubocop

Use !empty? instead of size > 0.
Open

    (phone_countries & countries).size > 0
Severity: Minor
Found in lib/validators/phone_validator3.rb by rubocop

This cop checks for numeric comparisons that can be replaced by a predicate method, such as receiver.length == 0, receiver.length > 0, receiver.length != 0, receiver.length < 1 and receiver.size == 0 that can be replaced by receiver.empty? and !receiver.empty.

Example:

# bad
[1, 2, 3].length == 0
0 == "foobar".length
array.length < 1
{a: 1, b: 2}.length != 0
string.length > 0
hash.size > 0

# good
[1, 2, 3].empty?
"foobar".empty?
array.empty?
!{a: 1, b: 2}.empty?
!string.empty?
!hash.empty?

Line is too long. [84/80]
Open

      when original_starts_with_plus? && phone.start_with?(data[Core::COUNTRY_CODE])
Severity: Minor
Found in lib/phonelib/phone_analyzer.rb by rubocop

Line is too long. [85/80]
Open

    # @return [Boolean] Flag defines whether to do strict double prefix parsing check
Severity: Minor
Found in lib/phonelib/core.rb by rubocop

Line is too long. [84/80]
Open

              default_data[country][Core::TYPES][type][key] << "|#{regex.join('|')}"
Severity: Minor
Found in lib/phonelib/core.rb by rubocop

Replace class var @@phone_data with a class instance var.
Open

      @@phone_data = @@data_by_country_codes = nil
Severity: Minor
Found in lib/phonelib/core.rb by rubocop

This cop checks for uses of class variables. Offenses are signaled only on assignment to class variables to reduce the number of offenses that would be reported.

Severity
Category
Status
Source
Language