mhutter/teamdrive_api

View on GitHub

Showing 37 of 37 total issues

Extra blank line detected.
Open


  def test_delete_license
Severity: Minor
Found in test/teamdrive_api/register_test.rb by rubocop

This cops checks for two or more consecutive blank lines.

Example:

# bad - It has two empty lines.
some_method
# one empty line
# two empty lines
some_method

# good
some_method
# one empty line
some_method

Use %i or %I for an array of symbols.
Open

      require_one of: [:username, :email], in_hash: query
Severity: Minor
Found in lib/teamdrive_api/register.rb by rubocop

This cop can check for array literals made up of symbols that are not using the %i() syntax.

Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

Example: EnforcedStyle: percent (default)

# good
%i[foo bar baz]

# bad
[:foo, :bar, :baz]

Example: EnforcedStyle: brackets

# good
[:foo, :bar, :baz]

# bad
%i[foo bar baz]

Add an empty line after magic comments.
Open

lib = File.expand_path('../lib', __FILE__)
Severity: Minor
Found in teamdrive_api.gemspec by rubocop

Checks for a newline after the final magic comment.

Example:

# good
# frozen_string_literal: true

# Some documentation for Person
class Person
  # Some code
end

# bad
# frozen_string_literal: true
# Some documentation for Person
class Person
  # Some code
end

%w-literals should be delimited by [ and ].
Open

        v = '$' + v if %w(true false).include?(v)
Severity: Minor
Found in lib/teamdrive_api/base.rb by rubocop

This cop enforces the consistent usage of %-literal delimiters.

Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

Example:

# Style/PercentLiteralDelimiters:
#   PreferredDelimiters:
#     default: '[]'
#     '%i':    '()'

# good
%w[alpha beta] + %i(gamma delta)

# bad
%W(alpha #{beta})

# bad
%I(alpha beta)

Use empty lines between method definitions.
Open

  def test_delete_license
Severity: Minor
Found in test/teamdrive_api/register_test.rb by rubocop

This cop checks whether method definitions are separated by one empty line.

NumberOfEmptyLines can be and integer (e.g. 1 by default) or an array (e.g. [1, 2]) to specificy a minimum and a maximum of empty lines.

AllowAdjacentOneLineDefs can be used to configure is adjacent one line methods definitions are an offense

Example:

# bad
def a
end
def b
end

Example:

# good
def a
end

def b
end

Use each_key instead of keys.each.
Open

    keys.each do |key|
Severity: Minor
Found in lib/teamdrive_api/core_ext/hash.rb by rubocop

This cop checks for uses of each_key and each_value Hash methods.

Note: If you have an array of two-element arrays, you can put parentheses around the block arguments to indicate that you're not working with a hash, and suppress RuboCop offenses.

Example:

# bad
hash.keys.each { |k| p k }
hash.values.each { |v| p v }
hash.each { |k, _v| p k }
hash.each { |_k, v| p v }

# good
hash.each_key { |k| p k }
hash.each_value { |v| p v }

Use alias instead of alias_method in a class body.
Open

    alias_method :create_account, :register_user
Severity: Minor
Found in lib/teamdrive_api/register.rb by rubocop

This cop enforces the use of either #alias or #alias_method depending on configuration. It also flags uses of alias :symbol rather than alias bareword.

Example: EnforcedStyle: prefer_alias (default)

# bad
alias_method :bar, :foo
alias :bar :foo

# good
alias bar foo

Example: EnforcedStyle: preferaliasmethod

# bad
alias :bar :foo
alias bar foo

# good
alias_method :bar, :foo

Use %i or %I for an array of symbols.
Open

      require_all of: [:username, :useremail, :password], in_hash: opts
Severity: Minor
Found in lib/teamdrive_api/register.rb by rubocop

This cop can check for array literals made up of symbols that are not using the %i() syntax.

Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

Example: EnforcedStyle: percent (default)

# good
%i[foo bar baz]

# bad
[:foo, :bar, :baz]

Example: EnforcedStyle: brackets

# good
[:foo, :bar, :baz]

# bad
%i[foo bar baz]

Freeze mutable objects assigned to constants.
Open

  BEFORE = [
    {
      'foo' => 'bar',
      'num' => {
        'first' => 1,

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

Symbol with a boolean name - you probably meant to use false.
Open

      assert_equal expected, @r.payload_for(:my_command, false: false)
Severity: Minor
Found in test/teamdrive_api/base_test.rb by rubocop

This cop checks for :true and :false symbols. In most cases it would be a typo.

Example:

# bad
:true

# good
true

Example:

# bad
:false

# good
false

Symbol with a boolean name - you probably meant to use true.
Open

      assert_equal expected, @r.payload_for(:my_command, true: true)
Severity: Minor
Found in test/teamdrive_api/base_test.rb by rubocop

This cop checks for :true and :false symbols. In most cases it would be a typo.

Example:

# bad
:true

# good
true

Example:

# bad
:false

# good
false

Align .to_return with stub_request(:post, URL) on line 211.
Open

    .to_return(status: 200, body: BODY_OK, headers: {})
Severity: Minor
Found in test/teamdrive_api/register_test.rb by rubocop

This cop checks the indentation of the method name part in method calls that span more than one line.

Example: EnforcedStyle: aligned

# bad
while myvariable
.b
  # do something
end

# good
while myvariable
      .b
  # do something
end

# good
Thing.a
     .b
     .c

Example: EnforcedStyle: indented

# good
while myvariable
  .b

  # do something
end

Example: EnforcedStyle: indentedrelativeto_receiver

# good
while myvariable
        .a
        .b

  # do something
end

# good
myvariable = Thing
               .a
               .b
               .c

Always use raise to signal exceptions.
Open

      fail TeamdriveApi::Error.new response[:exception][:primarycode],
Severity: Minor
Found in lib/teamdrive_api/base.rb by rubocop

This cop checks for uses of fail and raise.

Example: EnforcedStyle: only_raise (default)

# The `only_raise` style enforces the sole use of `raise`.
# bad
begin
  fail
rescue Exception
  # handle it
end

def watch_out
  fail
rescue Exception
  # handle it
end

Kernel.fail

# good
begin
  raise
rescue Exception
  # handle it
end

def watch_out
  raise
rescue Exception
  # handle it
end

Kernel.raise

Example: EnforcedStyle: only_fail

# The `only_fail` style enforces the sole use of `fail`.
# bad
begin
  raise
rescue Exception
  # handle it
end

def watch_out
  raise
rescue Exception
  # handle it
end

Kernel.raise

# good
begin
  fail
rescue Exception
  # handle it
end

def watch_out
  fail
rescue Exception
  # handle it
end

Kernel.fail

Example: EnforcedStyle: semantic

# The `semantic` style enforces the use of `fail` to signal an
# exception, then will use `raise` to trigger an offense after
# it has been rescued.
# bad
begin
  raise
rescue Exception
  # handle it
end

def watch_out
  # Error thrown
rescue Exception
  fail
end

Kernel.fail
Kernel.raise

# good
begin
  fail
rescue Exception
  # handle it
end

def watch_out
  fail
rescue Exception
  raise 'Preferably with descriptive message'
end

explicit_receiver.fail
explicit_receiver.raise

Freeze mutable objects assigned to constants.
Open

  EXPECTED = [
    {
      foo: 'bar',
      num: {
        first: 1,

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

Freeze mutable objects assigned to constants.
Open

  EXPECTED = {
    foo: 'bar',
    num: {
      first: 1,
      second: 2

This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

Example:

# bad
CONST = [1, 2, 3]

# good
CONST = [1, 2, 3].freeze

Unnecessary utf-8 encoding comment.
Open

# coding: utf-8
Severity: Minor
Found in teamdrive_api.gemspec by rubocop

Use %i or %I for an array of symbols.
Open

      require_all of: [:username, :productname, :type, :featurevalue],
Severity: Minor
Found in lib/teamdrive_api/register.rb by rubocop

This cop can check for array literals made up of symbols that are not using the %i() syntax.

Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

Example: EnforcedStyle: percent (default)

# good
%i[foo bar baz]

# bad
[:foo, :bar, :baz]

Example: EnforcedStyle: brackets

# good
[:foo, :bar, :baz]

# bad
%i[foo bar baz]
Severity
Category
Status
Source
Language