gmailgem/gmail

View on GitHub
lib/gmail/imap_extensions.rb

Summary

Maintainability
C
1 day
Test Coverage

Method patch_net_imap_response_parser has 88 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.patch_net_imap_response_parser(klass = Net::IMAP::ResponseParser)
      # https://github.com/ruby/ruby/blob/4d426fc2e03078d583d5d573d4863415c3e3eb8d/lib/net/imap.rb#L2258
      klass.class_eval do
        def msg_att(n = -1)
          match(Net::IMAP::ResponseParser::T_LPAR)
Severity: Major
Found in lib/gmail/imap_extensions.rb - About 3 hrs to fix

    Method extract_labels_response has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

            def extract_labels_response
              special, quoted = false, false
              index, paren_count = 0, 0
    
              # Start parsing response string for the labels section, parentheses inclusive
    Severity: Minor
    Found in lib/gmail/imap_extensions.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

    Method msg_att has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def msg_att(n = -1)
              match(Net::IMAP::ResponseParser::T_LPAR)
              attr = {}
              while true
                token = lookahead
    Severity: Minor
    Found in lib/gmail/imap_extensions.rb - About 1 hr 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 unescape has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def unescape
              unesc = ''
              special = false
              escapes = { '\\' => '\\',
                          '"'  => '"',
    Severity: Minor
    Found in lib/gmail/imap_extensions.rb - About 1 hr 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 add_unescape has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.add_unescape(klass = String)
          klass.class_eval do
            # Add a method to string which unescapes special characters
            # We use a simple state machine to ensure that specials are not
            # themselves escaped
    Severity: Minor
    Found in lib/gmail/imap_extensions.rb - About 1 hr to fix

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

              def x_gm_label_list
                if @str.index(/\(([^)]*)\)/ni, @pos)
                  resp = extract_labels_response
      
                  # We need to manually update the position of the regexp to prevent trip-ups
      Severity: Minor
      Found in lib/gmail/imap_extensions.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

      There are no issues that match your filters.

      Category
      Status