From 20cb751ff65a179a694fde4ce2bb60dda0e68b30 Mon Sep 17 00:00:00 2001 From: syeopite Date: Fri, 24 Sep 2021 19:05:25 -0700 Subject: [PATCH] Fix Lint/UnusedArgument issues --- src/invidious.cr | 2 +- src/invidious/channels/community.cr | 2 +- src/invidious/channels/playlists.cr | 2 +- src/invidious/channels/videos.cr | 2 +- src/invidious/comments.cr | 4 ++-- src/invidious/helpers/serialized_yt_data.cr | 2 +- src/invidious/helpers/signatures.cr | 2 +- src/invidious/playlists.cr | 6 +++--- src/invidious/routes/api/v1/authenticated.cr | 2 +- src/invidious/routes/login.cr | 4 ++-- src/invidious/search.cr | 4 ++-- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index 570c33e6..e2c83bda 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -1351,7 +1351,7 @@ error 500 do |env, ex| error_template(500, ex) end -static_headers do |response, filepath, filestat| +static_headers do | response | response.headers.add("Cache-Control", "max-age=2629800") end diff --git a/src/invidious/channels/community.cr b/src/invidious/channels/community.cr index 97ab30ec..a8bdd2e4 100644 --- a/src/invidious/channels/community.cr +++ b/src/invidious/channels/community.cr @@ -242,7 +242,7 @@ def produce_channel_community_continuation(ucid, cursor) }, } - continuation = object.try { |i| Protodec::Any.cast_json(object) } + continuation = object.try { |i| Protodec::Any.cast_json(i) } .try { |i| Protodec::Any.from_json(i) } .try { |i| Base64.urlsafe_encode(i) } .try { |i| URI.encode_www_form(i) } diff --git a/src/invidious/channels/playlists.cr b/src/invidious/channels/playlists.cr index 393b055e..3072b21d 100644 --- a/src/invidious/channels/playlists.cr +++ b/src/invidious/channels/playlists.cr @@ -84,7 +84,7 @@ def produce_channel_playlists_url(ucid, cursor, sort = "newest", auto_generated object["80226972:embedded"]["3:string"] = Base64.urlsafe_encode(Protodec::Any.from_json(Protodec::Any.cast_json(object["80226972:embedded"]["3:base64"]))) object["80226972:embedded"].delete("3:base64") - continuation = object.try { |i| Protodec::Any.cast_json(object) } + continuation = object.try { |i| Protodec::Any.cast_json(i) } .try { |i| Protodec::Any.from_json(i) } .try { |i| Base64.urlsafe_encode(i) } .try { |i| URI.encode_www_form(i) } diff --git a/src/invidious/channels/videos.cr b/src/invidious/channels/videos.cr index 2c43bf0b..48453bb7 100644 --- a/src/invidious/channels/videos.cr +++ b/src/invidious/channels/videos.cr @@ -49,7 +49,7 @@ def produce_channel_videos_continuation(ucid, page = 1, auto_generated = nil, so object["80226972:embedded"]["3:string"] = Base64.urlsafe_encode(Protodec::Any.from_json(Protodec::Any.cast_json(object["80226972:embedded"]["3:base64"]))) object["80226972:embedded"].delete("3:base64") - continuation = object.try { |i| Protodec::Any.cast_json(object) } + continuation = object.try { |i| Protodec::Any.cast_json(i) } .try { |i| Protodec::Any.from_json(i) } .try { |i| Base64.urlsafe_encode(i) } .try { |i| URI.encode_www_form(i) } diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr index 9c788253..caeaa0e8 100644 --- a/src/invidious/comments.cr +++ b/src/invidious/comments.cr @@ -638,7 +638,7 @@ def produce_comment_continuation(video_id, cursor = "", sort_by = "top") object["6:embedded"].as(Hash)["4:embedded"].as(Hash)["6:varint"] = 0_i64 end - continuation = object.try { |i| Protodec::Any.cast_json(object) } + continuation = object.try { |i| Protodec::Any.cast_json(i) } .try { |i| Protodec::Any.from_json(i) } .try { |i| Base64.urlsafe_encode(i) } .try { |i| URI.encode_www_form(i) } @@ -673,7 +673,7 @@ def produce_comment_reply_continuation(video_id, ucid, comment_id) }, } - continuation = object.try { |i| Protodec::Any.cast_json(object) } + continuation = object.try { |i| Protodec::Any.cast_json(i) } .try { |i| Protodec::Any.from_json(i) } .try { |i| Base64.urlsafe_encode(i) } .try { |i| URI.encode_www_form(i) } diff --git a/src/invidious/helpers/serialized_yt_data.cr b/src/invidious/helpers/serialized_yt_data.cr index a9798f0c..1ba3f20e 100644 --- a/src/invidious/helpers/serialized_yt_data.cr +++ b/src/invidious/helpers/serialized_yt_data.cr @@ -62,7 +62,7 @@ struct SearchVideo if xml to_xml(HOST_URL, auto_generated, query_params, xml) else - XML.build do |json| + XML.build do |xml| to_xml(HOST_URL, auto_generated, query_params, xml) end end diff --git a/src/invidious/helpers/signatures.cr b/src/invidious/helpers/signatures.cr index d8b1de65..ee09415b 100644 --- a/src/invidious/helpers/signatures.cr +++ b/src/invidious/helpers/signatures.cr @@ -30,7 +30,7 @@ struct DecryptFunction case op_body when "{a.reverse()" - operations[op_name] = ->(a : Array(String), b : Int32) { a.reverse } + operations[op_name] = ->(a : Array(String), _b : Int32) { a.reverse } when "{a.splice(0,b)" operations[op_name] = ->(a : Array(String), b : Int32) { a.delete_at(0..(b - 1)); a } else diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr index 7940dc1f..70c74eb3 100644 --- a/src/invidious/playlists.cr +++ b/src/invidious/playlists.cr @@ -51,7 +51,7 @@ struct PlaylistVideo if xml to_xml(auto_generated, xml) else - XML.build do |json| + XML.build do |xml| # Why was this `json`? to_xml(auto_generated, xml) end end @@ -143,7 +143,7 @@ struct Playlist json.field "videos" do json.array do videos = get_playlist_videos(PG_DB, self, offset: offset, locale: locale, video_id: video_id) - videos.each_with_index do |video, index| + videos.each do |video| video.to_json(locale, json) end end @@ -336,7 +336,7 @@ def produce_playlist_continuation(id, index) }, } - continuation = object.try { |i| Protodec::Any.cast_json(object) } + continuation = object.try { |i| Protodec::Any.cast_json(i) } .try { |i| Protodec::Any.from_json(i) } .try { |i| Base64.urlsafe_encode(i) } .try { |i| URI.encode_www_form(i) } diff --git a/src/invidious/routes/api/v1/authenticated.cr b/src/invidious/routes/api/v1/authenticated.cr index b4e9e9c8..f7a2ad78 100644 --- a/src/invidious/routes/api/v1/authenticated.cr +++ b/src/invidious/routes/api/v1/authenticated.cr @@ -335,7 +335,7 @@ module Invidious::Routes::API::V1::Authenticated case env.request.headers["Content-Type"]? when "application/x-www-form-urlencoded" - scopes = env.params.body.select { |k, v| k.match(/^scopes\[\d+\]$/) }.map { |k, v| v } + scopes = env.params.body.select { |k, _| k.match(/^scopes\[\d+\]$/) }.map { |_, v| v } callback_url = env.params.body["callbackUrl"]? expire = env.params.body["expire"]?.try &.to_i? when "application/json" diff --git a/src/invidious/routes/login.cr b/src/invidious/routes/login.cr index e7aef289..b719b571 100644 --- a/src/invidious/routes/login.cr +++ b/src/invidious/routes/login.cr @@ -395,7 +395,7 @@ module Invidious::Routes::Login return templated "login" end - tokens = env.params.body.select { |k, v| k.match(/^token\[\d+\]$/) }.map { |k, v| v } + tokens = env.params.body.select { |k, _| k.match(/^token\[\d+\]$/) }.map { |_, v| v } answer ||= "" captcha_type ||= "image" @@ -419,7 +419,7 @@ module Invidious::Routes::Login found_valid_captcha = false error_exception = Exception.new - tokens.each_with_index do |token, i| + tokens.each do |token| begin validate_request(token, answer, env.request, HMAC_KEY, PG_DB, locale) found_valid_captcha = true diff --git a/src/invidious/search.cr b/src/invidious/search.cr index d95d802e..f59c9a14 100644 --- a/src/invidious/search.cr +++ b/src/invidious/search.cr @@ -128,7 +128,7 @@ def produce_search_params(page = 1, sort : String = "relevance", date : String = object.delete("2:embedded") end - params = object.try { |i| Protodec::Any.cast_json(object) } + params = object.try { |i| Protodec::Any.cast_json(i) } .try { |i| Protodec::Any.from_json(i) } .try { |i| Base64.urlsafe_encode(i) } .try { |i| URI.encode_www_form(i) } @@ -161,7 +161,7 @@ def produce_channel_search_continuation(ucid, query, page) }, } - continuation = object.try { |i| Protodec::Any.cast_json(object) } + continuation = object.try { |i| Protodec::Any.cast_json(i) } .try { |i| Protodec::Any.from_json(i) } .try { |i| Base64.urlsafe_encode(i) } .try { |i| URI.encode_www_form(i) }