afair/email_address

View on GitHub

Showing 31 of 33 total issues

Method parse_srs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_srs(email, options = {}, &block)
    if email&.match(SRS_FORMAT_REGEX)
      @rewrite_scheme = :srs
      hhh, tt, domain, local, sending_domain = [$1, $2, $3, $4, $5]
      # hhh = tt = sending_domain if false && hhh # Hide warnings for now :-)
Severity: Minor
Found in lib/email_address/rewriter.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 matches? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def matches?(*rules)
      rules.flatten!
      match = local.matches?(rules)
      match ||= host.matches?(rules)
      return match if match
Severity: Minor
Found in lib/email_address/address.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 find_provider has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def find_provider # :nodoc:
      return provider if provider

      Config.providers.each do |provider, config|
        if config[:host_match] && matches?(config[:host_match])
Severity: Minor
Found in lib/email_address/host.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 valid_size? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def valid_size?
      return set_error(:local_size_long) if local.size > STANDARD_MAX_SIZE
      if @host&.hosted_service?
        return false if @config[:local_private_size] && !valid_size_checks(@config[:local_private_size])
      elsif @config[:local_size] && !valid_size_checks(@config[:local_size])
Severity: Minor
Found in lib/email_address/local.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

Avoid too many return statements within this method.
Open

        return rule if self.provider && provider_matches?(rule)
Severity: Major
Found in lib/email_address/host.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            return rule if ip_matches?(rule)
    Severity: Major
    Found in lib/email_address/host.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return rule if domain_matches?(rule)
      Severity: Major
      Found in lib/email_address/host.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return false unless host.valid?
        Severity: Major
        Found in lib/email_address/address.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return false unless local.valid?
          Severity: Major
          Found in lib/email_address/address.rb - About 30 mins to fix

            Method format has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def format(form = @config[:local_format] || :conventional)
                  if @config[:local_format].is_a?(Proc)
                    @config[:local_format].call(self)
                  elsif form == :conventional
                    conventional
            Severity: Minor
            Found in lib/email_address/local.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 error_messages has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def self.error_messages(hash = {}, locale = "en", *extra)
                  hash = extra.first if extra.first.is_a? Hash
            
                  @errors[locale] ||= {}
                  @errors[locale]["email_address"] ||= {}
            Severity: Minor
            Found in lib/email_address/config.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

            Severity
            Category
            Status
            Source
            Language