grokify/ringcentral-sdk-ruby

View on GitHub

Showing 129 of 129 total issues

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

        unless alive?

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?

Prefer annotated tokens (like %<foo>s</foo>) over unannotated tokens (like %s).
Open

        ua = "ringcentral-sdk-ruby/#{RingCentralSdk::VERSION} %s/%s %s" % [
Severity: Minor
Found in lib/ringcentral_sdk/rest/client.rb by rubocop

Use a consistent style for named format string tokens.

Note: unannotated style cop only works for strings which are passed as arguments to those methods: sprintf, format, %. The reason is that unannotated format is very similar to encoded URLs or Date/Time formatting strings.

Example: EnforcedStyle: annotated (default)

# bad
format('%{greeting}', greeting: 'Hello')
format('%s', 'Hello')

# good
format('%<greeting>s', greeting: 'Hello')</greeting>

Example: EnforcedStyle: template

# bad
format('%<greeting>s', greeting: 'Hello')
format('%s', 'Hello')

# good
format('%{greeting}', greeting: 'Hello')</greeting>

Example: EnforcedStyle: unannotated

# bad
format('%<greeting>s', greeting: 'Hello')
format('%{greeting}', 'Hello')

# good
format('%s', 'Hello')</greeting>

Use url.index('/').zero? instead of url.index('/') == 0.
Open

        if url.index('/') == 0
Severity: Minor
Found in lib/ringcentral_sdk/rest/client.rb by rubocop

This cop checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. The cop can also be configured to do the reverse.

The cop disregards #nonzero? as it its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

The cop ignores comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Interger polymorphic.

Example: EnforcedStyle: predicate (default)

# bad

foo == 0
0 > foo
bar.baz > 0

# good

foo.zero?
foo.negative?
bar.baz.positive?

Example: EnforcedStyle: comparison

# bad

foo.zero?
foo.negative?
bar.baz.positive?

# good

foo == 0
0 > foo
bar.baz > 0

Prefer Date or Time over DateTime.
Open

        last_updated_dt = DateTime.iso8601(last_updated_s)

This cop checks for uses of DateTime that should be replaced by Date or Time.

Example:

# bad - uses `DateTime` for current time
DateTime.now

# good - uses `Time` for current time
Time.now

# bad - uses `DateTime` for modern date
DateTime.iso8601('2016-06-29')

# good - uses `Date` for modern date
Date.iso8601('2016-06-29')

# good - uses `DateTime` with start argument for historical date
DateTime.iso8601('1751-04-23', Date::ENGLAND)

Use the return of the conditional for variable assignment and comparison.
Open

        if !@retry_options.nil? && @retry_options.to_s =~ /^\s*{/
          @retry_options = MultiJson.decode @retry_options.to_s, symbolize_keys: true
        else
          @retry_options = {}
        end

Unused method argument - add_token. If it's necessary, use _ or _add_token as an argument name to indicate that it won't be used.
Open

      def create_url(url, add_server = false, add_method = nil, add_token = false)
Severity: Minor
Found in lib/ringcentral_sdk/rest/client.rb by rubocop

This cop checks for unused method arguments.

Example:

# bad

def some_method(used, unused, _unused_but_allowed)
  puts used
end

Example:

# good

def some_method(used, _unused, _unused_but_allowed)
  puts used
end

Useless assignment to variable - req.
Open

          res = @http.put { |req| req = inflate_request(req, request_sdk) }
Severity: Minor
Found in lib/ringcentral_sdk/rest/client.rb by rubocop

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

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

        if url.index(URL_PREFIX).nil? && !has_http
Severity: Minor
Found in lib/ringcentral_sdk/rest/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?

Missing top-level class documentation comment.
Open

      class SMS < RingCentralSdk::REST::Request::Multipart

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

Example:

# bad
class Person
  # ...
end

# good
# Description/Explanation of Person class
class Person
  # ...
end

Space inside { missing.
Open

              @mime_part_params.merge(opts).merge({is_attachment: true})

Checks that braces used for hash literals have or don't have surrounding space depending on configuration.

Example: EnforcedStyle: space

# The `space` style enforces that hash literals have
# surrounding space.

# bad
h = {a: 1, b: 2}

# good
h = { a: 1, b: 2 }

Example: EnforcedStyle: no_space

# The `no_space` style enforces that hash literals have
# no surrounding space.

# bad
h = { a: 1, b: 2 }

# good
h = {a: 1, b: 2}

Example: EnforcedStyle: compact

# The `compact` style normally requires a space inside
# hash braces, with the exception that successive left
# braces or right braces are collapsed together in nested hashes.

# bad
h = { a: { b: 2 } }

# good
h = { a: { b: 2 }}

Do not prefix writer method names with set_.
Open

        def set_url(url)

This cop makes sure that accessor methods are named properly.

Example:

# bad
def set_attribute(value)
end

# good
def attribute=(value)
end

# bad
def get_attribute
end

# good
def attribute
end

Trailing whitespace detected.
Open

        

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

        if !ct.nil? && !ct.to_s.strip.empty?
Severity: Minor
Found in lib/ringcentral_sdk/rest/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?

Use a guard clause instead of wrapping the code inside a conditional expression.
Open

        if !defined?(@token) && !@token.nil? && @token.is_a?(String) && @token =~ /^\s*{/

Use a guard clause instead of wrapping the code inside a conditional expression

Example:

# bad
def test
  if something
    work
  end
end

# good
def test
  return unless something
  work
end

# also good
def test
  work if something
end

# bad
if something
  raise 'exception'
else
  ok
end

# good
raise 'exception' if something
ok

Do not prefix writer method names with set_.
Open

      def set_subscription(data)

This cop makes sure that accessor methods are named properly.

Example:

# bad
def set_attribute(value)
end

# good
def attribute=(value)
end

# bad
def get_attribute
end

# good
def attribute
end

Use the lambda method for multiline lambdas.
Open

          presence: ->(envelope) {

This cop (by default) checks for uses of the lambda literal syntax for single line lambdas, and the method call syntax for multiline lambdas. It is configurable to enforce one of the styles for both single line and multiline lambdas as well.

Example: EnforcedStyle: linecountdependent (default)

# bad
f = lambda { |x| x }
f = ->(x) do
      x
    end

# good
f = ->(x) { x }
f = lambda do |x|
      x
    end

Example: EnforcedStyle: lambda

# bad
f = ->(x) { x }
f = ->(x) do
      x
    end

# good
f = lambda { |x| x }
f = lambda do |x|
      x
    end

Example: EnforcedStyle: literal

# bad
f = lambda { |x| x }
f = lambda do |x|
      x
    end

# good
f = ->(x) { x }
f = ->(x) do
      x
    end

Space missing after comma.
Open

        opts.each do |k,v|

Checks for comma (,) not followed by some kind of space.

Example:

# bad
[1,2]
{ foo:bar,}

# good
[1, 2]
{ foo:bar, }

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

        if token.is_a? Hash
Severity: Minor
Found in lib/ringcentral_sdk/rest/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?

Prefer Date or Time over DateTime.
Open

          rec_last_modified_time_dt = DateTime.iso8601(rec_last_modified_time)

This cop checks for uses of DateTime that should be replaced by Date or Time.

Example:

# bad - uses `DateTime` for current time
DateTime.now

# good - uses `Time` for current time
Time.now

# bad - uses `DateTime` for modern date
DateTime.iso8601('2016-06-29')

# good - uses `Date` for modern date
Date.iso8601('2016-06-29')

# good - uses `DateTime` with start argument for historical date
DateTime.iso8601('1751-04-23', Date::ENGLAND)

Avoid using rescue in its modifier form.
Open

          (RUBY_ENGINE rescue nil || 'ruby'),
Severity: Minor
Found in lib/ringcentral_sdk/rest/client.rb by rubocop

This cop checks for uses of rescue in its modifier form.

Example:

# bad
some_method rescue handle_error

# good
begin
  some_method
rescue
  handle_error
end
Severity
Category
Status
Source
Language