[Cleanup] Resolve some easy ruby warnings

Mostly duplicate method warnings
This commit is contained in:
Earlopain 2024-04-28 11:59:37 +02:00
parent f51e0e85cf
commit a7ef80074d
No known key found for this signature in database
GPG Key ID: 48860312319ADF61
5 changed files with 7 additions and 22 deletions

View File

@ -10,15 +10,15 @@ module Danbooru
def has_bit_flags(attributes, options = {})
field = options[:field] || :bit_flags
define_singleton_method("flag_value_for") do |key|
index = attributes.index(key)
raise IndexError if index.nil?
1 << index
end
attributes.each.with_index do |attribute, i|
bit_flag = 1 << i
define_singleton_method("flag_value_for") do |key|
index = attributes.index(key)
raise IndexError if index.nil?
1 << index
end
define_method(attribute) do
send(field) & bit_flag > 0
end

View File

@ -97,7 +97,6 @@ class StorageManager
def protected_params(url, post, secret: Danbooru.config.protected_file_secret)
user_id = CurrentUser.id
ip = CurrentUser.ip_addr
time = (Time.now + 15.minute).to_i
secret = secret
hmac = Digest::MD5.base64digest("#{time} #{url} #{user_id} #{secret}").tr("+/","-_").gsub("==",'')

View File

@ -196,14 +196,6 @@ class ForumPost < ApplicationRecord
self.is_hidden = false if is_hidden.nil?
end
def creator_name
User.id_to_name(creator_id)
end
def updater_name
User.id_to_name(updater_id)
end
def forum_topic_page
(ForumPost.where("topic_id = ? and created_at <= ?", topic_id, created_at).count / Danbooru.config.records_per_page.to_f).ceil
end

View File

@ -3,7 +3,7 @@
<head>
<%= render "layouts/head" %>
</head>
<%= tag.body **body_attributes(CurrentUser.user) do %>
<%= tag.body(**body_attributes(CurrentUser.user)) do %>
<%= render "layouts/theme_include" %>
<header id="top">

View File

@ -44,12 +44,6 @@ class ParseValueTest < ActiveSupport::TestCase
assert_equal(0.0, eq_value("10:0", :ratio))
end
should "parse floats" do
assert_equal(10.0, eq_value("10", :float))
assert_equal(0.1, eq_value(".1", :float))
assert_equal(1.234, eq_value("1.234", :float))
end
should "parse filesizes" do
assert_equal(10, eq_value("10", :filesize))
assert_equal(102, eq_value(".1kb", :filesize))