tulul/lycantulul_bot

View on GitHub
maintenance_toggle.rb

Summary

Maintainability
A
0 mins
Test Coverage

Space inside string interpolation detected.
Open

puts "Maintenance mode toggling to #{res ^ 1 == 0 ? 'deactivated' : 'activated' }"
Severity: Minor
Found in maintenance_toggle.rb by rubocop

This cop checks for whitespace within string interpolations.

Example: EnforcedStyle: no_space (default)

# bad
   var = "This is the #{ space } example"

# good
   var = "This is the #{no_space} example"

Example: EnforcedStyle: space

# bad
   var = "This is the #{no_space} example"

# good
   var = "This is the #{ space } example"

Do not introduce global variables.
Open

$redis.set('lycantulul::maintenance_prevent', rp ^ 1)
Severity: Minor
Found in maintenance_toggle.rb by rubocop

This cops looks for uses of global variables. It does not report offenses for built-in global variables. Built-in global variables are allowed by default. Additionally users can allow additional variables via the AllowedVariables option.

Note that backreferences like $1, $2, etc are not global variables.

Example:

# bad
$foo = 2
bar = $foo + 5

# good
FOO = 2
foo = 2
$stdin.read

Do not introduce global variables.
Open

$redis.set('lycantulul::maintenance', res ^ 1)
Severity: Minor
Found in maintenance_toggle.rb by rubocop

This cops looks for uses of global variables. It does not report offenses for built-in global variables. Built-in global variables are allowed by default. Additionally users can allow additional variables via the AllowedVariables option.

Note that backreferences like $1, $2, etc are not global variables.

Example:

# bad
$foo = 2
bar = $foo + 5

# good
FOO = 2
foo = 2
$stdin.read

Do not introduce global variables.
Open

res = $redis.get('lycantulul::maintenance').to_i rescue 0
Severity: Minor
Found in maintenance_toggle.rb by rubocop

This cops looks for uses of global variables. It does not report offenses for built-in global variables. Built-in global variables are allowed by default. Additionally users can allow additional variables via the AllowedVariables option.

Note that backreferences like $1, $2, etc are not global variables.

Example:

# bad
$foo = 2
bar = $foo + 5

# good
FOO = 2
foo = 2
$stdin.read

Do not introduce global variables.
Open

Telegram::Bot::Client.run($token) do |bot|
Severity: Minor
Found in maintenance_toggle.rb by rubocop

This cops looks for uses of global variables. It does not report offenses for built-in global variables. Built-in global variables are allowed by default. Additionally users can allow additional variables via the AllowedVariables option.

Note that backreferences like $1, $2, etc are not global variables.

Example:

# bad
$foo = 2
bar = $foo + 5

# good
FOO = 2
foo = 2
$stdin.read

Do not introduce global variables.
Open

  $redis.del('lycantulul::maintenance_info')
Severity: Minor
Found in maintenance_toggle.rb by rubocop

This cops looks for uses of global variables. It does not report offenses for built-in global variables. Built-in global variables are allowed by default. Additionally users can allow additional variables via the AllowedVariables option.

Note that backreferences like $1, $2, etc are not global variables.

Example:

# bad
$foo = 2
bar = $foo + 5

# good
FOO = 2
foo = 2
$stdin.read

Avoid using rescue in its modifier form.
Open

      bot.api.send_message(chat_id: q, text: 'Sudah selesai bermain tenis. Silakan mulai main lagi~') rescue nil
Severity: Minor
Found in maintenance_toggle.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

Avoid using rescue in its modifier form.
Open

res = $redis.get('lycantulul::maintenance').to_i rescue 0
Severity: Minor
Found in maintenance_toggle.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

Line is too long. [112/80]
Open

      bot.api.send_message(chat_id: q, text: 'Sudah selesai bermain tenis. Silakan mulai main lagi~') rescue nil
Severity: Minor
Found in maintenance_toggle.rb by rubocop

Use (res ^ 1).zero? instead of res ^ 1 == 0.
Open

puts "Maintenance mode toggling to #{res ^ 1 == 0 ? 'deactivated' : 'activated' }"
Severity: Minor
Found in maintenance_toggle.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

Avoid using rescue in its modifier form.
Open

  bot.api.send_message(chat_id: Lycantulul::RegisteredPlayer.find_by(username: 'araishikeiwai').user_id, text: 'MAINTENANCE TOGGLED') rescue nil
Severity: Minor
Found in maintenance_toggle.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

Line is too long. [154/80]
Open

    bot.api.send_message(chat_id: game.group_id, text: 'Abis ini mau main tenis bentar yak, nungguin pada selese main dulu. Bentar doang kok.') rescue nil
Severity: Minor
Found in maintenance_toggle.rb by rubocop

Line is too long. [144/80]
Open

  bot.api.send_message(chat_id: Lycantulul::RegisteredPlayer.find_by(username: 'araishikeiwai').user_id, text: 'MAINTENANCE TOGGLED') rescue nil
Severity: Minor
Found in maintenance_toggle.rb by rubocop

Do not introduce global variables.
Open

    $redis.rpush('lycantulul::maintenance_info', game.group_id)
Severity: Minor
Found in maintenance_toggle.rb by rubocop

This cops looks for uses of global variables. It does not report offenses for built-in global variables. Built-in global variables are allowed by default. Additionally users can allow additional variables via the AllowedVariables option.

Note that backreferences like $1, $2, etc are not global variables.

Example:

# bad
$foo = 2
bar = $foo + 5

# good
FOO = 2
foo = 2
$stdin.read

Avoid using rescue in its modifier form.
Open

    bot.api.send_message(chat_id: game.group_id, text: 'Abis ini mau main tenis bentar yak, nungguin pada selese main dulu. Bentar doang kok.') rescue nil
Severity: Minor
Found in maintenance_toggle.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

Do not introduce global variables.
Open

  queue = $redis.lrange('lycantulul::maintenance_info', 0, -1).uniq
Severity: Minor
Found in maintenance_toggle.rb by rubocop

This cops looks for uses of global variables. It does not report offenses for built-in global variables. Built-in global variables are allowed by default. Additionally users can allow additional variables via the AllowedVariables option.

Note that backreferences like $1, $2, etc are not global variables.

Example:

# bad
$foo = 2
bar = $foo + 5

# good
FOO = 2
foo = 2
$stdin.read

Do not introduce global variables.
Open

  Telegram::Bot::Client.run($token) do |bot|
Severity: Minor
Found in maintenance_toggle.rb by rubocop

This cops looks for uses of global variables. It does not report offenses for built-in global variables. Built-in global variables are allowed by default. Additionally users can allow additional variables via the AllowedVariables option.

Note that backreferences like $1, $2, etc are not global variables.

Example:

# bad
$foo = 2
bar = $foo + 5

# good
FOO = 2
foo = 2
$stdin.read

Use (count = Lycantulul::Game.running.count).positive? instead of (count = Lycantulul::Game.running.count) > 0.
Open

while res == 0 && (count = Lycantulul::Game.running.count) > 0
Severity: Minor
Found in maintenance_toggle.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

Line is too long. [82/80]
Open

puts "Maintenance mode toggling to #{res ^ 1 == 0 ? 'deactivated' : 'activated' }"
Severity: Minor
Found in maintenance_toggle.rb by rubocop

Avoid using rescue in its modifier form.
Open

rp = $redis.get('lycantulul::maintenance_prevent').to_i rescue 0
Severity: Minor
Found in maintenance_toggle.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

Use res.zero? instead of res == 0.
Open

while res == 0 && (count = Lycantulul::Game.running.count) > 0
Severity: Minor
Found in maintenance_toggle.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

Missing magic comment # frozen_string_literal: true.
Open

load 'Rakefile'
Severity: Minor
Found in maintenance_toggle.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

Do not introduce global variables.
Open

rp = $redis.get('lycantulul::maintenance_prevent').to_i rescue 0
Severity: Minor
Found in maintenance_toggle.rb by rubocop

This cops looks for uses of global variables. It does not report offenses for built-in global variables. Built-in global variables are allowed by default. Additionally users can allow additional variables via the AllowedVariables option.

Note that backreferences like $1, $2, etc are not global variables.

Example:

# bad
$foo = 2
bar = $foo + 5

# good
FOO = 2
foo = 2
$stdin.read

Do not introduce global variables.
Open

Telegram::Bot::Client.run($token) do |bot|
Severity: Minor
Found in maintenance_toggle.rb by rubocop

This cops looks for uses of global variables. It does not report offenses for built-in global variables. Built-in global variables are allowed by default. Additionally users can allow additional variables via the AllowedVariables option.

Note that backreferences like $1, $2, etc are not global variables.

Example:

# bad
$foo = 2
bar = $foo + 5

# good
FOO = 2
foo = 2
$stdin.read

There are no issues that match your filters.

Category
Status