From 27b309c9dbe8cb224b9a8e05e3ecf964e025f342 Mon Sep 17 00:00:00 2001 From: George Dietrich Date: Mon, 19 Aug 2024 21:15:37 -0400 Subject: [PATCH] Enable `Lint/UselessAssign` ameba rule again but excluding type declarations (athena-framework/athena#446) --- spec/controller_spec.cr | 2 ++ spec/custom_annotation_spec.cr | 6 +++--- src/ip_utils.cr | 1 - src/request.cr | 7 ++----- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/spec/controller_spec.cr b/spec/controller_spec.cr index df36464..786f198 100644 --- a/spec/controller_spec.cr +++ b/spec/controller_spec.cr @@ -3,6 +3,7 @@ require "./spec_helper" describe ATH::Controller do describe ".render" do it "creates a proper response for the template" do + # ameba:disable Lint/UselessAssign name = "TEST" response = ATH::Controller.render "#{__DIR__}/assets/greeting.ecr" @@ -12,6 +13,7 @@ describe ATH::Controller do end it "creates a proper response for the template with a layout" do + # ameba:disable Lint/UselessAssign name = "TEST" response = ATH::Controller.render "#{__DIR__}/assets/greeting.ecr", "#{__DIR__}/assets/layout.ecr" diff --git a/spec/custom_annotation_spec.cr b/spec/custom_annotation_spec.cr index b301ac4..ccb84bc 100644 --- a/spec/custom_annotation_spec.cr +++ b/spec/custom_annotation_spec.cr @@ -2,21 +2,21 @@ require "./spec_helper" struct CustomAnnotationControllerTest < ATH::Spec::APITestCase def test_with_annotation : Nil - self.get("/with-ann") + self.get "/with-ann" self.assert_response_header_equals "ANNOTATION", "true" self.assert_response_header_equals "ANNOTATION_VALUE", "1" end def test_without_annotation : Nil - self.get("/without-ann") + self.get "/without-ann" self.assert_response_not_has_header "ANNOTATION" self.assert_response_header_equals "ANNOTATION_VALUE", "1" end def test_overriding_class_annotation : Nil - headers = self.get("/with-ann-override").headers + self.get "/with-ann-override" self.assert_response_not_has_header "ANNOTATION" self.assert_response_header_equals "ANNOTATION_VALUE", "2" diff --git a/src/ip_utils.cr b/src/ip_utils.cr index 388aa4b..b30338f 100644 --- a/src/ip_utils.cr +++ b/src/ip_utils.cr @@ -83,7 +83,6 @@ module Athena::Framework::IPUtils return self.set_cached_result cache_key, false end - address = ip netmask = 128 end diff --git a/src/request.cr b/src/request.cr index 1b5c3e8..b6a3b9c 100644 --- a/src/request.cr +++ b/src/request.cr @@ -316,15 +316,12 @@ class Athena::Framework::Request end if @@trusted_header_set.includes?(ProxyHeader::FORWARDED) && (forwarded_param = type.forwarded_param) && (forwarded = @request.headers[ProxyHeader::FORWARDED.header]?) - parts = ATH::HeaderUtils.split forwarded, ",;=" - param = type.forwarded_param - - parts.each do |sub_parts| + ATH::HeaderUtils.split(forwarded, ",;=").each do |sub_parts| # In this particular context compiler gets confused, so lets make it happy by skipping unexpected typed parts, which should never happen. next if sub_parts.is_a?(String) next if sub_parts.nil? - unless v = HeaderUtils.combine(sub_parts)[param]?.as?(String?) + unless v = HeaderUtils.combine(sub_parts)[forwarded_param]?.as?(String?) next end