gmailgem/gmail

View on GitHub
lib/gmail/mailbox.rb

Summary

Maintainability
C
1 day
Test Coverage

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 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 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 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

      There are no issues that match your filters.

      Category
      Status