TracksApp/tracks

View on GitHub
doc/tracks_cli_client.rb

Summary

Maintainability
A
0 mins
Test Coverage

Complex method ConsoleOptions#initialize (41.9)
Open

  def initialize
    @options = {}

    @parser = OptionParser.new do |cmd|
      cmd.banner = "Ruby Gtd CLI - takes todos input from STDIN"
Severity: Minor
Found in doc/tracks_cli_client.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

PostLineAsTodo#post has approx 7 statements
Open

  def post(lines)
Severity: Minor
Found in doc/tracks_cli_client.rb by reek

A method with Too Many Statements is any method that has a large number of lines.

Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

So the following method would score +6 in Reek's statement-counting algorithm:

def parse(arg, argv, &error)
  if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
    return nil, block, nil                                         # +1
  end
  opt = (val = parse_arg(val, &error))[1]                          # +2
  val = conv_arg(*val)                                             # +3
  if opt and !arg
    argv.shift                                                     # +4
  else
    val[0] = nil                                                   # +5
  end
  val                                                              # +6
end

(You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

ConsoleOptions#run has approx 10 statements
Open

  def run(args)
Severity: Minor
Found in doc/tracks_cli_client.rb by reek

A method with Too Many Statements is any method that has a large number of lines.

Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

So the following method would score +6 in Reek's statement-counting algorithm:

def parse(arg, argv, &error)
  if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
    return nil, block, nil                                         # +1
  end
  opt = (val = parse_arg(val, &error))[1]                          # +2
  val = conv_arg(*val)                                             # +3
  if opt and !arg
    argv.shift                                                     # +4
  else
    val[0] = nil                                                   # +5
  end
  val                                                              # +6
end

(You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

ConsoleOptions#initialize contains iterators nested 2 deep
Open

      cmd.on('-p [N]', Integer, "project id to set for new todo") do |v|
        @options[:project_id] = v
      end

      cmd.on('-c [N]', Integer, 'context id to set') do |v|
Severity: Minor
Found in doc/tracks_cli_client.rb by reek

A Nested Iterator occurs when a block contains another block.

Example

Given

class Duck
  class << self
    def duck_names
      %i!tick trick track!.each do |surname|
        %i!duck!.each do |last_name|
          puts "full name is #{surname} #{last_name}"
        end
      end
    end
  end
end

Reek would report the following warning:

test.rb -- 1 warning:
  [5]:Duck#duck_names contains iterators nested 2 deep (NestedIterators)

Complex method PostLineAsTodo#post (23.8)
Open

  def post(lines)
    lines.each_line do |l|
      l.chomp!
      next if l.strip.empty?

Severity: Minor
Found in doc/tracks_cli_client.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

InvalidParser has no descriptive comment
Open

class InvalidParser < StandardError; end
Severity: Minor
Found in doc/tracks_cli_client.rb by reek

Classes and modules are the units of reuse and release. It is therefore considered good practice to annotate every class and module with a brief comment outlining its responsibilities.

Example

Given

class Dummy
  # Do things...
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [1]:Dummy has no descriptive comment (IrresponsibleModule)

Fixing this is simple - just an explaining comment:

# The Dummy class is responsible for ...
class Dummy
  # Do things...
end

PostLineAsTodo has no descriptive comment
Open

class PostLineAsTodo
Severity: Minor
Found in doc/tracks_cli_client.rb by reek

Classes and modules are the units of reuse and release. It is therefore considered good practice to annotate every class and module with a brief comment outlining its responsibilities.

Example

Given

class Dummy
  # Do things...
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [1]:Dummy has no descriptive comment (IrresponsibleModule)

Fixing this is simple - just an explaining comment:

# The Dummy class is responsible for ...
class Dummy
  # Do things...
end

ConsoleOptions#initialize calls 'Time.now' 2 times
Open

        @options[:show_from] = Time.now.to_i + 24 * 3600 * 7 * (v || 1)
      end

      cmd.on('-m [N]', Integer, 'Postpone task for N months') do |v|
        @options[:show_from] = Time.now.to_i + 24 * 3600 * 7 * 4 * (v || 1)
Severity: Minor
Found in doc/tracks_cli_client.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

PostLineAsTodo#initialize calls 'options[:project_id]' 2 times
Open

    @project_id = options[:project_id] ? options[:project_id].to_i : 1
Severity: Minor
Found in doc/tracks_cli_client.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

PostLineAsTodo#initialize calls 'options[:context_id]' 2 times
Open

    @context_id = options[:context_id] ? options[:context_id].to_i : 1
Severity: Minor
Found in doc/tracks_cli_client.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

ConsoleOptions has no descriptive comment
Open

class ConsoleOptions
Severity: Minor
Found in doc/tracks_cli_client.rb by reek

Classes and modules are the units of reuse and release. It is therefore considered good practice to annotate every class and module with a brief comment outlining its responsibilities.

Example

Given

class Dummy
  # Do things...
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [1]:Dummy has no descriptive comment (IrresponsibleModule)

Fixing this is simple - just an explaining comment:

# The Dummy class is responsible for ...
class Dummy
  # Do things...
end

ConsoleOptions#initialize calls '24 * 3600 * 7' 2 times
Open

        @options[:show_from] = Time.now.to_i + 24 * 3600 * 7 * (v || 1)
      end

      cmd.on('-m [N]', Integer, 'Postpone task for N months') do |v|
        @options[:show_from] = Time.now.to_i + 24 * 3600 * 7 * 4 * (v || 1)
Severity: Minor
Found in doc/tracks_cli_client.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

ConsoleOptions#initialize calls '24 * 3600' 2 times
Open

        @options[:show_from] = Time.now.to_i + 24 * 3600 * 7 * (v || 1)
      end

      cmd.on('-m [N]', Integer, 'Postpone task for N months') do |v|
        @options[:show_from] = Time.now.to_i + 24 * 3600 * 7 * 4 * (v || 1)
Severity: Minor
Found in doc/tracks_cli_client.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

Error has no descriptive comment
Open

class Error < StandardError; end
Severity: Minor
Found in doc/tracks_cli_client.rb by reek

Classes and modules are the units of reuse and release. It is therefore considered good practice to annotate every class and module with a brief comment outlining its responsibilities.

Example

Given

class Dummy
  # Do things...
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [1]:Dummy has no descriptive comment (IrresponsibleModule)

Fixing this is simple - just an explaining comment:

# The Dummy class is responsible for ...
class Dummy
  # Do things...
end

ConsoleOptions#run calls 'exit 1' 3 times
Open

      exit 1
    end

    PostLineAsTodo.new(@options).post(lines)
    exit 0
Severity: Minor
Found in doc/tracks_cli_client.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

ConsoleOptions#initialize calls 'Time.now.to_i' 2 times
Open

        @options[:show_from] = Time.now.to_i + 24 * 3600 * 7 * (v || 1)
      end

      cmd.on('-m [N]', Integer, 'Postpone task for N months') do |v|
        @options[:show_from] = Time.now.to_i + 24 * 3600 * 7 * 4 * (v || 1)
Severity: Minor
Found in doc/tracks_cli_client.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

PostLineAsTodo#post calls 'resp.code' 2 times
Open

      if resp.code == '302' || resp.code == '201'
Severity: Minor
Found in doc/tracks_cli_client.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

ConsoleOptions#initialize has the variable name 'v'
Open

      cmd.on('-p [N]', Integer, "project id to set for new todo") do |v|
        @options[:project_id] = v
      end

      cmd.on('-c [N]', Integer, 'context id to set') do |v|
Severity: Minor
Found in doc/tracks_cli_client.rb by reek

An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

PostLineAsTodo#post has the variable name 'l'
Open

    lines.each_line do |l|
Severity: Minor
Found in doc/tracks_cli_client.rb by reek

An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

Prefer $PROGRAM_NAME over $0.
Open

if $0 == __FILE__
Severity: Minor
Found in doc/tracks_cli_client.rb by rubocop

Missing magic comment # frozen_string_literal: true.
Open

#!/usr/bin/env ruby
Severity: Minor
Found in doc/tracks_cli_client.rb by rubocop

This cop is designed to help upgrade to Ruby 3.0. It will add the comment # frozen_string_literal: true to the top of files to enable frozen string literals. Frozen string literals may be default in Ruby 3.0. The comment will be added below a shebang and encoding comment. The frozen string literal comment is only valid in Ruby 2.3+.

Example: EnforcedStyle: when_needed (default)

# The `when_needed` style will add the frozen string literal comment
# to files only when the `TargetRubyVersion` is set to 2.3+.
# bad
module Foo
  # ...
end

# good
# frozen_string_literal: true

module Foo
  # ...
end

Example: EnforcedStyle: always

# The `always` style will always add the frozen string literal comment
# to a file, regardless of the Ruby version or if `freeze` or `<<` are
# called on a string literal.
# bad
module Bar
  # ...
end

# good
# frozen_string_literal: true

module Bar
  # ...
end

Example: EnforcedStyle: never

# The `never` will enforce that the frozen string literal comment does
# not exist in a file.
# bad
# frozen_string_literal: true

module Baz
  # ...
end

# good
module Baz
  # ...
end

Script file tracks_cli_client.rb doesn't have execute permission.
Open

#!/usr/bin/env ruby
Severity: Minor
Found in doc/tracks_cli_client.rb by rubocop

Line is too long. [121/120]
Open

# CLI ruby client for Tracks: rails application for GTD methodology (First author: Vitalie Lazu <vitalie.lazu@gmail.com>)
Severity: Minor
Found in doc/tracks_cli_client.rb by rubocop

Trailing whitespace detected.
Open

        context_id:  @context_id, 
Severity: Minor
Found in doc/tracks_cli_client.rb by rubocop

Extra empty line detected at class body end.
Open


end
Severity: Minor
Found in doc/tracks_cli_client.rb by rubocop

This cops checks if empty lines around the bodies of classes match the configuration.

Example: EnforcedStyle: empty_lines

# good

class Foo

  def bar
    # ...
  end

end

Example: EnforcedStyle: emptylinesexcept_namespace

# good

class Foo
  class Bar

    # ...

  end
end

Example: EnforcedStyle: emptylinesspecial

# good
class Foo

  def bar; end

end

Example: EnforcedStyle: noemptylines (default)

# good

class Foo
  def bar
    # ...
  end
end

Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.
Open

        show_from:   @options[:show_from])
Severity: Minor
Found in doc/tracks_cli_client.rb by rubocop

This cop checks that the closing brace in a method call is either on the same line as the last method argument, or a new line.

When using the symmetrical (default) style:

If a method call's opening brace is on the same line as the first argument of the call, then the closing brace should be on the same line as the last argument of the call.

If an method call's opening brace is on the line above the first argument of the call, then the closing brace should be on the line below the last argument of the call.

When using the new_line style:

The closing brace of a multi-line method call must be on the line after the last argument of the call.

When using the same_line style:

The closing brace of a multi-line method call must be on the same line as the last argument of the call.

Example:

# symmetrical: bad
  # new_line: good
  # same_line: bad
  foo(a,
    b
  )

  # symmetrical: bad
  # new_line: bad
  # same_line: good
  foo(
    a,
    b)

  # symmetrical: good
  # new_line: bad
  # same_line: good
  foo(a,
    b)

  # symmetrical: good
  # new_line: good
  # same_line: bad
  foo(
    a,
    b
  )

Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
Open

if $0 == __FILE__
Severity: Minor
Found in doc/tracks_cli_client.rb by rubocop

Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop.

Example:

# bad
if condition
  do_stuff(bar)
end

unless qux.empty?
  Foo.do_something
end

# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?

Extra empty line detected at class body beginning.
Open


  def initialize(options)
Severity: Minor
Found in doc/tracks_cli_client.rb by rubocop

This cops checks if empty lines around the bodies of classes match the configuration.

Example: EnforcedStyle: empty_lines

# good

class Foo

  def bar
    # ...
  end

end

Example: EnforcedStyle: emptylinesexcept_namespace

# good

class Foo
  class Bar

    # ...

  end
end

Example: EnforcedStyle: emptylinesspecial

# good
class Foo

  def bar; end

end

Example: EnforcedStyle: noemptylines (default)

# good

class Foo
  def bar
    # ...
  end
end

Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.
Open

      password: ENV['GTD_PASSWORD'])
Severity: Minor
Found in doc/tracks_cli_client.rb by rubocop

This cop checks that the closing brace in a method call is either on the same line as the last method argument, or a new line.

When using the symmetrical (default) style:

If a method call's opening brace is on the same line as the first argument of the call, then the closing brace should be on the same line as the last argument of the call.

If an method call's opening brace is on the line above the first argument of the call, then the closing brace should be on the line below the last argument of the call.

When using the new_line style:

The closing brace of a multi-line method call must be on the line after the last argument of the call.

When using the same_line style:

The closing brace of a multi-line method call must be on the same line as the last argument of the call.

Example:

# symmetrical: bad
  # new_line: good
  # same_line: bad
  foo(a,
    b
  )

  # symmetrical: bad
  # new_line: bad
  # same_line: good
  foo(
    a,
    b)

  # symmetrical: good
  # new_line: bad
  # same_line: good
  foo(a,
    b)

  # symmetrical: good
  # new_line: good
  # same_line: bad
  foo(
    a,
    b
  )

There are no issues that match your filters.

Category
Status