flavorjones/calendar-assistant

View on GitHub

Showing 13 of 13 total issues

Method available_blocks has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

      def available_blocks(length: 1)
        event_repository.in_tz do
          dates = events.keys.sort

          # iterate over the days finding free chunks of time
Severity: Minor
Found in lib/calendar_assistant/event_set.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 Event has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Event < SimpleDelegator
    include HasDuration

    #  constants describing enumerated attribute values
    #  see https://developers.google.com/calendar/v3/reference/events
Severity: Minor
Found in lib/calendar_assistant/event.rb - About 2 hrs to fix

    Method print_available_blocks has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def print_available_blocks(ca, event_set, omit_title: false)
            ers = ca.config.calendar_ids.map { |calendar_id| ca.event_repository calendar_id }
            time_zones = ers.map { |er| er.calendar.time_zone }.uniq
    
            unless omit_title
    Severity: Minor
    Found in lib/calendar_assistant/cli/printer.rb - About 1 hr to fix

      Method event_attributes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def event_attributes
              attributes = []
      
              attributes << "recurring" if recurring?
              attributes << "not-busy" unless busy?
      Severity: Minor
      Found in lib/calendar_assistant/cli/event_presenter.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 intersection has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def intersection(other, length: 1)
              set = new({})
              set.ensure_keys(events.keys + other.events.keys)
              set.events.keys.each do |date|
                events[date].each do |event_a|
      Severity: Minor
      Found in lib/calendar_assistant/event_set.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 available_blocks has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def available_blocks(length: 1)
              event_repository.in_tz do
                dates = events.keys.sort
      
                # iterate over the days finding free chunks of time
      Severity: Minor
      Found in lib/calendar_assistant/event_set.rb - About 1 hr to fix

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

              def prompt(query, default = nil)
                loop do
                  message = query
                  message += " [#{default}]" if default
                  message += ": "
        Severity: Minor
        Found in lib/calendar_assistant/cli/printer.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 join has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def join(timespec = "now")
                return if handle_help_args
                set_formatting
                ca = CalendarAssistant.new command_service.config, service: command_service.service
                ca.in_env do
        Severity: Minor
        Found in lib/calendar_assistant/cli/commands.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 abandoned? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def abandoned?
              return false if declined? || self? || response_status.nil? || !visible_guestlist?
              human_attendees.each do |attendee|
                next if attendee.self
                return false if attendee.response_status != CalendarAssistant::Event::Response::DECLINED
        Severity: Minor
        Found in lib/calendar_assistant/event.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 print_available_blocks has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def print_available_blocks(ca, event_set, omit_title: false)
                ers = ca.config.calendar_ids.map { |calendar_id| ca.event_repository calendar_id }
                time_zones = ers.map { |er| er.calendar.time_zone }.uniq
        
                unless omit_title
        Severity: Minor
        Found in lib/calendar_assistant/cli/printer.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 ensure_keys has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def ensure_keys(keys, only: false)
                keys.each do |key|
                  events[key] = [] unless events.has_key?(key)
                end
                if only
        Severity: Minor
        Found in lib/calendar_assistant/event_set.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 event_date has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def event_date
                if all_day?
                  start_date = __getobj__.start_date
                  end_date = __getobj__.end_date
                  if (end_date - start_date) <= 1
        Severity: Minor
        Found in lib/calendar_assistant/cli/event_presenter.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize(file: nil, load_events: true)
              @file = file
              if (@file && File.exist?(@file) && load_events)
                payload = File.read(@file)
                @store = if YAML.respond_to?(:unsafe_load)
        Severity: Minor
        Found in lib/calendar_assistant/local_service.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