Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ruby/app/controller/controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
class SomeController < Rails::ActionController

end
2 changes: 1 addition & 1 deletion ruby/app/models/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def schedule_welcome_email
end

class Comment < ApplicationRecord
after_create_commit :broadcast
after_create_commit :broadcast
after_destroy_commit :broadcast

def broadcast
Expand Down
21 changes: 9 additions & 12 deletions ruby/code.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# frozen_string_literal: true

# Raises "bad ordering of magic comments"
# frozen_string_literal: true
# encoding: ascii

# Raises "use of deprecated BigDecimal.new"
a = { 'hello' => 'world', 'testing' => BigDecimal.new(123.456, 3) }
a = {"hello" => "world", "testing" => BigDecimal("123.456", 3)}

# Raises "`while`/`until` detected in `begin` block"
begin
do_something
end while a == b

# Raises "multiple comparison detected"
x < y < z
10 <= x <= 20
x < y && y < z
10 <= x && x <= 20

# Raises "empty rescue block detected"
begin
Expand All @@ -24,12 +23,11 @@

# Raises "redundant `else`-clause detected"
if bar
else
end

# Raises "unused method arguments detected"
def some_method(bar)
puts 'Hello'
puts "Hello"
end

# Raises "unreachable code detected"
Expand All @@ -49,7 +47,7 @@ def some_method
end

# Raises "Deprecated way of initializing OpenSSL::Cipher and OpenSSL::Digest"
OpenSSL::Cipher::AES.new(128, :GCM)
OpenSSL::Cipher.new("aes-128-gcm")

# Raises "put empty method definitions on a single line"
# Also raises "multiple methods with same name in the same scope" as we have a
Expand All @@ -64,17 +62,16 @@ def foo
end

# Raises "Use `Range#cover?` instead of `Range#include?`"
(1..9).include?(5)
(1..9).cover?(5)

my_hash = {}
# Raises "Hash merging can be replaced by hash key assignment"
my_hash.merge!('key': value)

my_hash[:key] = value

# Raises "Use `size` instead of `count`"
[1, 2, 3].count
[1, 2, 3].size

file_path = 'path/to/some/file'
file_path = "path/to/some/file"
unless File.exist?(file_path)
FileUtils.remove file_path
end
Expand Down