Skip to content

Commit

Permalink
bump ameba to 1.4.0 and fix warnings (#654)
Browse files Browse the repository at this point in the history
  • Loading branch information
mamantoha authored Feb 17, 2023
1 parent 1966189 commit 6a10ea8
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 10 deletions.
17 changes: 14 additions & 3 deletions .ameba.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
# This configuration file was generated by `ameba --gen-config`
# on 2019-08-25 09:29:24 UTC using Ameba version 0.10.0.
# on 2023-01-30 12:35:15 UTC using Ameba version 1.4.0.
# The point is for the user to remove these configuration records
# one by one as the reported problems are removed from the code base.

# Problems found: 7
# Problems found: 2
# Run `ameba --only Lint/UselessAssign` for details
Lint/UselessAssign:
Description: Disallows useless variable assignments
Excluded:
- spec/view_spec.cr
Enabled: true
Severity: Warning

# Problems found: 6
# Run `ameba --only Lint/NotNil` for details
Lint/NotNil:
Description: Identifies usage of `not_nil!` calls
Excluded:
- spec/view_spec.cr
- src/kemal/param_parser.cr
- src/kemal/static_file_handler.cr
- src/kemal/config.cr
Enabled: true
Severity: Warning
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
development_dependencies:
ameba:
github: crystal-ameba/ameba
version: ~> 1.0
version: ~> 1.4.0

crystal: ">= 0.36.0"

Expand Down
2 changes: 1 addition & 1 deletion spec/config_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe "Config" do
end

it "sets default powered_by_header to true" do
Kemal::Config.new.powered_by_header.should be_true
Kemal::Config.new.powered_by_header?.should be_true
end

it "sets host binding" do
Expand Down
2 changes: 1 addition & 1 deletion src/kemal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module Kemal
#
# To use custom command line arguments, set args to nil
#
def self.run(port : Int32? = nil, args = ARGV, trap_signal : Bool = true, &block)
def self.run(port : Int32? = nil, args = ARGV, trap_signal : Bool = true, &)
Kemal::CLI.new args
config = Kemal.config
config.setup
Expand Down
6 changes: 3 additions & 3 deletions src/kemal/config.cr
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ module Kemal
@ssl : OpenSSL::SSL::Context::Server?
{% end %}

property host_binding, ssl, port, env, public_folder, logging, running
property app_name, host_binding, ssl, port, env, public_folder, logging, running
property always_rescue, server : HTTP::Server?, extra_options, shutdown_message
property serve_static : (Bool | Hash(String, Bool))
property static_headers : (HTTP::Server::Response, String, File::Info -> Void)?
property powered_by_header : Bool = true, app_name
property? powered_by_header : Bool = true

def initialize
@app_name = "Kemal"
Expand Down Expand Up @@ -159,7 +159,7 @@ module Kemal
end
end

def self.config
def self.config(&)
yield Config::INSTANCE
end

Expand Down
2 changes: 1 addition & 1 deletion src/kemal/init_handler.cr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Kemal
INSTANCE = new

def call(context : HTTP::Server::Context)
context.response.headers.add "X-Powered-By", "Kemal" if Kemal.config.powered_by_header
context.response.headers.add "X-Powered-By", "Kemal" if Kemal.config.powered_by_header?
context.response.content_type = "text/html" unless context.response.headers.has_key?("Content-Type")
call_next context
end
Expand Down

0 comments on commit 6a10ea8

Please sign in to comment.