daddyz/phonelib

View on GitHub

Showing 280 of 280 total issues

Module has too many lines. [270/100]
Open

  module Core
    # @private variable will include hash with data for validation
    @@phone_data = nil

    # 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

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Class has too many lines. [226/100]
Open

    class Importer
      include Phonelib::DataImporterHelper

      # countries that can have double country prefix in number
      DOUBLE_COUNTRY_CODES_COUNTRIES = %w(IN DE BR IT NO PL CU VN)
Severity: Minor
Found in lib/phonelib/data_importer.rb by rubocop

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Module has too many lines. [133/100]
Open

  module PhoneAnalyzer
    # extending with helper methods for analyze
    include Phonelib::PhoneAnalyzerHelper

    # array of types not included for validation check in cycle
Severity: Minor
Found in lib/phonelib/phone_analyzer.rb by rubocop

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Module has too many lines. [123/100]
Open

  module PhoneAnalyzerHelper
    private

    def decorate_analyze_result(result)
      if result.size == 1

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Module has too many lines. [112/100]
Open

  module PhoneFormatter
    # Returns formatted national number
    # @param formatted [Boolean] whether to return numbers only or formatted
    # @return [String] formatted national number
    def national(formatted = true)
Severity: Minor
Found in lib/phonelib/phone_formatter.rb by rubocop

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Class has too many lines. [109/100]
Open

  class Phone
    # @!attribute [r] original
    # @return [String] original phone number passed for parsing
    attr_reader :original
    # @!attribute [r] extension
Severity: Minor
Found in lib/phonelib/phone.rb by rubocop

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Module has too many lines. [102/100]
Open

  module DataImporterHelper
    # xml comments attributes names that should not be parsed
    XML_COMMENT_ATTRIBUTES = %w(text comment)
    # xml format attributes names
    XML_FORMAT_NAMES = %w(intlFormat format)

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for load_data is too high. [36.47/15]
Open

    def load_data
      data_file = "#{File.dirname(__FILE__)}/../../#{FILE_MAIN_DATA}"
      default_data = Marshal.load(File.binread(data_file))
      if override_phone_data
        override_data_file = Marshal.load(File.binread(override_phone_data))
Severity: Minor
Found in lib/phonelib/core.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [22/10]
Open

    def load_data
      data_file = "#{File.dirname(__FILE__)}/../../#{FILE_MAIN_DATA}"
      default_data = Marshal.load(File.binread(data_file))
      if override_phone_data
        override_data_file = Marshal.load(File.binread(override_phone_data))
Severity: Minor
Found in lib/phonelib/core.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [21/10]
Open

    def hash_from_xml(data, type)
      hash = {}
      case type
      when :attributes
        data.attributes.each do |k, v|

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

File core.rb has 273 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Phonelib
  # main module that includes all basic data and methods
  module Core
    # @private variable will include hash with data for validation
    @@phone_data = nil
Severity: Minor
Found in lib/phonelib/core.rb - About 2 hrs to fix

    Assignment Branch Condition size for merge_short_with_main_type is too high. [22.38/15]
    Open

          def merge_short_with_main_type(country_id, type, data)
            @data[country_id][:types][type] ||= {}
            @data[country_id][:types][type][Core::SHORT] ||= {}
            data.each do |k, v|
              if @data[country_id][:types][type][Core::SHORT][k]
    Severity: Minor
    Found in lib/phonelib/data_importer.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for international is too high. [22.93/15]
    Open

        def international(formatted = true, prefix = '+')
          prefix = formatted if formatted.is_a?(String)
          return nil if sanitized.empty?
          return "#{prefix}#{country_prefix_or_not}#{sanitized}" unless possible?
          return "#{prefix}#{data_country_code}#{@national_number}" unless formatted
    Severity: Minor
    Found in lib/phonelib/phone_formatter.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Class Phone has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Phone
        # @!attribute [r] original
        # @return [String] original phone number passed for parsing
        attr_reader :original
        # @!attribute [r] extension
    Severity: Minor
    Found in lib/phonelib/phone.rb - About 2 hrs to fix

      Assignment Branch Condition size for country_code is too high. [20.27/15]
      Open

          def country_code
            return @country_code if @country_code
      
            code = Phonelib.phone_data[country] && Phonelib.phone_data[country][Core::COUNTRY_CODE]
            return @country_code = code unless code == '1' && Phonelib.phone_data[country][Core::LEADING_DIGITS]
      Severity: Minor
      Found in lib/phonelib/phone_formatter.rb by rubocop

      This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

      Assignment Branch Condition size for hash_from_xml is too high. [20.05/15]
      Open

          def hash_from_xml(data, type)
            hash = {}
            case type
            when :attributes
              data.attributes.each do |k, v|

      This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

      Method has too many lines. [15/10]
      Open

          def formatting_data
            return @formatting_data if defined?(@formatting_data)
      
            data = @data[country]
            format = data[:format]
      Severity: Minor
      Found in lib/phonelib/phone_formatter.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Assignment Branch Condition size for detect_and_parse is too high. [18.47/15]
      Open

          def detect_and_parse(phone, country)
            countries_data = country_code_candidates_for(phone).flat_map { |code|
              Phonelib.data_by_country_codes[code] || []
            }
            countries_data.each_with_object({}) do |data, result|
      Severity: Minor
      Found in lib/phonelib/phone_analyzer.rb by rubocop

      This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

      Assignment Branch Condition size for convert_to_e164 is too high. [17.49/15]
      Open

          def convert_to_e164(phone, data)
            match = phone.match full_regex_for_data(data, Core::VALID_PATTERN, !original_starts_with_plus?)
            case
            when match
              "#{data[Core::COUNTRY_CODE]}#{match.to_a.last}"
      Severity: Minor
      Found in lib/phonelib/phone_analyzer.rb by rubocop

      This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

      Method has too many lines. [12/10]
      Open

            def types_and_formats(children)
              result = { types: {}, formats: [] }
      
              without_comments(children).each do |phone_type|
                if phone_type.name == 'references'
      Severity: Minor
      Found in lib/phonelib/data_importer.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Severity
      Category
      Status
      Source
      Language