From 5034b2c4f57041f9f75b9081f8c20bddac13e8e9 Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Fri, 6 Dec 2024 20:43:31 +0100 Subject: [PATCH] Make issue messages moar Markdown-friendly --- .../rule/lint/hash_duplicated_key_spec.cr | 6 +-- spec/ameba/rule/lint/percent_arrays_spec.cr | 12 +++--- spec/ameba/rule/lint/rand_zero_spec.cr | 4 +- .../rule/lint/shadowed_exception_spec.cr | 42 +++++++++---------- spec/ameba/rule/lint/spec_filename_spec.cr | 2 +- spec/ameba/rule/lint/typos_spec.cr | 6 +-- .../rule/naming/accessor_method_name_spec.cr | 12 +++--- spec/ameba/rule/naming/constant_names_spec.cr | 2 +- spec/ameba/rule/naming/filename_spec.cr | 2 +- spec/ameba/rule/naming/method_names_spec.cr | 2 +- spec/ameba/rule/naming/predicate_name_spec.cr | 6 +-- .../rule/naming/query_bool_methods_spec.cr | 10 ++--- spec/ameba/rule/naming/type_names_spec.cr | 4 +- spec/ameba/rule/naming/variable_names_spec.cr | 10 ++--- spec/ameba/rule/style/large_numbers_spec.cr | 2 +- spec/ameba/rule/style/unless_else_spec.cr | 2 +- spec/ameba/rule/style/while_true_spec.cr | 2 +- src/ameba/rule/lint/hash_duplicated_key.cr | 2 +- src/ameba/rule/lint/percent_arrays.cr | 2 +- src/ameba/rule/lint/rand_zero.cr | 2 +- src/ameba/rule/lint/shadowed_exception.cr | 2 +- src/ameba/rule/lint/spec_filename.cr | 2 +- src/ameba/rule/lint/typos.cr | 2 +- src/ameba/rule/naming/accessor_method_name.cr | 2 +- src/ameba/rule/naming/constant_names.cr | 2 +- src/ameba/rule/naming/filename.cr | 2 +- src/ameba/rule/naming/method_names.cr | 2 +- src/ameba/rule/naming/predicate_name.cr | 2 +- src/ameba/rule/naming/query_bool_methods.cr | 2 +- src/ameba/rule/naming/type_names.cr | 2 +- src/ameba/rule/naming/variable_names.cr | 2 +- src/ameba/rule/style/large_numbers.cr | 2 +- src/ameba/rule/style/unless_else.cr | 2 +- src/ameba/rule/style/while_true.cr | 2 +- 34 files changed, 80 insertions(+), 80 deletions(-) diff --git a/spec/ameba/rule/lint/hash_duplicated_key_spec.cr b/spec/ameba/rule/lint/hash_duplicated_key_spec.cr index e0093f881..f50085729 100644 --- a/spec/ameba/rule/lint/hash_duplicated_key_spec.cr +++ b/spec/ameba/rule/lint/hash_duplicated_key_spec.cr @@ -15,21 +15,21 @@ module Ameba::Rule::Lint it "fails if there is a duplicated key in a hash literal" do expect_issue subject, <<-CRYSTAL h = {"a" => 1, "b" => 2, "a" => 3} - # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Duplicated keys in hash literal: "a" + # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Duplicated keys in hash literal: `"a"` CRYSTAL end it "fails if there is a duplicated key in the inner hash literal" do expect_issue subject, <<-CRYSTAL h = {"a" => 1, "b" => {"a" => 3, "b" => 4, "a" => 5}} - # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Duplicated keys in hash literal: "a" + # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Duplicated keys in hash literal: `"a"` CRYSTAL end it "reports multiple duplicated keys" do expect_issue subject, <<-CRYSTAL h = {"key1" => 1, "key1" => 2, "key2" => 3, "key2" => 4} - # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Duplicated keys in hash literal: "key1", "key2" + # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Duplicated keys in hash literal: `"key1"`, `"key2"` CRYSTAL end end diff --git a/spec/ameba/rule/lint/percent_arrays_spec.cr b/spec/ameba/rule/lint/percent_arrays_spec.cr index 7301fde8d..213902d58 100644 --- a/spec/ameba/rule/lint/percent_arrays_spec.cr +++ b/spec/ameba/rule/lint/percent_arrays_spec.cr @@ -20,42 +20,42 @@ module Ameba::Rule::Lint it "fails if string percent array has commas" do expect_issue subject, <<-CRYSTAL %w[one, two] - # ^{} error: Symbols `,"` may be unwanted in %w array literals + # ^{} error: Symbols `,"` may be unwanted in `%w` array literals CRYSTAL end it "fails if string percent array has quotes" do expect_issue subject, <<-CRYSTAL %w["one" "two"] - # ^{} error: Symbols `,"` may be unwanted in %w array literals + # ^{} error: Symbols `,"` may be unwanted in `%w` array literals CRYSTAL end it "fails if symbols percent array has commas" do expect_issue subject, <<-CRYSTAL %i[one, two] - # ^{} error: Symbols `,:` may be unwanted in %i array literals + # ^{} error: Symbols `,:` may be unwanted in `%i` array literals CRYSTAL end it "fails if symbols percent array has a colon" do expect_issue subject, <<-CRYSTAL %i[:one :two] - # ^{} error: Symbols `,:` may be unwanted in %i array literals + # ^{} error: Symbols `,:` may be unwanted in `%i` array literals CRYSTAL end it "reports rule, location and message for %i" do expect_issue subject, <<-CRYSTAL %i[:one] - # ^{} error: Symbols `,:` may be unwanted in %i array literals + # ^{} error: Symbols `,:` may be unwanted in `%i` array literals CRYSTAL end it "reports rule, location and message for %w" do expect_issue subject, <<-CRYSTAL %w["one"] - # ^{} error: Symbols `,"` may be unwanted in %w array literals + # ^{} error: Symbols `,"` may be unwanted in `%w` array literals CRYSTAL end diff --git a/spec/ameba/rule/lint/rand_zero_spec.cr b/spec/ameba/rule/lint/rand_zero_spec.cr index e30e1ff8e..19bbff265 100644 --- a/spec/ameba/rule/lint/rand_zero_spec.cr +++ b/spec/ameba/rule/lint/rand_zero_spec.cr @@ -15,14 +15,14 @@ module Ameba::Rule::Lint it "fails if it is rand(0)" do expect_issue subject, <<-CRYSTAL rand(0) - # ^^^^^ error: rand(0) always returns 0 + # ^^^^^ error: `rand(0)` always returns `0` CRYSTAL end it "fails if it is rand(1)" do expect_issue subject, <<-CRYSTAL rand(1) - # ^^^^^ error: rand(1) always returns 0 + # ^^^^^ error: `rand(1)` always returns `0` CRYSTAL end end diff --git a/spec/ameba/rule/lint/shadowed_exception_spec.cr b/spec/ameba/rule/lint/shadowed_exception_spec.cr index 7a3c97fbf..016867a71 100644 --- a/spec/ameba/rule/lint/shadowed_exception_spec.cr +++ b/spec/ameba/rule/lint/shadowed_exception_spec.cr @@ -35,7 +35,7 @@ module Ameba::Rule::Lint rescue Exception handle_exception rescue ArgumentError - # ^^^^^^^^^^^^^ error: Shadowed exception found: ArgumentError + # ^^^^^^^^^^^^^ error: Shadowed exception found: `ArgumentError` handle_argument_error_exception end CRYSTAL @@ -48,7 +48,7 @@ module Ameba::Rule::Lint rescue Exception 2 rescue MySuperException - # ^^^^^^^^^^^^^^^^ error: Shadowed exception found: MySuperException + # ^^^^^^^^^^^^^^^^ error: Shadowed exception found: `MySuperException` 3 end CRYSTAL @@ -58,7 +58,7 @@ module Ameba::Rule::Lint expect_issue subject, <<-CRYSTAL begin rescue Exception | IndexError - # ^^^^^^^^^^ error: Shadowed exception found: IndexError + # ^^^^^^^^^^ error: Shadowed exception found: `IndexError` end CRYSTAL end @@ -67,9 +67,9 @@ module Ameba::Rule::Lint expect_issue subject, <<-CRYSTAL begin rescue IndexError | Exception - # ^^^^^^^^^^ error: Shadowed exception found: IndexError + # ^^^^^^^^^^ error: Shadowed exception found: `IndexError` rescue Exception - # ^^^^^^^^^ error: Shadowed exception found: Exception + # ^^^^^^^^^ error: Shadowed exception found: `Exception` rescue end CRYSTAL @@ -81,7 +81,7 @@ module Ameba::Rule::Lint rescue IndexError rescue ArgumentError rescue IndexError - # ^^^^^^^^^^ error: Shadowed exception found: IndexError + # ^^^^^^^^^^ error: Shadowed exception found: `IndexError` end CRYSTAL end @@ -91,7 +91,7 @@ module Ameba::Rule::Lint begin rescue IndexError rescue ArgumentError | IndexError - # ^^^^^^^^^^ error: Shadowed exception found: IndexError + # ^^^^^^^^^^ error: Shadowed exception found: `IndexError` end CRYSTAL end @@ -101,7 +101,7 @@ module Ameba::Rule::Lint begin rescue IndexError rescue IndexError - # ^^^^^^^^^^ error: Shadowed exception found: IndexError + # ^^^^^^^^^^ error: Shadowed exception found: `IndexError` rescue Exception end CRYSTAL @@ -111,7 +111,7 @@ module Ameba::Rule::Lint expect_issue subject, <<-CRYSTAL begin rescue IndexError | IndexError - # ^^^^^^^^^^ error: Shadowed exception found: IndexError + # ^^^^^^^^^^ error: Shadowed exception found: `IndexError` end CRYSTAL end @@ -121,12 +121,12 @@ module Ameba::Rule::Lint begin rescue Exception rescue ArgumentError - # ^^^^^^^^^^^^^ error: Shadowed exception found: ArgumentError + # ^^^^^^^^^^^^^ error: Shadowed exception found: `ArgumentError` rescue IndexError - # ^^^^^^^^^^ error: Shadowed exception found: IndexError + # ^^^^^^^^^^ error: Shadowed exception found: `IndexError` rescue KeyError | IO::Error - # ^^^^^^^^^ error: Shadowed exception found: IO::Error - # ^^^^^^^^ error: Shadowed exception found: KeyError + # ^^^^^^^^^ error: Shadowed exception found: `IO::Error` + # ^^^^^^^^ error: Shadowed exception found: `KeyError` rescue end CRYSTAL @@ -137,7 +137,7 @@ module Ameba::Rule::Lint begin rescue Exception rescue ex : IndexError - # ^^^^^^^^^^ error: Shadowed exception found: IndexError + # ^^^^^^^^^^ error: Shadowed exception found: `IndexError` rescue end CRYSTAL @@ -148,9 +148,9 @@ module Ameba::Rule::Lint begin rescue Exception rescue ArgumentError - # ^^^^^^^^^^^^^ error: Shadowed exception found: ArgumentError + # ^^^^^^^^^^^^^ error: Shadowed exception found: `ArgumentError` rescue IndexError - # ^^^^^^^^^^ error: Shadowed exception found: IndexError + # ^^^^^^^^^^ error: Shadowed exception found: `IndexError` end CRYSTAL end @@ -160,10 +160,10 @@ module Ameba::Rule::Lint begin rescue Exception rescue ArgumentError | IndexError - # ^^^^^^^^^^ error: Shadowed exception found: IndexError - # ^^^^^^^^^^^^^ error: Shadowed exception found: ArgumentError + # ^^^^^^^^^^ error: Shadowed exception found: `IndexError` + # ^^^^^^^^^^^^^ error: Shadowed exception found: `ArgumentError` rescue IO::Error - # ^^^^^^^^^ error: Shadowed exception found: IO::Error + # ^^^^^^^^^ error: Shadowed exception found: `IO::Error` end CRYSTAL end @@ -173,8 +173,8 @@ module Ameba::Rule::Lint begin do_something rescue Exception | IndexError | ArgumentError - # ^^^^^^^^^^^^^ error: Shadowed exception found: ArgumentError - # ^^^^^^^^^^ error: Shadowed exception found: IndexError + # ^^^^^^^^^^^^^ error: Shadowed exception found: `ArgumentError` + # ^^^^^^^^^^ error: Shadowed exception found: `IndexError` end CRYSTAL end diff --git a/spec/ameba/rule/lint/spec_filename_spec.cr b/spec/ameba/rule/lint/spec_filename_spec.cr index 30a2c57de..fa3757484 100644 --- a/spec/ameba/rule/lint/spec_filename_spec.cr +++ b/spec/ameba/rule/lint/spec_filename_spec.cr @@ -22,7 +22,7 @@ module Ameba::Rule::Lint it "fails if filename is wrong" do expect_issue subject, <<-CRYSTAL, path: "spec/foo.cr" - # ^{} error: Spec filename should have `_spec` suffix: foo_spec.cr, not foo.cr + # ^{} error: Spec filename should have `_spec` suffix: `foo_spec.cr`, not `foo.cr` CRYSTAL end diff --git a/spec/ameba/rule/lint/typos_spec.cr b/spec/ameba/rule/lint/typos_spec.cr index 544b81fe1..50b2ca714 100644 --- a/spec/ameba/rule/lint/typos_spec.cr +++ b/spec/ameba/rule/lint/typos_spec.cr @@ -16,11 +16,11 @@ module Ameba::Rule::Lint source = expect_issue subject, <<-CRYSTAL # method with no arugments - # ^^^^^^^^^ error: Typo found: arugments -> arguments + # ^^^^^^^^^ error: Typo found: `arugments` -> `arguments` def tpos - # ^^^^ error: Typo found: tpos -> typos + # ^^^^ error: Typo found: `tpos` -> `typos` :otput - # ^^^^^ error: Typo found: otput -> output + # ^^^^^ error: Typo found: `otput` -> `output` end CRYSTAL diff --git a/spec/ameba/rule/naming/accessor_method_name_spec.cr b/spec/ameba/rule/naming/accessor_method_name_spec.cr index 9fe18e69c..a1241d996 100644 --- a/spec/ameba/rule/naming/accessor_method_name_spec.cr +++ b/spec/ameba/rule/naming/accessor_method_name_spec.cr @@ -35,11 +35,11 @@ module Ameba::Rule::Naming it "fails if accessor method is defined with receiver in top-level scope" do expect_issue subject, <<-CRYSTAL def Foo.get_user - # ^^^^^^^^ error: Favour method name 'user' over 'get_user' + # ^^^^^^^^ error: Favour method name `user` over `get_user` end def Foo.set_user(user) - # ^^^^^^^^ error: Favour method name 'user=' over 'set_user' + # ^^^^^^^^ error: Favour method name `user=` over `set_user` end CRYSTAL end @@ -48,19 +48,19 @@ module Ameba::Rule::Naming expect_issue subject, <<-CRYSTAL class Foo def self.get_instance - # ^^^^^^^^^^^^ error: Favour method name 'instance' over 'get_instance' + # ^^^^^^^^^^^^ error: Favour method name `instance` over `get_instance` end def self.set_instance(value) - # ^^^^^^^^^^^^ error: Favour method name 'instance=' over 'set_instance' + # ^^^^^^^^^^^^ error: Favour method name `instance=` over `set_instance` end def get_user - # ^^^^^^^^ error: Favour method name 'user' over 'get_user' + # ^^^^^^^^ error: Favour method name `user` over `get_user` end def set_user(user) - # ^^^^^^^^ error: Favour method name 'user=' over 'set_user' + # ^^^^^^^^ error: Favour method name `user=` over `set_user` end end CRYSTAL diff --git a/spec/ameba/rule/naming/constant_names_spec.cr b/spec/ameba/rule/naming/constant_names_spec.cr index 6cbce95e8..c57027cc6 100644 --- a/spec/ameba/rule/naming/constant_names_spec.cr +++ b/spec/ameba/rule/naming/constant_names_spec.cr @@ -8,7 +8,7 @@ module Ameba rule = Rule::Naming::ConstantNames.new expect_issue rule, <<-CRYSTAL, name: name, file: file, line: line %{name} = #{value} - # ^{name} error: Constant name should be screaming-cased: #{expected}, not #{name} + # ^{name} error: Constant name should be screaming-cased: `#{expected}`, not `#{name}` CRYSTAL end end diff --git a/spec/ameba/rule/naming/filename_spec.cr b/spec/ameba/rule/naming/filename_spec.cr index 5673aa913..e12c32fc5 100644 --- a/spec/ameba/rule/naming/filename_spec.cr +++ b/spec/ameba/rule/naming/filename_spec.cr @@ -12,7 +12,7 @@ module Ameba::Rule::Naming it "fails if filename is wrong" do expect_issue subject, <<-CRYSTAL, path: "src/fooBar.cr" - # ^{} error: Filename should be underscore-cased: foo_bar.cr, not fooBar.cr + # ^{} error: Filename should be underscore-cased: `foo_bar.cr`, not `fooBar.cr` CRYSTAL end end diff --git a/spec/ameba/rule/naming/method_names_spec.cr b/spec/ameba/rule/naming/method_names_spec.cr index df664cec9..a6bb82d8d 100644 --- a/spec/ameba/rule/naming/method_names_spec.cr +++ b/spec/ameba/rule/naming/method_names_spec.cr @@ -8,7 +8,7 @@ module Ameba rule = Rule::Naming::MethodNames.new expect_issue rule, <<-CRYSTAL, name: name, file: file, line: line def %{name}; end - # ^{name} error: Method name should be underscore-cased: #{expected}, not %{name} + # ^{name} error: Method name should be underscore-cased: `#{expected}`, not `%{name}` CRYSTAL end end diff --git a/spec/ameba/rule/naming/predicate_name_spec.cr b/spec/ameba/rule/naming/predicate_name_spec.cr index 27e2851d6..acf9adcae 100644 --- a/spec/ameba/rule/naming/predicate_name_spec.cr +++ b/spec/ameba/rule/naming/predicate_name_spec.cr @@ -23,16 +23,16 @@ module Ameba::Rule::Naming expect_issue subject, <<-CRYSTAL class Image def self.is_valid?(x) - # ^^^^^^^^^ error: Favour method name 'valid?' over 'is_valid?' + # ^^^^^^^^^ error: Favour method name `valid?` over `is_valid?` end end def is_valid?(x) - # ^^^^^^^^^ error: Favour method name 'valid?' over 'is_valid?' + # ^^^^^^^^^ error: Favour method name `valid?` over `is_valid?` end def is_valid(x) - # ^^^^^^^^ error: Favour method name 'valid?' over 'is_valid' + # ^^^^^^^^ error: Favour method name `valid?` over `is_valid` end CRYSTAL end diff --git a/spec/ameba/rule/naming/query_bool_methods_spec.cr b/spec/ameba/rule/naming/query_bool_methods_spec.cr index 8d4710d0f..ee731efd3 100644 --- a/spec/ameba/rule/naming/query_bool_methods_spec.cr +++ b/spec/ameba/rule/naming/query_bool_methods_spec.cr @@ -30,9 +30,9 @@ module Ameba::Rule::Naming class Foo class_property? foo = true class_property bar = true - # ^^^ error: Consider using 'class_property?' for 'bar' + # ^^^ error: Consider using `class_property?` for `bar` class_property baz = true - # ^^^ error: Consider using 'class_property?' for 'baz' + # ^^^ error: Consider using `class_property?` for `baz` end CRYSTAL end @@ -42,7 +42,7 @@ module Ameba::Rule::Naming expect_issue subject, <<-CRYSTAL, call: {{ call }} class Foo %{call} foo = true - _{call} # ^^^ error: Consider using '%{call}?' for 'foo' + _{call} # ^^^ error: Consider using `%{call}?` for `foo` end CRYSTAL end @@ -51,7 +51,7 @@ module Ameba::Rule::Naming expect_issue subject, <<-CRYSTAL, call: {{ call }} class Foo %{call} foo : Bool = true - _{call} # ^^^ error: Consider using '%{call}?' for 'foo' + _{call} # ^^^ error: Consider using `%{call}?` for `foo` end CRYSTAL end @@ -60,7 +60,7 @@ module Ameba::Rule::Naming expect_issue subject, <<-CRYSTAL, call: {{ call }} class Foo %{call} foo : Bool - _{call} # ^^^ error: Consider using '%{call}?' for 'foo' + _{call} # ^^^ error: Consider using `%{call}?` for `foo` def initialize(@foo = true) end diff --git a/spec/ameba/rule/naming/type_names_spec.cr b/spec/ameba/rule/naming/type_names_spec.cr index 555b21c83..9dc94f846 100644 --- a/spec/ameba/rule/naming/type_names_spec.cr +++ b/spec/ameba/rule/naming/type_names_spec.cr @@ -8,7 +8,7 @@ module Ameba rule = Rule::Naming::TypeNames.new expect_issue rule, <<-CRYSTAL, type: type, name: name, file: file, line: line %{type} %{name}; end - _{type} # ^{name} error: Type name should be camelcased: #{expected}, but it was %{name} + _{type} # ^{name} error: Type name should be camelcased: `#{expected}`, not `%{name}` CRYSTAL end end @@ -46,7 +46,7 @@ module Ameba it "reports alias name" do expect_issue subject, <<-CRYSTAL alias Numeric_value = Int32 - # ^^^^^^^^^^^^^ error: Type name should be camelcased: NumericValue, but it was Numeric_value + # ^^^^^^^^^^^^^ error: Type name should be camelcased: `NumericValue`, not `Numeric_value` CRYSTAL end end diff --git a/spec/ameba/rule/naming/variable_names_spec.cr b/spec/ameba/rule/naming/variable_names_spec.cr index 586dc51c6..b2c5cb0b4 100644 --- a/spec/ameba/rule/naming/variable_names_spec.cr +++ b/spec/ameba/rule/naming/variable_names_spec.cr @@ -8,7 +8,7 @@ module Ameba rule = Rule::Naming::VariableNames.new expect_issue rule, <<-CRYSTAL, name: name, file: file, line: line %{name} = #{value} - # ^{name} error: Var name should be underscore-cased: #{expected}, not %{name} + # ^{name} error: Variable name should be underscore-cased: `#{expected}`, not `%{name}` CRYSTAL end end @@ -37,7 +37,7 @@ module Ameba expect_issue subject, <<-CRYSTAL class Greeting def initialize(@badNamed = nil) - # ^ error: Var name should be underscore-cased: @bad_named, not @badNamed + # ^ error: Variable name should be underscore-cased: `@bad_named`, not `@badNamed` end end CRYSTAL @@ -47,8 +47,8 @@ module Ameba expect_issue subject, <<-CRYSTAL class Location def at(@startLocation = nil, @endLocation = nil) - # ^ error: Var name should be underscore-cased: @start_location, not @startLocation - # ^ error: Var name should be underscore-cased: @end_location, not @endLocation + # ^ error: Variable name should be underscore-cased: `@start_location`, not `@startLocation` + # ^ error: Variable name should be underscore-cased: `@end_location`, not `@endLocation` end end CRYSTAL @@ -58,7 +58,7 @@ module Ameba expect_issue subject, <<-CRYSTAL class Greeting @@defaultGreeting = "Hello world" - # ^^^^^^^^^^^^^^^^^ error: Var name should be underscore-cased: @@default_greeting, not @@defaultGreeting + # ^^^^^^^^^^^^^^^^^ error: Variable name should be underscore-cased: `@@default_greeting`, not `@@defaultGreeting` end CRYSTAL end diff --git a/spec/ameba/rule/style/large_numbers_spec.cr b/spec/ameba/rule/style/large_numbers_spec.cr index 68833d82b..cca9fcf96 100644 --- a/spec/ameba/rule/style/large_numbers_spec.cr +++ b/spec/ameba/rule/style/large_numbers_spec.cr @@ -10,7 +10,7 @@ module Ameba source = expect_issue rule, <<-CRYSTAL, number: number, file: file, line: line number = %{number} - # ^{number} error: Large numbers should be written with underscores: #{expected} + # ^{number} error: Large numbers should be written with underscores: `#{expected}` CRYSTAL expect_correction source, <<-CRYSTAL diff --git a/spec/ameba/rule/style/unless_else_spec.cr b/spec/ameba/rule/style/unless_else_spec.cr index 4cd3bc745..262214ee5 100644 --- a/spec/ameba/rule/style/unless_else_spec.cr +++ b/spec/ameba/rule/style/unless_else_spec.cr @@ -15,7 +15,7 @@ module Ameba::Rule::Style it "fails if unless has else" do source = expect_issue subject, <<-CRYSTAL unless something - # ^^^^^^^^^^^^^^ error: Favour if over unless with else + # ^^^^^^^^^^^^^^ error: Favour `if` over `unless` with `else` :one else :two diff --git a/spec/ameba/rule/style/while_true_spec.cr b/spec/ameba/rule/style/while_true_spec.cr index 3464e272e..7c11505d8 100644 --- a/spec/ameba/rule/style/while_true_spec.cr +++ b/spec/ameba/rule/style/while_true_spec.cr @@ -18,7 +18,7 @@ module Ameba::Rule::Style source = expect_issue subject, <<-CRYSTAL a = 1 while true - # ^^^^^^^^ error: While statement using true literal as condition + # ^^^^^^^^ error: While statement using `true` literal as condition a += 1 break if a > 5 end diff --git a/src/ameba/rule/lint/hash_duplicated_key.cr b/src/ameba/rule/lint/hash_duplicated_key.cr index 3843a9c11..244f46e8b 100644 --- a/src/ameba/rule/lint/hash_duplicated_key.cr +++ b/src/ameba/rule/lint/hash_duplicated_key.cr @@ -30,7 +30,7 @@ module Ameba::Rule::Lint def test(source, node : Crystal::HashLiteral) return if (keys = duplicated_keys(node.entries)).empty? - issue_for node, MSG % keys.join(", ") + issue_for node, MSG % keys.map { |key| "`#{key}`" }.join(", ") end private def duplicated_keys(entries) diff --git a/src/ameba/rule/lint/percent_arrays.cr b/src/ameba/rule/lint/percent_arrays.cr index d47aa7951..acf353a22 100644 --- a/src/ameba/rule/lint/percent_arrays.cr +++ b/src/ameba/rule/lint/percent_arrays.cr @@ -32,7 +32,7 @@ module Ameba::Rule::Lint symbol_array_unwanted_symbols %(,:) end - MSG = "Symbols `%s` may be unwanted in %s array literals" + MSG = "Symbols `%s` may be unwanted in `%s` array literals" def test(source) issue = start_token = nil diff --git a/src/ameba/rule/lint/rand_zero.cr b/src/ameba/rule/lint/rand_zero.cr index 9902c744e..32f92bb01 100644 --- a/src/ameba/rule/lint/rand_zero.cr +++ b/src/ameba/rule/lint/rand_zero.cr @@ -28,7 +28,7 @@ module Ameba::Rule::Lint description "Disallows rand zero calls" end - MSG = "%s always returns 0" + MSG = "`%s` always returns `0`" def test(source, node : Crystal::Call) return unless node.name == "rand" && diff --git a/src/ameba/rule/lint/shadowed_exception.cr b/src/ameba/rule/lint/shadowed_exception.cr index b9054aaf5..0a65c4ebb 100644 --- a/src/ameba/rule/lint/shadowed_exception.cr +++ b/src/ameba/rule/lint/shadowed_exception.cr @@ -39,7 +39,7 @@ module Ameba::Rule::Lint description "Disallows rescued exception that get shadowed" end - MSG = "Shadowed exception found: %s" + MSG = "Shadowed exception found: `%s`" def test(source, node : Crystal::ExceptionHandler) rescues = node.rescues diff --git a/src/ameba/rule/lint/spec_filename.cr b/src/ameba/rule/lint/spec_filename.cr index 16316d21f..42e03c08a 100644 --- a/src/ameba/rule/lint/spec_filename.cr +++ b/src/ameba/rule/lint/spec_filename.cr @@ -19,7 +19,7 @@ module Ameba::Rule::Lint ignored_filenames %w[spec_helper] end - MSG = "Spec filename should have `_spec` suffix: %s.cr, not %s.cr" + MSG = "Spec filename should have `_spec` suffix: `%s.cr`, not `%s.cr`" private LOCATION = {1, 1} diff --git a/src/ameba/rule/lint/typos.cr b/src/ameba/rule/lint/typos.cr index 9cbb94dd4..20bdd3866 100644 --- a/src/ameba/rule/lint/typos.cr +++ b/src/ameba/rule/lint/typos.cr @@ -21,7 +21,7 @@ module Ameba::Rule::Lint fail_on_error false end - MSG = "Typo found: %s -> %s" + MSG = "Typo found: `%s` -> `%s`" BIN_PATH = Process.find_executable("typos") rescue nil diff --git a/src/ameba/rule/naming/accessor_method_name.cr b/src/ameba/rule/naming/accessor_method_name.cr index b9ad2daf7..b290d86cf 100644 --- a/src/ameba/rule/naming/accessor_method_name.cr +++ b/src/ameba/rule/naming/accessor_method_name.cr @@ -41,7 +41,7 @@ module Ameba::Rule::Naming description "Makes sure that accessor methods are named properly" end - MSG = "Favour method name '%s' over '%s'" + MSG = "Favour method name `%s` over `%s`" def test(source, node : Crystal::ClassDef | Crystal::ModuleDef) each_def_node(node) do |def_node| diff --git a/src/ameba/rule/naming/constant_names.cr b/src/ameba/rule/naming/constant_names.cr index 5995fe4c5..464cbacb4 100644 --- a/src/ameba/rule/naming/constant_names.cr +++ b/src/ameba/rule/naming/constant_names.cr @@ -27,7 +27,7 @@ module Ameba::Rule::Naming description "Enforces constant names to be in screaming case" end - MSG = "Constant name should be screaming-cased: %s, not %s" + MSG = "Constant name should be screaming-cased: `%s`, not `%s`" def test(source, node : Crystal::Assign) return unless (target = node.target).is_a?(Crystal::Path) diff --git a/src/ameba/rule/naming/filename.cr b/src/ameba/rule/naming/filename.cr index 0351221e1..6ddf89d83 100644 --- a/src/ameba/rule/naming/filename.cr +++ b/src/ameba/rule/naming/filename.cr @@ -13,7 +13,7 @@ module Ameba::Rule::Naming description "Enforces file names to be in underscored case" end - MSG = "Filename should be underscore-cased: %s, not %s" + MSG = "Filename should be underscore-cased: `%s`, not `%s`" private LOCATION = {1, 1} diff --git a/src/ameba/rule/naming/method_names.cr b/src/ameba/rule/naming/method_names.cr index a90a8606a..6f94fc866 100644 --- a/src/ameba/rule/naming/method_names.cr +++ b/src/ameba/rule/naming/method_names.cr @@ -43,7 +43,7 @@ module Ameba::Rule::Naming description "Enforces method names to be in underscored case" end - MSG = "Method name should be underscore-cased: %s, not %s" + MSG = "Method name should be underscore-cased: `%s`, not `%s`" def test(source, node : Crystal::Def) name = node.name.to_s diff --git a/src/ameba/rule/naming/predicate_name.cr b/src/ameba/rule/naming/predicate_name.cr index c69af0c9f..5f1f90090 100644 --- a/src/ameba/rule/naming/predicate_name.cr +++ b/src/ameba/rule/naming/predicate_name.cr @@ -29,7 +29,7 @@ module Ameba::Rule::Naming description "Disallows tautological predicate names" end - MSG = "Favour method name '%s?' over '%s'" + MSG = "Favour method name `%s?` over `%s`" def test(source, node : Crystal::Def) return unless node.name =~ /^is_([a-z]\w*)\??$/ diff --git a/src/ameba/rule/naming/query_bool_methods.cr b/src/ameba/rule/naming/query_bool_methods.cr index b253f748f..707950885 100644 --- a/src/ameba/rule/naming/query_bool_methods.cr +++ b/src/ameba/rule/naming/query_bool_methods.cr @@ -34,7 +34,7 @@ module Ameba::Rule::Naming description "Reports boolean properties without the `?` suffix" end - MSG = "Consider using '%s?' for '%s'" + MSG = "Consider using `%s?` for `%s`" CALL_NAMES = %w[getter class_getter property class_property] diff --git a/src/ameba/rule/naming/type_names.cr b/src/ameba/rule/naming/type_names.cr index bdfb3d624..bdc7f9674 100644 --- a/src/ameba/rule/naming/type_names.cr +++ b/src/ameba/rule/naming/type_names.cr @@ -57,7 +57,7 @@ module Ameba::Rule::Naming description "Enforces type names in camelcase manner" end - MSG = "Type name should be camelcased: %s, but it was %s" + MSG = "Type name should be camelcased: `%s`, not `%s`" def test(source, node : Crystal::Alias | Crystal::ClassDef | Crystal::ModuleDef | Crystal::LibDef | Crystal::EnumDef) name = node.name.to_s diff --git a/src/ameba/rule/naming/variable_names.cr b/src/ameba/rule/naming/variable_names.cr index a35eb448b..10d5c5019 100644 --- a/src/ameba/rule/naming/variable_names.cr +++ b/src/ameba/rule/naming/variable_names.cr @@ -28,7 +28,7 @@ module Ameba::Rule::Naming description "Enforces variable names to be in underscored case" end - MSG = "Var name should be underscore-cased: %s, not %s" + MSG = "Variable name should be underscore-cased: `%s`, not `%s`" def test(source : Source) VarVisitor.new self, source diff --git a/src/ameba/rule/style/large_numbers.cr b/src/ameba/rule/style/large_numbers.cr index db51857e4..ec521ec7b 100644 --- a/src/ameba/rule/style/large_numbers.cr +++ b/src/ameba/rule/style/large_numbers.cr @@ -34,7 +34,7 @@ module Ameba::Rule::Style int_min_digits 6 end - MSG = "Large numbers should be written with underscores: %s" + MSG = "Large numbers should be written with underscores: `%s`" def test(source) Tokenizer.new(source).run do |token| diff --git a/src/ameba/rule/style/unless_else.cr b/src/ameba/rule/style/unless_else.cr index 97d677030..9ab18b26a 100644 --- a/src/ameba/rule/style/unless_else.cr +++ b/src/ameba/rule/style/unless_else.cr @@ -48,7 +48,7 @@ module Ameba::Rule::Style description "Disallows the use of an `else` block with the `unless`" end - MSG = "Favour if over unless with else" + MSG = "Favour `if` over `unless` with `else`" def test(source, node : Crystal::Unless) return if node.else.nop? diff --git a/src/ameba/rule/style/while_true.cr b/src/ameba/rule/style/while_true.cr index 60a8359f9..c6a2b173b 100644 --- a/src/ameba/rule/style/while_true.cr +++ b/src/ameba/rule/style/while_true.cr @@ -31,7 +31,7 @@ module Ameba::Rule::Style description "Disallows while statements with a true literal as condition" end - MSG = "While statement using true literal as condition" + MSG = "While statement using `true` literal as condition" def test(source, node : Crystal::While) return unless node.cond.true_literal?