mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Fix specs on Crystal nightly (soon to be v1.7.0)
This commit is contained in:
parent
a091af14a8
commit
d31e41b8a7
10 changed files with 21 additions and 21 deletions
|
@ -17,7 +17,7 @@ module Ameba::Rule::Lint
|
|||
require "big"
|
||||
require "math"
|
||||
require "big"
|
||||
# ^{} error: Duplicated require of `big`
|
||||
# ^^^^^^^^^^^ error: Duplicated require of `big`
|
||||
CRYSTAL
|
||||
|
||||
expect_no_corrections source
|
||||
|
|
|
@ -77,7 +77,7 @@ module Ameba::Rule::Lint
|
|||
issue = s.issues.first
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:2:19"
|
||||
issue.end_location.to_s.should eq "source.cr:2:29"
|
||||
issue.end_location.to_s.should eq "source.cr:2:28"
|
||||
issue.message.should eq "Remove redundant with_index"
|
||||
end
|
||||
end
|
||||
|
@ -155,7 +155,7 @@ module Ameba::Rule::Lint
|
|||
issue = s.issues.first
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:2:14"
|
||||
issue.end_location.to_s.should eq "source.cr:2:29"
|
||||
issue.end_location.to_s.should eq "source.cr:2:28"
|
||||
issue.message.should eq "Use each instead of each_with_index"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -76,7 +76,7 @@ module Ameba::Rule::Lint
|
|||
issue = s.issues.first
|
||||
issue.rule.should_not be_nil
|
||||
issue.location.to_s.should eq "source.cr:2:14"
|
||||
issue.end_location.to_s.should eq "source.cr:2:30"
|
||||
issue.end_location.to_s.should eq "source.cr:2:29"
|
||||
issue.message.should eq "Use `each` instead of `each_with_object`"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ module Ameba::Rule::Performance
|
|||
it "reports if there is select followed by any? without a block" do
|
||||
source = expect_issue subject, <<-CRYSTAL
|
||||
[1, 2, 3].select { |e| e > 2 }.any?
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `any? {...}` instead of `select {...}.any?`
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `any? {...}` instead of `select {...}.any?`
|
||||
CRYSTAL
|
||||
|
||||
expect_no_corrections source
|
||||
|
@ -32,7 +32,7 @@ module Ameba::Rule::Performance
|
|||
it "reports if there is reject followed by any? without a block" do
|
||||
source = expect_issue subject, <<-CRYSTAL
|
||||
[1, 2, 3].reject { |e| e > 2 }.any?
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `any? {...}` instead of `reject {...}.any?`
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `any? {...}` instead of `reject {...}.any?`
|
||||
CRYSTAL
|
||||
|
||||
expect_no_corrections source
|
||||
|
@ -60,7 +60,7 @@ module Ameba::Rule::Performance
|
|||
it "reports in macro scope" do
|
||||
source = expect_issue subject, <<-CRYSTAL
|
||||
{{ [1, 2, 3].reject { |e| e > 2 }.any? }}
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `any? {...}` instead of `reject {...}.any?`
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `any? {...}` instead of `reject {...}.any?`
|
||||
CRYSTAL
|
||||
|
||||
expect_no_corrections source
|
||||
|
|
|
@ -19,7 +19,7 @@ module Ameba::Rule::Performance
|
|||
it "reports if there is map followed by compact call" do
|
||||
expect_issue subject, <<-CRYSTAL
|
||||
(1..3).map(&.itself).compact
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^ error: Use `compact_map {...}` instead of `map {...}.compact`
|
||||
# ^^^^^^^^^^^^^^^^^^^^^ error: Use `compact_map {...}` instead of `map {...}.compact`
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ module Ameba::Rule::Performance
|
|||
it "reports if there is select followed by last" do
|
||||
expect_issue subject, <<-CRYSTAL
|
||||
[1, 2, 3].select { |e| e > 2 }.last
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `reverse_each.find {...}` instead of `select {...}.last`
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `reverse_each.find {...}` instead of `select {...}.last`
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
|
@ -30,14 +30,14 @@ module Ameba::Rule::Performance
|
|||
it "reports if there is select followed by last?" do
|
||||
expect_issue subject, <<-CRYSTAL
|
||||
[1, 2, 3].select { |e| e > 2 }.last?
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `reverse_each.find {...}` instead of `select {...}.last?`
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `reverse_each.find {...}` instead of `select {...}.last?`
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
it "reports if there is select followed by first" do
|
||||
expect_issue subject, <<-CRYSTAL
|
||||
[1, 2, 3].select { |e| e > 2 }.first
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `find {...}` instead of `select {...}.first`
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `find {...}` instead of `select {...}.first`
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
|
@ -50,7 +50,7 @@ module Ameba::Rule::Performance
|
|||
it "reports if there is select followed by first?" do
|
||||
expect_issue subject, <<-CRYSTAL
|
||||
[1, 2, 3].select { |e| e > 2 }.first?
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `find {...}` instead of `select {...}.first?`
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `find {...}` instead of `select {...}.first?`
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ module Ameba::Rule::Performance
|
|||
it "reports if there is map followed by flatten call" do
|
||||
expect_issue subject, <<-CRYSTAL
|
||||
%w[Alice Bob].map(&.chars).flatten
|
||||
# ^^^^^^^^^^^^^^^^^^^^^ error: Use `flat_map {...}` instead of `map {...}.flatten`
|
||||
# ^^^^^^^^^^^^^^^^^^^^ error: Use `flat_map {...}` instead of `map {...}.flatten`
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ module Ameba::Rule::Performance
|
|||
it "reports if there is map followed by sum without a block" do
|
||||
expect_issue subject, <<-CRYSTAL
|
||||
(1..3).map(&.to_u64).sum
|
||||
# ^^^^^^^^^^^^^^^^^^ error: Use `sum {...}` instead of `map {...}.sum`
|
||||
# ^^^^^^^^^^^^^^^^^ error: Use `sum {...}` instead of `map {...}.sum`
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
|
@ -27,14 +27,14 @@ module Ameba::Rule::Performance
|
|||
it "reports if there is map followed by sum without a block (with argument)" do
|
||||
expect_issue subject, <<-CRYSTAL
|
||||
(1..3).map(&.to_u64).sum(0)
|
||||
# ^^^^^^^^^^^^^^^^^^ error: Use `sum {...}` instead of `map {...}.sum`
|
||||
# ^^^^^^^^^^^^^^^^^ error: Use `sum {...}` instead of `map {...}.sum`
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
it "reports if there is map followed by sum with a block" do
|
||||
expect_issue subject, <<-CRYSTAL
|
||||
(1..3).map(&.to_u64).sum(&.itself)
|
||||
# ^^^^^^^^^^^^^^^^^^ error: Use `sum {...}` instead of `map {...}.sum`
|
||||
# ^^^^^^^^^^^^^^^^^ error: Use `sum {...}` instead of `map {...}.sum`
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ module Ameba::Rule::Performance
|
|||
it "reports if there is a select followed by size" do
|
||||
expect_issue subject, <<-CRYSTAL
|
||||
[1, 2, 3].select { |e| e > 2 }.size
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `count {...}` instead of `select {...}.size`.
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `count {...}` instead of `select {...}.size`.
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
|
@ -32,14 +32,14 @@ module Ameba::Rule::Performance
|
|||
it "reports if there is a reject followed by size" do
|
||||
expect_issue subject, <<-CRYSTAL
|
||||
[1, 2, 3].reject { |e| e < 2 }.size
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `count {...}` instead of `reject {...}.size`.
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `count {...}` instead of `reject {...}.size`.
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
it "reports if a block shorthand used" do
|
||||
expect_issue subject, <<-CRYSTAL
|
||||
[1, 2, 3].reject(&.empty?).size
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^ error: Use `count {...}` instead of `reject {...}.size`.
|
||||
# ^^^^^^^^^^^^^^^^^^^^^ error: Use `count {...}` instead of `reject {...}.size`.
|
||||
CRYSTAL
|
||||
end
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ module Ameba::Rule::Style
|
|||
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::Style
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue