daddyz/phonelib

View on GitHub

Showing 214 of 214 total issues

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

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

    # getter for phone data for other modules of gem, can be used outside
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. [176/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. [112/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. [110/100]
Open

  module PhoneAnalyzerHelper
    private

    def original_starts_with_plus?
      original_s[0] == Core::PLUS_SIGN

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. [108/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.

Module has too many lines. [102/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.

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.

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 valid?
      return "#{prefix}#{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 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.

    File core.rb has 251 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 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

      Assignment Branch Condition size for import_country_names is too high. [17.72/15]
      Open

            def import_country_names
              puts 'IMPORTING COUNTRY NAMES'
      
              require 'open-uri'
              require 'csv'
      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

      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.

      Cyclomatic complexity for international is too high. [8/6]
      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 valid?
            return "#{prefix}#{country_code}#{@national_number}" unless formatted
      Severity: Minor
      Found in lib/phonelib/phone_formatter.rb by rubocop

      This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

      An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

      Severity
      Category
      Status
      Source
      Language