From 031c1daf58a4c39a5f1863da8c0875141a604546 Mon Sep 17 00:00:00 2001 From: Vitalii Elenhaupt Date: Sun, 19 Feb 2023 09:30:05 +0200 Subject: [PATCH 1/4] chore: fix crystal-nightly compatibility --- spec/ameba/severity_spec.cr | 2 +- src/ameba/severity.cr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/ameba/severity_spec.cr b/spec/ameba/severity_spec.cr index 633372b0d..a784f621e 100644 --- a/spec/ameba/severity_spec.cr +++ b/spec/ameba/severity_spec.cr @@ -34,7 +34,7 @@ module Ameba end it "raises when name is incorrect" do - expect_raises(Exception, "Incorrect severity name BadName. Try one of [Error, Warning, Convention]") do + expect_raises(Exception, "Incorrect severity name BadName. Try one of available names") do Severity.parse("BadName") end end diff --git a/src/ameba/severity.cr b/src/ameba/severity.cr index ed350a968..c31c8e822 100644 --- a/src/ameba/severity.cr +++ b/src/ameba/severity.cr @@ -41,7 +41,7 @@ module Ameba def self.parse(name : String) super name rescue ArgumentError - raise "Incorrect severity name #{name}. Try one of #{values}" + raise "Incorrect severity name #{name}. Try one of available names" end end From 63a54986dd97ccc7b9ee2b905ddeb123489ad4ca Mon Sep 17 00:00:00 2001 From: Vitalii Elenhaupt Date: Sun, 19 Feb 2023 14:22:17 +0200 Subject: [PATCH 2/4] Reformat code example --- src/ameba/rule/lint/missing_block_argument.cr | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/ameba/rule/lint/missing_block_argument.cr b/src/ameba/rule/lint/missing_block_argument.cr index b5420f4d4..379bfa853 100644 --- a/src/ameba/rule/lint/missing_block_argument.cr +++ b/src/ameba/rule/lint/missing_block_argument.cr @@ -3,19 +3,15 @@ module Ameba::Rule::Lint # # For example, this is considered invalid: # - # ``` - # def foo - # yield 42 - # end - # ``` + # def foo + # yield 42 + # end # # And has to be written as the following: # - # ``` - # def foo(&) - # yield 42 - # end - # ``` + # def foo(&) + # yield 42 + # end # # YAML configuration example: # From be8862837f183d5b4a376df69b9ab0adac80e04c Mon Sep 17 00:00:00 2001 From: Vitalii Elenhaupt Date: Sun, 19 Feb 2023 14:44:29 +0200 Subject: [PATCH 3/4] Improve error message reported to end user --- spec/ameba/severity_spec.cr | 2 +- src/ameba/severity.cr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/ameba/severity_spec.cr b/spec/ameba/severity_spec.cr index a784f621e..723b250d8 100644 --- a/spec/ameba/severity_spec.cr +++ b/spec/ameba/severity_spec.cr @@ -34,7 +34,7 @@ module Ameba end it "raises when name is incorrect" do - expect_raises(Exception, "Incorrect severity name BadName. Try one of available names") do + expect_raises(Exception, "Incorrect severity name BadName. Try one of Error, Warning, Convention") do Severity.parse("BadName") end end diff --git a/src/ameba/severity.cr b/src/ameba/severity.cr index c31c8e822..0ac8d4b88 100644 --- a/src/ameba/severity.cr +++ b/src/ameba/severity.cr @@ -41,7 +41,7 @@ module Ameba def self.parse(name : String) super name rescue ArgumentError - raise "Incorrect severity name #{name}. Try one of available names" + raise "Incorrect severity name #{name}. Try one of #{values.map(&.to_s).join(", ")}" end end From d03f058cae92346e96028826dfd7eb622bb348b4 Mon Sep 17 00:00:00 2001 From: Vitalii Elenhaupt Date: Sun, 19 Feb 2023 17:39:25 +0200 Subject: [PATCH 4/4] Add semicolon to the error message --- spec/ameba/severity_spec.cr | 2 +- src/ameba/severity.cr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/ameba/severity_spec.cr b/spec/ameba/severity_spec.cr index 723b250d8..9fd17a21c 100644 --- a/spec/ameba/severity_spec.cr +++ b/spec/ameba/severity_spec.cr @@ -34,7 +34,7 @@ module Ameba end it "raises when name is incorrect" do - expect_raises(Exception, "Incorrect severity name BadName. Try one of Error, Warning, Convention") do + expect_raises(Exception, "Incorrect severity name BadName. Try one of: Error, Warning, Convention") do Severity.parse("BadName") end end diff --git a/src/ameba/severity.cr b/src/ameba/severity.cr index 0ac8d4b88..19e5a8095 100644 --- a/src/ameba/severity.cr +++ b/src/ameba/severity.cr @@ -41,7 +41,7 @@ module Ameba def self.parse(name : String) super name rescue ArgumentError - raise "Incorrect severity name #{name}. Try one of #{values.map(&.to_s).join(", ")}" + raise "Incorrect severity name #{name}. Try one of: #{values.map(&.to_s).join(", ")}" end end