botanicus/now-task-manager

View on GitHub

Showing 34 of 34 total issues

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

  def self.main(today_tasks, task_list)
    if today_tasks && current_time_frame = today_tasks.current_time_frame
      colour, icon = self.heading(current_time_frame, today_tasks.active_task)
      puts icon, '---'
      self.with_active_time_frame(current_time_frame)
Severity: Minor
Found in lib/pomodoro/commands/bitbar.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 run has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    unless File.directory?(self.config.today_path_dir)
      command "mkdir #{self.config.today_path_dir}"
    end

Severity: Minor
Found in lib/pomodoro/commands/generate.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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

module Pomodoro::Formats::Review::Plugins::Medications
  HEADER ||= 'Medications'

  def self.parse(string)
    tree = Parser.new.parse(string)
Severity: Major
Found in lib/pomodoro/formats/review/plugins/medications.rb and 1 other location - About 1 hr to fix
lib/pomodoro/formats/review/plugins/activities.rb on lines 8..30

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 68.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

module Pomodoro::Formats::Review::Plugins::Activities
  HEADER ||= 'Activities'

  def self.parse(string)
    tree = Parser.new.parse(string)
Severity: Major
Found in lib/pomodoro/formats/review/plugins/activities.rb and 1 other location - About 1 hr to fix
lib/pomodoro/formats/review/plugins/medications.rb on lines 10..32

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 68.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method main has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.main(today_tasks, task_list)
    if today_tasks && current_time_frame = today_tasks.current_time_frame
      colour, icon = self.heading(current_time_frame, today_tasks.active_task)
      puts icon, '---'
      self.with_active_time_frame(current_time_frame)
Severity: Minor
Found in lib/pomodoro/commands/bitbar.rb - About 1 hr to fix

    Method run has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def run
        unless File.directory?(self.config.today_path_dir)
          command "mkdir #{self.config.today_path_dir}"
        end
    
    
    Severity: Minor
    Found in lib/pomodoro/commands/generate.rb - About 1 hr to fix

      Method run has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def run
          ensure_today
      
          unless (@args & ['--confirm', '-c']).empty?
            Pomodoro::Commands::Next.new(Array.new).run
      Severity: Minor
      Found in lib/pomodoro/commands/start.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 calendar has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def calendar
            (self.data['calendar'] || Hash.new).reduce(Hash.new) do |buffer, (event_name, date)|
              if date.is_a?(Integer)
                today = Date.today
                p_date = Date.new(today.year, today.month, date)
      Severity: Minor
      Found in lib/pomodoro/config.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 with_active_time_frame has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.with_active_time_frame(current_time_frame)
          puts "#{current_time_frame.header} | color=green"
          puts "#{current_time_frame.remaining_duration}h remaining"
      
          current_time_frame.tasks.each do |task|
      Severity: Minor
      Found in lib/pomodoro/commands/bitbar.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_upcoming_events_to_scheduled_list has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def add_upcoming_events_to_scheduled_list(scheduled_task_list)
          upcoming_events = self.config.calendar.select do |event_name, date|
            ((Date.today + 1)..(Date.today + 6)).cover?(date)
          end
      
      
      Severity: Minor
      Found in lib/pomodoro/commands/generate.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 run has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def run
          ensure_today
          today_list = parse_today_list(self.config).task_list
      
          active_task = today_list.active_task
      Severity: Minor
      Found in lib/pomodoro/commands/active.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 get_period_and_date has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def get_period_and_date(default_period = :day)
              increment = self.get_date_increment
              period = (@args.first && @args.shift || default_period).to_sym
      
              if increment == 0
      Severity: Minor
      Found in lib/pomodoro/commands.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 run has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def run
          ensure_today
      
          unless (@args & ['--confirm', '-c']).empty?
            Pomodoro::Commands::Next.new(Array.new).run
      Severity: Minor
      Found in lib/pomodoro/commands/start.rb - About 1 hr to fix

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

          def run
            period, date = self.get_period_and_date(:week)
            router = Pomodoro::Router.new(self.config.data_root_path, date)
        
            if router.respond_to?(:"#{period}_plan_path")
        Severity: Minor
        Found in lib/pomodoro/commands/plan.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 format has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.format(task)
              output = [task.class::STATUS_MAPPING[task.status][0]]
              if task.start_time || task.end_time
                output << "[#{self.format_duration(task.start_time, task.end_time)}]"
              end
        Severity: Minor
        Found in lib/pomodoro/formats/today/task/formatter.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 run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def run
            @args.unshift(Date.today.year.to_s) unless @args.first&.match(/^\d{4}$/)
        
            year = @args.shift
        
        
        Severity: Minor
        Found in lib/pomodoro/commands/test.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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          def initialize(sections)
            @sections = sections
        
            section_methods = [:method_name]
            unless sections.is_a?(Array) && sections.all? { |item| section_methods.all? { |method| item.respond_to?(method) } }
        Severity: Minor
        Found in lib/pomodoro/formats/review/sections.rb and 1 other location - About 45 mins to fix
        lib/pomodoro/formats/today/task_list.rb on lines 32..42

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 40.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            def initialize(*time_frames)
              @time_frames = time_frames
        
              time_frame_methods = [:method_name]
              unless time_frames.is_a?(Array) && time_frames.all? { |item| time_frame_methods.all? { |method| item.respond_to?(method) } }
        Severity: Minor
        Found in lib/pomodoro/formats/today/task_list.rb and 1 other location - About 45 mins to fix
        lib/pomodoro/formats/review/sections.rb on lines 5..15

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 40.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

          def populate_from_scheduled_task_list(day, scheduled_task_list)
            scheduled_task_list.each do |task_group|
              next unless task_group.scheduled_date == @date
              task_group.tasks.each do |task|
                if task.time_frame
        Severity: Minor
        Found in lib/pomodoro/commands/generate.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 run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def run
            period, date = self.get_period_and_date(:day)
            router = Pomodoro::Router.new(self.config.data_root_path, date)
        
            abort t(:cannot_be_past_today) if date > Date.today
        Severity: Minor
        Found in lib/pomodoro/commands/review.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