Skip to content

Commit

Permalink
Merge pull request #529 from crystal-ameba/markdownify-issue-messages
Browse files Browse the repository at this point in the history
Make issue messages moar Markdown-friendly
  • Loading branch information
Sija authored Dec 7, 2024
2 parents b96acc1 + 5034b2c commit b8310b4
Show file tree
Hide file tree
Showing 34 changed files with 80 additions and 80 deletions.
6 changes: 3 additions & 3 deletions spec/ameba/rule/lint/hash_duplicated_key_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions spec/ameba/rule/lint/percent_arrays_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions spec/ameba/rule/lint/rand_zero_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 21 additions & 21 deletions spec/ameba/rule/lint/shadowed_exception_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/ameba/rule/lint/spec_filename_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions spec/ameba/rule/lint/typos_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 6 additions & 6 deletions spec/ameba/rule/naming/accessor_method_name_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/ameba/rule/naming/constant_names_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/ameba/rule/naming/filename_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/ameba/rule/naming/method_names_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/ameba/rule/naming/predicate_name_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions spec/ameba/rule/naming/query_bool_methods_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/ameba/rule/naming/type_names_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit b8310b4

Please sign in to comment.