bump ameba to 1.4.0 and fix warnings (#654)

This commit is contained in:
Anton Maminov 2023-02-17 07:18:37 +02:00 committed by GitHub
parent 19661893ca
commit 6a10ea8127
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 11 deletions

View file

@ -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
Enabled: true
Severity: Warning
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:
- src/kemal/param_parser.cr
- src/kemal/static_file_handler.cr
- src/kemal/config.cr
Enabled: true
Severity: Warning

View file

@ -15,7 +15,7 @@ dependencies:
development_dependencies:
ameba:
github: crystal-ameba/ameba
version: ~> 1.0
version: ~> 1.4.0
crystal: ">= 0.36.0"

View file

@ -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

View file

@ -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

View file

@ -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"
@ -159,7 +159,7 @@ module Kemal
end
end
def self.config
def self.config(&)
yield Config::INSTANCE
end

View file

@ -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