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
…rations (#446)
  • Loading branch information
Blacksmoke16 authored Aug 20, 2024
1 parent 081841f commit 150c355
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .ameba.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Lint/NotNil:
Lint/Typos:
Enabled: false # This has its own dedicated CI job
Lint/UselessAssign:
Enabled: false # TODO: Enable once https://github.com/crystal-ameba/ameba/issues/447 is resolved
ExcludeTypeDeclarations: true # TODO: Disable this once https://github.com/crystal-ameba/ameba/issues/447 is resolved
Naming/AccessorMethodName:
Enabled: false
Naming/BlockParameterName:
Expand Down
4 changes: 2 additions & 2 deletions shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ authors:

dependencies:
athena:
github: athena-framework/athena
github: athena-framework/framework
athena-clock:
github: athena-framework/clock
athena-console:
Expand Down Expand Up @@ -44,7 +44,7 @@ dependencies:
development_dependencies:
ameba:
github: crystal-ameba/ameba
version: ~> 1.6.0
version: ~> 1.6.1
athena-spec:
github: athena-framework/spec
version: ~> 0.3.2
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ describe ADI::ServiceContainer::ProcessAutoconfigureAnnotations do
end

it "handles a non service abstract parent type with service child types" do
collection = ADI.container.non_service_abstract_client.services.should eq [NonServiceChild1.new, NonServiceChild2.new]
ADI.container.non_service_abstract_client.services.should eq [NonServiceChild1.new, NonServiceChild2.new]
end

it "provides an empty array if there were no services configured with the desired tag" do
Expand Down
1 change: 1 addition & 0 deletions src/components/dotenv/src/athena-dotenv.cr
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ class Athena::Dotenv
self.load override_existing_vars, {dist_path}
end

# ameba:disable Lint/UselessAssign
unless env = ENV[env_key]?
self.populate({env_key => env = default_environment}, override_existing_vars)
end
Expand Down
2 changes: 2 additions & 0 deletions src/components/framework/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 src/components/framework/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/components/framework/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/components/framework/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 150c355

Please sign in to comment.