voxable-labs/hg

View on GitHub
lib/chatbase_api_client.rb

Summary

Maintainability
A
0 mins
Test Coverage

Method has too many lines. [17/10] (https://github.com/voxable-labs/voxable-style-guide#short-methods)
Open

  def serialize_bot_message(message, response)
    message = message.to_json if message.is_a?(Hash)
    parsed_response = JSON.parse(response)
    message_body = {
      request_body: {
Severity: Minor
Found in lib/chatbase_api_client.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [14/10] (https://github.com/voxable-labs/voxable-style-guide#short-methods)
Open

  def serialize_user_message(message)
    message_received = {
      sender: message.sender['id'],
      recipient: message.recipient['id'],
      timestamp: message.messaging['timestamp'],
Severity: Minor
Found in lib/chatbase_api_client.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Use parentheses for method calls with arguments. (https://github.com/voxable-labs/voxable-style-guide#method-invocation-parens)
Open

    logger.error e
Severity: Minor
Found in lib/chatbase_api_client.rb by rubocop

This cop checks presence of parentheses in method calls containing parameters. By default, macro methods are ignored. Additional methods can be added to the IgnoredMethods list.

Example:

# bad
array.delete e

# good
array.delete(e)

# good
# Operators don't need parens
foo == bar

# good
# Setter methods don't need parens
foo.bar = baz

# okay with `puts` listed in `IgnoredMethods`
puts 'test'

# IgnoreMacros: true (default)

# good
class Foo
  bar :baz
end

# IgnoreMacros: false

# bad
class Foo
  bar :baz
end

Redundant begin block detected. (https://github.com/voxable-labs/voxable-style-guide#begin-implicit)
Open

    begin
Severity: Minor
Found in lib/chatbase_api_client.rb by rubocop

This cop checks for redundant begin blocks.

Currently it checks for code like this:

Example:

def redundant
  begin
    ala
    bala
  rescue StandardError => e
    something
  end
end

def preferred
  ala
  bala
rescue StandardError => e
  something
end

Prefer keyword arguments to options hashes.
Open

  def initialize(params = {})
Severity: Minor
Found in lib/chatbase_api_client.rb by rubocop

This cop checks for options hashes and discourages them if the current Ruby version supports keyword arguments.

Example:

# bad
def fry(options = {})
  temperature = options.fetch(:temperature, 300)
  # ...
end


# good
def fry(temperature: 300)
  # ...
end

= is not aligned with the preceding assignment.
Open

    message_body = {
Severity: Minor
Found in lib/chatbase_api_client.rb by rubocop

This cop checks for extra/unnecessary whitespace.

Example:

# good if AllowForAlignment is true
name      = "RuboCop"
# Some comment and an empty line

website  += "/bbatsov/rubocop" unless cond
puts        "rubocop"          if     debug

# bad for any configuration
set_app("RuboCop")
website  = "https://github.com/bbatsov/rubocop"

= is not aligned with the preceding assignment.
Open

    parsed_response = JSON.parse(response)
Severity: Minor
Found in lib/chatbase_api_client.rb by rubocop

This cop checks for extra/unnecessary whitespace.

Example:

# good if AllowForAlignment is true
name      = "RuboCop"
# Some comment and an empty line

website  += "/bbatsov/rubocop" unless cond
puts        "rubocop"          if     debug

# bad for any configuration
set_app("RuboCop")
website  = "https://github.com/bbatsov/rubocop"

Space missing to the left of {.
Open

    catch_errors{
Severity: Minor
Found in lib/chatbase_api_client.rb by rubocop

Checks that block braces have or don't have a space before the opening brace depending on configuration.

Example:

# bad
foo.map{ |a|
  a.bar.to_s
}

# good
foo.map { |a|
  a.bar.to_s
}

Use parentheses for method calls with arguments. (https://github.com/voxable-labs/voxable-style-guide#method-invocation-parens)
Open

    logger.error 'error with Chatbase API request:'
Severity: Minor
Found in lib/chatbase_api_client.rb by rubocop

This cop checks presence of parentheses in method calls containing parameters. By default, macro methods are ignored. Additional methods can be added to the IgnoredMethods list.

Example:

# bad
array.delete e

# good
array.delete(e)

# good
# Operators don't need parens
foo == bar

# good
# Setter methods don't need parens
foo.bar = baz

# okay with `puts` listed in `IgnoredMethods`
puts 'test'

# IgnoreMacros: true (default)

# good
class Foo
  bar :baz
end

# IgnoreMacros: false

# bad
class Foo
  bar :baz
end

Line is too long. [118/80] (https://github.com/voxable-labs/voxable-style-guide#80-character-limits)
Open

      self.class.post("#{BASE_PATH}/message_received?api_key=#{ENV['CHATBASE_API_KEY']}", json_body(message_received))
Severity: Minor
Found in lib/chatbase_api_client.rb by rubocop

Use parentheses for method calls with arguments. (https://github.com/voxable-labs/voxable-style-guide#method-invocation-parens)
Open

    logger.error e.backtrace.join("\n")
Severity: Minor
Found in lib/chatbase_api_client.rb by rubocop

This cop checks presence of parentheses in method calls containing parameters. By default, macro methods are ignored. Additional methods can be added to the IgnoredMethods list.

Example:

# bad
array.delete e

# good
array.delete(e)

# good
# Operators don't need parens
foo == bar

# good
# Setter methods don't need parens
foo.bar = baz

# okay with `puts` listed in `IgnoredMethods`
puts 'test'

# IgnoreMacros: true (default)

# good
class Foo
  bar :baz
end

# IgnoreMacros: false

# bad
class Foo
  bar :baz
end

= is not aligned with the preceding assignment.
Open

    @text = text
Severity: Minor
Found in lib/chatbase_api_client.rb by rubocop

This cop checks for extra/unnecessary whitespace.

Example:

# good if AllowForAlignment is true
name      = "RuboCop"
# Some comment and an empty line

website  += "/bbatsov/rubocop" unless cond
puts        "rubocop"          if     debug

# bad for any configuration
set_app("RuboCop")
website  = "https://github.com/bbatsov/rubocop"

Space missing to the left of {.
Open

    catch_errors{
Severity: Minor
Found in lib/chatbase_api_client.rb by rubocop

Checks that block braces have or don't have a space before the opening brace depending on configuration.

Example:

# bad
foo.map{ |a|
  a.bar.to_s
}

# good
foo.map { |a|
  a.bar.to_s
}

Useless assignment to variable - message_body. (https://github.com/voxable-labs/voxable-style-guide#underscore-unused-vars)
Open

    message_body = {
Severity: Minor
Found in lib/chatbase_api_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

Line is too long. [110/80] (https://github.com/voxable-labs/voxable-style-guide#80-character-limits)
Open

      self.class.post("#{BASE_PATH}/send_message?api_key=#{ENV['CHATBASE_API_KEY']}", json_body(message_body))
Severity: Minor
Found in lib/chatbase_api_client.rb by rubocop

Prefer symbols instead of strings as hash keys. (https://github.com/voxable-labs/voxable-style-guide#symbols-as-keys)
Open

      headers: { 'Content-Type' => 'application/json' }
Severity: Minor
Found in lib/chatbase_api_client.rb by rubocop

This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

Example:

# bad
{ 'one' => 1, 'two' => 2, 'three' => 3 }

# good
{ one: 1, two: 2, three: 3 }

= is not aligned with the following assignment.
Open

    @intent = intent
Severity: Minor
Found in lib/chatbase_api_client.rb by rubocop

This cop checks for extra/unnecessary whitespace.

Example:

# good if AllowForAlignment is true
name      = "RuboCop"
# Some comment and an empty line

website  += "/bbatsov/rubocop" unless cond
puts        "rubocop"          if     debug

# bad for any configuration
set_app("RuboCop")
website  = "https://github.com/bbatsov/rubocop"

Useless assignment to variable - message_received. (https://github.com/voxable-labs/voxable-style-guide#underscore-unused-vars)
Open

    message_received = {
Severity: Minor
Found in lib/chatbase_api_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

Freeze mutable objects assigned to constants.
Open

  BASE_PATH = 'https://chatbase.com/api/facebook'
Severity: Minor
Found in lib/chatbase_api_client.rb by rubocop

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

= is not aligned with the following assignment.
Open

    @intent = params.fetch(:intent, nil)
Severity: Minor
Found in lib/chatbase_api_client.rb by rubocop

This cop checks for extra/unnecessary whitespace.

Example:

# good if AllowForAlignment is true
name      = "RuboCop"
# Some comment and an empty line

website  += "/bbatsov/rubocop" unless cond
puts        "rubocop"          if     debug

# bad for any configuration
set_app("RuboCop")
website  = "https://github.com/bbatsov/rubocop"

= is not aligned with the following assignment.
Open

    message = message.to_json if message.is_a?(Hash)
Severity: Minor
Found in lib/chatbase_api_client.rb by rubocop

This cop checks for extra/unnecessary whitespace.

Example:

# good if AllowForAlignment is true
name      = "RuboCop"
# Some comment and an empty line

website  += "/bbatsov/rubocop" unless cond
puts        "rubocop"          if     debug

# bad for any configuration
set_app("RuboCop")
website  = "https://github.com/bbatsov/rubocop"

= is not aligned with the preceding assignment.
Open

    @text = params.fetch(:text, nil)
Severity: Minor
Found in lib/chatbase_api_client.rb by rubocop

This cop checks for extra/unnecessary whitespace.

Example:

# good if AllowForAlignment is true
name      = "RuboCop"
# Some comment and an empty line

website  += "/bbatsov/rubocop" unless cond
puts        "rubocop"          if     debug

# bad for any configuration
set_app("RuboCop")
website  = "https://github.com/bbatsov/rubocop"

= is not aligned with the preceding assignment.
Open

    @not_handled = not_handled
Severity: Minor
Found in lib/chatbase_api_client.rb by rubocop

This cop checks for extra/unnecessary whitespace.

Example:

# good if AllowForAlignment is true
name      = "RuboCop"
# Some comment and an empty line

website  += "/bbatsov/rubocop" unless cond
puts        "rubocop"          if     debug

# bad for any configuration
set_app("RuboCop")
website  = "https://github.com/bbatsov/rubocop"

= is not aligned with the preceding assignment.
Open

    @not_handled = params.fetch(:not_handled, false)
Severity: Minor
Found in lib/chatbase_api_client.rb by rubocop

This cop checks for extra/unnecessary whitespace.

Example:

# good if AllowForAlignment is true
name      = "RuboCop"
# Some comment and an empty line

website  += "/bbatsov/rubocop" unless cond
puts        "rubocop"          if     debug

# bad for any configuration
set_app("RuboCop")
website  = "https://github.com/bbatsov/rubocop"

There are no issues that match your filters.

Category
Status