thenickperson/tracking

View on GitHub

Showing 10 of 10 total issues

Method parse has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def parse args=ARGV
            OptionParser.new do |opts|
                # Setup
                version_path = File.expand_path('../../VERSION', File.dirname(__FILE__))
                opts.version = File.exist?(version_path) ? File.read(version_path) : ''
Severity: Minor
Found in lib/tracking/cli.rb - About 1 hr to fix

    Method split_task has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

            def split_task task
    
                # If the task fits
                if task.length <= TrackingConfig[:task_width]
                    return [task]
    Severity: Minor
    Found in lib/tracking/cli.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 display_task has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

            def display_task(task)
                split_task(task.name).each_with_index do |name_line, line_index|
                    col_1 = pad((task.start_time if line_index==0), 5)
                    col_2 = pad(name_line, @name_width)
                    col_3 = pad((task.elapsed_time if line_index==0), @elapsed_time_width)
    Severity: Minor
    Found in lib/tracking/cli.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 has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

            def get options={}
                if File.exist? @data_file
                    # Read all lines from the data file
                    lines = CSV.read(@data_file, @csv_options)
                    # Shorten lines to meet TrackingConfig[:lines], if needed
    Severity: Minor
    Found in lib/tracking/list.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 split_task has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def split_task task
    
                # If the task fits
                if task.length <= TrackingConfig[:task_width]
                    return [task]
    Severity: Minor
    Found in lib/tracking/cli.rb - About 1 hr to fix

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

              def elapsed_time format=TrackingConfig[:elapsed_format], show_seconds=TrackingConfig[:show_elapsed_seconds]
                  # Calculate the elapsed time and break it down into different units
                  seconds = ((self.current? ? Time.now : @end_time) - @start_time).floor
                  minutes = hours = days = 0
                  if seconds >= 60
      Severity: Minor
      Found in lib/tracking/task.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

      Avoid too many return statements within this method.
      Open

                          return
      Severity: Major
      Found in lib/tracking/cli.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                            return
        Severity: Major
        Found in lib/tracking/cli.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                              return ' '*(difference/2).floor + string + ' '*(difference/2).ceil
          Severity: Major
          Found in lib/tracking/cli.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                                return
            Severity: Major
            Found in lib/tracking/cli.rb - About 30 mins to fix
              Severity
              Category
              Status
              Source
              Language