gmailgem/gmail

View on GitHub

Showing 13 of 16 total issues

Class Message has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Message
    PREFETCH_ATTRS = ["UID", "ENVELOPE", "BODY.PEEK[]", "FLAGS", "X-GM-LABELS", "X-GM-MSGID", "X-GM-THRID"].freeze

    # Raised when given label doesn't exists.
    class NoLabelError < RuntimeError; end
Severity: Minor
Found in lib/gmail/message.rb - About 3 hrs to fix

    Consider simplifying this complex logical expression.
    Open

          if args.first.is_a?(Symbol)
            search = MAILBOX_ALIASES[args.shift].dup
            opts = args.first.is_a?(Hash) ? args.first : {}
    
            opts[:after]      and search.concat ['SINCE', Net::IMAP.format_date(opts[:after])]
    Severity: Critical
    Found in lib/gmail/mailbox.rb - About 3 hrs to fix

      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

        Class Base has 23 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class Base
              # Gmail IMAP defaults
              GMAIL_IMAP_HOST = 'imap.gmail.com'.freeze
              GMAIL_IMAP_PORT = 993
        
        
        Severity: Minor
        Found in lib/gmail/client/base.rb - About 2 hrs to fix

          Method wait_once has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              def wait_once(options = {})
                options[:idle_timeout] ||= 29 * 60
          
                response = nil
                loop do
          Severity: Minor
          Found in lib/gmail/mailbox.rb - About 2 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 fetch_uids has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def fetch_uids(*args)
                args << :all if args.empty?
          
                if args.first.is_a?(Symbol)
                  search = MAILBOX_ALIASES[args.shift].dup
          Severity: Minor
          Found in lib/gmail/mailbox.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 fetch_uids has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def fetch_uids(*args)
                  args << :all if args.empty?
            
                  if args.first.is_a?(Symbol)
                    search = MAILBOX_ALIASES[args.shift].dup
            Severity: Minor
            Found in lib/gmail/mailbox.rb - About 1 hr to fix

              Method mailbox has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def mailbox(name, &block)
                      @mailbox_mutex.synchronize do
                        name = labels.localize(name)
                        mailbox = (mailboxes[name] ||= Mailbox.new(self, name))
                        switch_to_mailbox(mailbox) if @current_mailbox != mailbox
              Severity: Minor
              Found in lib/gmail/client/base.rb - About 55 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 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

              Severity
              Category
              Status
              Source
              Language