ringcentral-ruby/ringcentral-avatars-ruby

View on GitHub

Showing 16 of 16 total issues

Method initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def initialize(client, opts = {})
        @client = client
        if !opts.key?(:initials_opts) && opts.key?(:avatar_opts)
          opts[:initials_opts] = opts[:avatar_opts]
        end
Severity: Minor
Found in lib/ringcentral-avatars/creator.rb - About 35 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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def initialize(opts = {})
        @avatarly_opts =  inflate_avatarly_opts opts[:initials_opts]
        @identicon_opts = inflate_identicon_opts opts[:identicon_opts]
        @style = opts.key?(:style) ? opts[:style] : DEFAULT_STYLE
        @png_metadata = opts.key?(:png_metadata) ? opts[:png_metadata] : {}
Severity: Minor
Found in lib/ringcentral-avatars/creator.rb - About 25 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

Final newline missing.
Open

gemspec
Severity: Minor
Found in Gemfile by rubocop

Avoid the use of Perl-style backrefs.
Open

version = $1
Severity: Minor
Found in ringcentral-avatars.gemspec by rubocop

This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.

Example:

# bad
puts $1

# good
puts Regexp.last_match(1)

Missing top-level class documentation comment.
Open

    class Creator
Severity: Minor
Found in lib/ringcentral-avatars/creator.rb by rubocop

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

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

        if types.empty?
Severity: Minor
Found in lib/ringcentral-avatars/creator.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?

Avoid multi-line ternary operators, use if or unless instead.
Open

        blob = style == 'initials' \
          ? Avatarly.generate_avatar(text, @avatarly_opts) \
          : RubyIdenticon.create(text, @identicon_opts)
Severity: Minor
Found in lib/ringcentral-avatars/creator.rb by rubocop

This cop checks for multi-line ternary op expressions.

Example:

# bad
a = cond ?
  b : c
a = cond ? b :
    c
a = cond ?
    b :
    c

# good
a = cond ? b : c
a =
  if cond
    b
  else
    c
  end

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

        if !opts.key?(:initials_opts) && opts.key?(:avatar_opts)
Severity: Minor
Found in lib/ringcentral-avatars/creator.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?

Line is too long. [121/120]
Open

  # puts 'yard doc generation disabled until JRuby build native extensions for redcarpet or yard removes the dependency.'
Severity: Minor
Found in Rakefile by rubocop

required_ruby_version (2.2, declared in ringcentral-avatars.gemspec) and TargetRubyVersion (2.1, declared in .rubocop.yml) should be equal.
Open

  s.required_ruby_version = '>= 2.2.2'
Severity: Minor
Found in ringcentral-avatars.gemspec by rubocop

Checks that required_ruby_version of gemspec and TargetRubyVersion of .rubocop.yml are equal. Thereby, RuboCop to perform static analysis working on the version required by gemspec.

Example:

# When `TargetRubyVersion` of .rubocop.yml is `2.3`.

# bad
Gem::Specification.new do |spec|
  spec.required_ruby_version = '>= 2.2.0'
end

# bad
Gem::Specification.new do |spec|
  spec.required_ruby_version = '>= 2.4.0'
end

# good
Gem::Specification.new do |spec|
  spec.required_ruby_version = '>= 2.3.0'
end

# good
Gem::Specification.new do |spec|
  spec.required_ruby_version = '>= 2.3'
end

# good
Gem::Specification.new do |spec|
  spec.required_ruby_version = ['>= 2.3.0', '< 2.5.0']
end

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

        if avatar?(ext) && !opts[:overwrite]
Severity: Minor
Found in lib/ringcentral-avatars/creator.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 the return of the conditional for variable assignment and comparison.
Open

        if opts.key? :png_metadata
          opts[:png_metadata] = PNG_DEFAULT_METADATA.merge(opts[:png_metadata])
        else
          opts[:png_metadata] = PNG_DEFAULT_METADATA
        end
Severity: Minor
Found in lib/ringcentral-avatars/creator.rb by rubocop

The name of this source file (ringcentral-avatars.rb) should use snake_case.
Open

require 'ringcentral-avatars/creator'
Severity: Minor
Found in lib/ringcentral-avatars.rb by rubocop

This cop makes sure that Ruby source files have snake_case names. Ruby scripts (i.e. source files with a shebang in the first line) are ignored.

Example:

# bad
lib/layoutManager.rb

anything/usingCamelCase

# good
lib/layout_manager.rb

anything/using_snake_case.rake

Missing top-level module documentation comment.
Open

  module Avatars
Severity: Minor
Found in lib/ringcentral-avatars.rb by rubocop

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

Use each_value instead of each.
Open

        @extensions.extensions_hash.each do |_ext_id, ext|
Severity: Minor
Found in lib/ringcentral-avatars/creator.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 }

Missing top-level class documentation comment.
Open

    class MultiAvatar
Severity: Minor
Found in lib/ringcentral-avatars/creator.rb by rubocop

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
Severity
Category
Status
Source
Language