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 "big"
|
||||||
require "math"
|
require "math"
|
||||||
require "big"
|
require "big"
|
||||||
# ^{} error: Duplicated require of `big`
|
# ^^^^^^^^^^^ error: Duplicated require of `big`
|
||||||
CRYSTAL
|
CRYSTAL
|
||||||
|
|
||||||
expect_no_corrections source
|
expect_no_corrections source
|
||||||
|
|
|
@ -77,7 +77,7 @@ module Ameba::Rule::Lint
|
||||||
issue = s.issues.first
|
issue = s.issues.first
|
||||||
issue.rule.should_not be_nil
|
issue.rule.should_not be_nil
|
||||||
issue.location.to_s.should eq "source.cr:2:19"
|
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"
|
issue.message.should eq "Remove redundant with_index"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -155,7 +155,7 @@ module Ameba::Rule::Lint
|
||||||
issue = s.issues.first
|
issue = s.issues.first
|
||||||
issue.rule.should_not be_nil
|
issue.rule.should_not be_nil
|
||||||
issue.location.to_s.should eq "source.cr:2:14"
|
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"
|
issue.message.should eq "Use each instead of each_with_index"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -76,7 +76,7 @@ module Ameba::Rule::Lint
|
||||||
issue = s.issues.first
|
issue = s.issues.first
|
||||||
issue.rule.should_not be_nil
|
issue.rule.should_not be_nil
|
||||||
issue.location.to_s.should eq "source.cr:2:14"
|
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`"
|
issue.message.should eq "Use `each` instead of `each_with_object`"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,7 @@ module Ameba::Rule::Performance
|
||||||
it "reports if there is select followed by any? without a block" do
|
it "reports if there is select followed by any? without a block" do
|
||||||
source = expect_issue subject, <<-CRYSTAL
|
source = expect_issue subject, <<-CRYSTAL
|
||||||
[1, 2, 3].select { |e| e > 2 }.any?
|
[1, 2, 3].select { |e| e > 2 }.any?
|
||||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `any? {...}` instead of `select {...}.any?`
|
# ^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `any? {...}` instead of `select {...}.any?`
|
||||||
CRYSTAL
|
CRYSTAL
|
||||||
|
|
||||||
expect_no_corrections source
|
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
|
it "reports if there is reject followed by any? without a block" do
|
||||||
source = expect_issue subject, <<-CRYSTAL
|
source = expect_issue subject, <<-CRYSTAL
|
||||||
[1, 2, 3].reject { |e| e > 2 }.any?
|
[1, 2, 3].reject { |e| e > 2 }.any?
|
||||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `any? {...}` instead of `reject {...}.any?`
|
# ^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `any? {...}` instead of `reject {...}.any?`
|
||||||
CRYSTAL
|
CRYSTAL
|
||||||
|
|
||||||
expect_no_corrections source
|
expect_no_corrections source
|
||||||
|
@ -60,7 +60,7 @@ module Ameba::Rule::Performance
|
||||||
it "reports in macro scope" do
|
it "reports in macro scope" do
|
||||||
source = expect_issue subject, <<-CRYSTAL
|
source = expect_issue subject, <<-CRYSTAL
|
||||||
{{ [1, 2, 3].reject { |e| e > 2 }.any? }}
|
{{ [1, 2, 3].reject { |e| e > 2 }.any? }}
|
||||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `any? {...}` instead of `reject {...}.any?`
|
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `any? {...}` instead of `reject {...}.any?`
|
||||||
CRYSTAL
|
CRYSTAL
|
||||||
|
|
||||||
expect_no_corrections source
|
expect_no_corrections source
|
||||||
|
|
|
@ -19,7 +19,7 @@ module Ameba::Rule::Performance
|
||||||
it "reports if there is map followed by compact call" do
|
it "reports if there is map followed by compact call" do
|
||||||
expect_issue subject, <<-CRYSTAL
|
expect_issue subject, <<-CRYSTAL
|
||||||
(1..3).map(&.itself).compact
|
(1..3).map(&.itself).compact
|
||||||
# ^^^^^^^^^^^^^^^^^^^^^^ error: Use `compact_map {...}` instead of `map {...}.compact`
|
# ^^^^^^^^^^^^^^^^^^^^^ error: Use `compact_map {...}` instead of `map {...}.compact`
|
||||||
CRYSTAL
|
CRYSTAL
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ module Ameba::Rule::Performance
|
||||||
it "reports if there is select followed by last" do
|
it "reports if there is select followed by last" do
|
||||||
expect_issue subject, <<-CRYSTAL
|
expect_issue subject, <<-CRYSTAL
|
||||||
[1, 2, 3].select { |e| e > 2 }.last
|
[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
|
CRYSTAL
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -30,14 +30,14 @@ module Ameba::Rule::Performance
|
||||||
it "reports if there is select followed by last?" do
|
it "reports if there is select followed by last?" do
|
||||||
expect_issue subject, <<-CRYSTAL
|
expect_issue subject, <<-CRYSTAL
|
||||||
[1, 2, 3].select { |e| e > 2 }.last?
|
[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
|
CRYSTAL
|
||||||
end
|
end
|
||||||
|
|
||||||
it "reports if there is select followed by first" do
|
it "reports if there is select followed by first" do
|
||||||
expect_issue subject, <<-CRYSTAL
|
expect_issue subject, <<-CRYSTAL
|
||||||
[1, 2, 3].select { |e| e > 2 }.first
|
[1, 2, 3].select { |e| e > 2 }.first
|
||||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `find {...}` instead of `select {...}.first`
|
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `find {...}` instead of `select {...}.first`
|
||||||
CRYSTAL
|
CRYSTAL
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ module Ameba::Rule::Performance
|
||||||
it "reports if there is select followed by first?" do
|
it "reports if there is select followed by first?" do
|
||||||
expect_issue subject, <<-CRYSTAL
|
expect_issue subject, <<-CRYSTAL
|
||||||
[1, 2, 3].select { |e| e > 2 }.first?
|
[1, 2, 3].select { |e| e > 2 }.first?
|
||||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `find {...}` instead of `select {...}.first?`
|
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `find {...}` instead of `select {...}.first?`
|
||||||
CRYSTAL
|
CRYSTAL
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ module Ameba::Rule::Performance
|
||||||
it "reports if there is map followed by flatten call" do
|
it "reports if there is map followed by flatten call" do
|
||||||
expect_issue subject, <<-CRYSTAL
|
expect_issue subject, <<-CRYSTAL
|
||||||
%w[Alice Bob].map(&.chars).flatten
|
%w[Alice Bob].map(&.chars).flatten
|
||||||
# ^^^^^^^^^^^^^^^^^^^^^ error: Use `flat_map {...}` instead of `map {...}.flatten`
|
# ^^^^^^^^^^^^^^^^^^^^ error: Use `flat_map {...}` instead of `map {...}.flatten`
|
||||||
CRYSTAL
|
CRYSTAL
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ module Ameba::Rule::Performance
|
||||||
it "reports if there is map followed by sum without a block" do
|
it "reports if there is map followed by sum without a block" do
|
||||||
expect_issue subject, <<-CRYSTAL
|
expect_issue subject, <<-CRYSTAL
|
||||||
(1..3).map(&.to_u64).sum
|
(1..3).map(&.to_u64).sum
|
||||||
# ^^^^^^^^^^^^^^^^^^ error: Use `sum {...}` instead of `map {...}.sum`
|
# ^^^^^^^^^^^^^^^^^ error: Use `sum {...}` instead of `map {...}.sum`
|
||||||
CRYSTAL
|
CRYSTAL
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -27,14 +27,14 @@ module Ameba::Rule::Performance
|
||||||
it "reports if there is map followed by sum without a block (with argument)" do
|
it "reports if there is map followed by sum without a block (with argument)" do
|
||||||
expect_issue subject, <<-CRYSTAL
|
expect_issue subject, <<-CRYSTAL
|
||||||
(1..3).map(&.to_u64).sum(0)
|
(1..3).map(&.to_u64).sum(0)
|
||||||
# ^^^^^^^^^^^^^^^^^^ error: Use `sum {...}` instead of `map {...}.sum`
|
# ^^^^^^^^^^^^^^^^^ error: Use `sum {...}` instead of `map {...}.sum`
|
||||||
CRYSTAL
|
CRYSTAL
|
||||||
end
|
end
|
||||||
|
|
||||||
it "reports if there is map followed by sum with a block" do
|
it "reports if there is map followed by sum with a block" do
|
||||||
expect_issue subject, <<-CRYSTAL
|
expect_issue subject, <<-CRYSTAL
|
||||||
(1..3).map(&.to_u64).sum(&.itself)
|
(1..3).map(&.to_u64).sum(&.itself)
|
||||||
# ^^^^^^^^^^^^^^^^^^ error: Use `sum {...}` instead of `map {...}.sum`
|
# ^^^^^^^^^^^^^^^^^ error: Use `sum {...}` instead of `map {...}.sum`
|
||||||
CRYSTAL
|
CRYSTAL
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ module Ameba::Rule::Performance
|
||||||
it "reports if there is a select followed by size" do
|
it "reports if there is a select followed by size" do
|
||||||
expect_issue subject, <<-CRYSTAL
|
expect_issue subject, <<-CRYSTAL
|
||||||
[1, 2, 3].select { |e| e > 2 }.size
|
[1, 2, 3].select { |e| e > 2 }.size
|
||||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `count {...}` instead of `select {...}.size`.
|
# ^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `count {...}` instead of `select {...}.size`.
|
||||||
CRYSTAL
|
CRYSTAL
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,14 +32,14 @@ module Ameba::Rule::Performance
|
||||||
it "reports if there is a reject followed by size" do
|
it "reports if there is a reject followed by size" do
|
||||||
expect_issue subject, <<-CRYSTAL
|
expect_issue subject, <<-CRYSTAL
|
||||||
[1, 2, 3].reject { |e| e < 2 }.size
|
[1, 2, 3].reject { |e| e < 2 }.size
|
||||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `count {...}` instead of `reject {...}.size`.
|
# ^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `count {...}` instead of `reject {...}.size`.
|
||||||
CRYSTAL
|
CRYSTAL
|
||||||
end
|
end
|
||||||
|
|
||||||
it "reports if a block shorthand used" do
|
it "reports if a block shorthand used" do
|
||||||
expect_issue subject, <<-CRYSTAL
|
expect_issue subject, <<-CRYSTAL
|
||||||
[1, 2, 3].reject(&.empty?).size
|
[1, 2, 3].reject(&.empty?).size
|
||||||
# ^^^^^^^^^^^^^^^^^^^^^^ error: Use `count {...}` instead of `reject {...}.size`.
|
# ^^^^^^^^^^^^^^^^^^^^^ error: Use `count {...}` instead of `reject {...}.size`.
|
||||||
CRYSTAL
|
CRYSTAL
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ module Ameba::Rule::Style
|
||||||
expect_issue subject, <<-CRYSTAL, call: {{ call }}
|
expect_issue subject, <<-CRYSTAL, call: {{ call }}
|
||||||
class Foo
|
class Foo
|
||||||
%{call} foo : Bool = true
|
%{call} foo : Bool = true
|
||||||
_{call} # ^ error: Consider using '%{call}?' for 'foo'
|
_{call} # ^^^ error: Consider using '%{call}?' for 'foo'
|
||||||
end
|
end
|
||||||
CRYSTAL
|
CRYSTAL
|
||||||
end
|
end
|
||||||
|
@ -60,7 +60,7 @@ module Ameba::Rule::Style
|
||||||
expect_issue subject, <<-CRYSTAL, call: {{ call }}
|
expect_issue subject, <<-CRYSTAL, call: {{ call }}
|
||||||
class Foo
|
class Foo
|
||||||
%{call} foo : Bool
|
%{call} foo : Bool
|
||||||
_{call} # ^ error: Consider using '%{call}?' for 'foo'
|
_{call} # ^^^ error: Consider using '%{call}?' for 'foo'
|
||||||
|
|
||||||
def initialize(@foo = true)
|
def initialize(@foo = true)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue