Skip to content

Commit

Permalink
Enable Lint/UselessAssign ameba rule again but excluding type decla…
Browse files Browse the repository at this point in the history
  • Loading branch information
Blacksmoke16 authored Aug 20, 2024
1 parent 38cfba9 commit 27b309c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
2 changes: 2 additions & 0 deletions spec/controller_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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"

Expand Down
6 changes: 3 additions & 3 deletions spec/custom_annotation_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion src/ip_utils.cr
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ module Athena::Framework::IPUtils
return self.set_cached_result cache_key, false
end

address = ip
netmask = 128
end

Expand Down
7 changes: 2 additions & 5 deletions src/request.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 27b309c

Please sign in to comment.