From 9926f0295aba0b5669c165508ec880ca5a9005dc Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Wed, 21 Dec 2022 21:13:01 +0100 Subject: [PATCH] Remove most of the obsolete specs --- .../rule/layout/trailing_whitespace_spec.cr | 11 --------- .../rule/lint/comparison_to_boolean_spec.cr | 21 ----------------- spec/ameba/rule/lint/debug_calls_spec.cr | 11 --------- .../rule/lint/debugger_statement_spec.cr | 11 --------- .../rule/lint/duplicated_require_spec.cr | 23 ------------------- spec/ameba/rule/lint/empty_expression_spec.cr | 13 ----------- spec/ameba/rule/lint/empty_loop_spec.cr | 16 ------------- .../rule/lint/hash_duplicated_key_spec.cr | 12 ---------- .../rule/lint/literals_comparison_spec.cr | 13 ----------- .../rule/lint/not_nil_after_no_bang_spec.cr | 13 ----------- spec/ameba/rule/lint/not_nil_spec.cr | 13 ----------- spec/ameba/rule/lint/rand_zero_spec.cr | 11 --------- .../lint/shadowing_outer_local_var_spec.cr | 14 ----------- .../rule/lint/shared_var_in_fiber_spec.cr | 19 --------------- spec/ameba/rule/lint/syntax_spec.cr | 10 -------- .../lint/useless_condition_in_when_spec.cr | 17 -------------- .../rule/performance/any_after_filter_spec.cr | 9 -------- .../performance/any_instead_of_empty_spec.cr | 13 ----------- .../chained_call_with_no_bang_spec.cr | 16 ------------- .../performance/compact_after_map_spec.cr | 13 ----------- .../first_last_after_filter_spec.cr | 15 ------------ .../performance/flatten_after_map_spec.cr | 13 ----------- .../performance/map_instead_of_block_spec.cr | 13 ----------- .../performance/size_after_filter_spec.cr | 13 ----------- spec/ameba/rule/style/constant_names_spec.cr | 14 ----------- spec/ameba/rule/style/is_a_filter_spec.cr | 15 ------------ spec/ameba/rule/style/is_a_nil_spec.cr | 14 ----------- spec/ameba/rule/style/large_numbers_spec.cr | 12 ---------- spec/ameba/rule/style/method_names_spec.cr | 15 ------------ .../negated_conditions_in_unless_spec.cr | 11 --------- spec/ameba/rule/style/predicate_name_spec.cr | 18 --------------- spec/ameba/rule/style/redundant_begin_spec.cr | 19 --------------- spec/ameba/rule/style/type_names_spec.cr | 15 ------------ spec/ameba/rule/style/unless_else_spec.cr | 18 --------------- spec/ameba/rule/style/variable_names_spec.cr | 14 ----------- spec/ameba/rule/style/verbose_block_spec.cr | 15 ------------ 36 files changed, 513 deletions(-) diff --git a/spec/ameba/rule/layout/trailing_whitespace_spec.cr b/spec/ameba/rule/layout/trailing_whitespace_spec.cr index b6d9902d..9885e14f 100644 --- a/spec/ameba/rule/layout/trailing_whitespace_spec.cr +++ b/spec/ameba/rule/layout/trailing_whitespace_spec.cr @@ -15,16 +15,5 @@ module Ameba::Rule::Layout expect_correction source, "whitespace at the end" end - - it "reports rule, pos and message" do - source = Source.new "a = 1\n b = 2 ", "source.cr" - subject.catch(source).should_not be_valid - - issue = source.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:2:7" - issue.end_location.to_s.should eq "source.cr:2:7" - issue.message.should eq "Trailing whitespace detected" - end end end diff --git a/spec/ameba/rule/lint/comparison_to_boolean_spec.cr b/spec/ameba/rule/lint/comparison_to_boolean_spec.cr index e72278d8..e99eba97 100644 --- a/spec/ameba/rule/lint/comparison_to_boolean_spec.cr +++ b/spec/ameba/rule/lint/comparison_to_boolean_spec.cr @@ -94,16 +94,6 @@ module Ameba::Rule::Lint a CRYSTAL end - - it "reports rule, pos and message" do - source = Source.new "a != true", "source.cr" - subject.catch(source) - - issue = source.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:1" - issue.message.should eq "Comparison to a boolean is pointless" - end end context "boolean on the left" do @@ -165,17 +155,6 @@ module Ameba::Rule::Lint a CRYSTAL end - - it "reports rule, pos and message" do - source = Source.new "true != a", "source.cr" - subject.catch(source).should_not be_valid - - issue = source.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:1" - issue.end_location.to_s.should eq "source.cr:1:9" - issue.message.should eq "Comparison to a boolean is pointless" - end end end end diff --git a/spec/ameba/rule/lint/debug_calls_spec.cr b/spec/ameba/rule/lint/debug_calls_spec.cr index bd46aba9..ffdc90ea 100644 --- a/spec/ameba/rule/lint/debug_calls_spec.cr +++ b/spec/ameba/rule/lint/debug_calls_spec.cr @@ -28,16 +28,5 @@ module Ameba::Rule::Lint CRYSTAL end end - - it "reports rule, pos and message" do - s = Source.new "pp! :foo", "source.cr" - subject.catch(s).should_not be_valid - - issue = s.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:1" - issue.end_location.to_s.should eq "source.cr:1:8" - issue.message.should eq "Possibly forgotten debug-related `pp!` call detected" - end end end diff --git a/spec/ameba/rule/lint/debugger_statement_spec.cr b/spec/ameba/rule/lint/debugger_statement_spec.cr index 2f67e351..ad6942df 100644 --- a/spec/ameba/rule/lint/debugger_statement_spec.cr +++ b/spec/ameba/rule/lint/debugger_statement_spec.cr @@ -31,16 +31,5 @@ module Ameba::Rule::Lint expect_no_corrections source end - - it "reports rule, pos and message" do - s = Source.new "debugger", "source.cr" - subject.catch(s).should_not be_valid - - issue = s.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:1" - issue.end_location.to_s.should eq "source.cr:1:8" - issue.message.should eq "Possible forgotten debugger statement detected" - end end end diff --git a/spec/ameba/rule/lint/duplicated_require_spec.cr b/spec/ameba/rule/lint/duplicated_require_spec.cr index 14eee4d0..6967d764 100644 --- a/spec/ameba/rule/lint/duplicated_require_spec.cr +++ b/spec/ameba/rule/lint/duplicated_require_spec.cr @@ -22,28 +22,5 @@ module Ameba::Rule::Lint expect_no_corrections source end - - it "reports rule, pos and message" do - source = Source.new <<-CRYSTAL, "source.cr" - require "./thing" - require "./thing" - require "./another_thing" - require "./another_thing" - CRYSTAL - - subject.catch(source).should_not be_valid - - issue = source.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:2:1" - issue.end_location.to_s.should eq "" - issue.message.should eq "Duplicated require of `./thing`" - - issue = source.issues.last - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:4:1" - issue.end_location.to_s.should eq "" - issue.message.should eq "Duplicated require of `./another_thing`" - end end end diff --git a/spec/ameba/rule/lint/empty_expression_spec.cr b/spec/ameba/rule/lint/empty_expression_spec.cr index 7918d094..9e9bbee7 100644 --- a/spec/ameba/rule/lint/empty_expression_spec.cr +++ b/spec/ameba/rule/lint/empty_expression_spec.cr @@ -110,18 +110,5 @@ module Ameba ) subject.catch(s).should be_valid end - - it "reports rule, location and message" do - s = Source.new %( - if () - end - ), "source.cr" - subject.catch(s).should_not be_valid - issue = s.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:4" - issue.end_location.to_s.should eq "source.cr:1:5" - issue.message.should eq "Avoid empty expressions" - end end end diff --git a/spec/ameba/rule/lint/empty_loop_spec.cr b/spec/ameba/rule/lint/empty_loop_spec.cr index d2a8c21e..3d0fc0c2 100644 --- a/spec/ameba/rule/lint/empty_loop_spec.cr +++ b/spec/ameba/rule/lint/empty_loop_spec.cr @@ -64,21 +64,5 @@ module Ameba::Rule::Lint end CRYSTAL end - - it "reports rule, message and location" do - s = Source.new %( - a = 1 - loop do - # comment goes here - end - ), "source.cr" - subject.catch(s).should_not be_valid - s.issues.size.should eq 1 - issue = s.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:2:1" - issue.end_location.to_s.should eq "source.cr:4:3" - issue.message.should eq EmptyLoop::MSG - end end end diff --git a/spec/ameba/rule/lint/hash_duplicated_key_spec.cr b/spec/ameba/rule/lint/hash_duplicated_key_spec.cr index def877f7..e0093f88 100644 --- a/spec/ameba/rule/lint/hash_duplicated_key_spec.cr +++ b/spec/ameba/rule/lint/hash_duplicated_key_spec.cr @@ -32,17 +32,5 @@ module Ameba::Rule::Lint # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Duplicated keys in hash literal: "key1", "key2" CRYSTAL end - - it "reports rule, location and message" do - s = Source.new %q( - h = {"a" => 1, "a" => 2} - ), "source.cr" - subject.catch(s).should_not be_valid - issue = s.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:5" - issue.end_location.to_s.should eq "source.cr:1:24" - issue.message.should eq %(Duplicated keys in hash literal: "a") - end end end diff --git a/spec/ameba/rule/lint/literals_comparison_spec.cr b/spec/ameba/rule/lint/literals_comparison_spec.cr index 6f6c5004..c0040d91 100644 --- a/spec/ameba/rule/lint/literals_comparison_spec.cr +++ b/spec/ameba/rule/lint/literals_comparison_spec.cr @@ -58,18 +58,5 @@ module Ameba::Rule::Lint CRYSTAL end end - - it "reports rule, pos and message" do - s = Source.new %( - "foo" == "foo" - ), "source.cr" - subject.catch(s).should_not be_valid - issue = s.issues.first - - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:1" - issue.end_location.to_s.should eq "source.cr:1:14" - issue.message.should eq "Comparison always evaluates to true" - end end end diff --git a/spec/ameba/rule/lint/not_nil_after_no_bang_spec.cr b/spec/ameba/rule/lint/not_nil_after_no_bang_spec.cr index 521b79ef..954d0d7a 100644 --- a/spec/ameba/rule/lint/not_nil_after_no_bang_spec.cr +++ b/spec/ameba/rule/lint/not_nil_after_no_bang_spec.cr @@ -58,18 +58,5 @@ module Ameba::Rule::Lint CRYSTAL end end - - it "reports rule, pos and message" do - s = Source.new %( - (1..3).index(1).not_nil! - ), "source.cr" - subject.catch(s).should_not be_valid - issue = s.issues.first - - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:8" - issue.end_location.to_s.should eq "source.cr:1:24" - issue.message.should eq "Use `index! {...}` instead of `index {...}.not_nil!`" - end end end diff --git a/spec/ameba/rule/lint/not_nil_spec.cr b/spec/ameba/rule/lint/not_nil_spec.cr index 3359009e..0f5881b2 100644 --- a/spec/ameba/rule/lint/not_nil_spec.cr +++ b/spec/ameba/rule/lint/not_nil_spec.cr @@ -32,18 +32,5 @@ module Ameba::Rule::Lint CRYSTAL end end - - it "reports rule, pos and message" do - s = Source.new %( - (1..3).first?.not_nil! - ), "source.cr" - subject.catch(s).should_not be_valid - issue = s.issues.first - - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:15" - issue.end_location.to_s.should eq "source.cr:1:22" - issue.message.should eq "Avoid using `not_nil!`" - end end end diff --git a/spec/ameba/rule/lint/rand_zero_spec.cr b/spec/ameba/rule/lint/rand_zero_spec.cr index cb5cc6d4..e30e1ff8 100644 --- a/spec/ameba/rule/lint/rand_zero_spec.cr +++ b/spec/ameba/rule/lint/rand_zero_spec.cr @@ -25,16 +25,5 @@ module Ameba::Rule::Lint # ^^^^^ error: rand(1) always returns 0 CRYSTAL end - - it "reports rule, location and a message" do - s = Source.new "rand(1)", "source.cr" - subject.catch(s).should_not be_valid - issue = s.issues.first - - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:1" - issue.end_location.to_s.should eq "source.cr:1:7" - issue.message.should eq "rand(1) always returns 0" - end end end diff --git a/spec/ameba/rule/lint/shadowing_outer_local_var_spec.cr b/spec/ameba/rule/lint/shadowing_outer_local_var_spec.cr index 72340ebb..ba44bc11 100644 --- a/spec/ameba/rule/lint/shadowing_outer_local_var_spec.cr +++ b/spec/ameba/rule/lint/shadowing_outer_local_var_spec.cr @@ -157,20 +157,6 @@ module Ameba::Rule::Lint CRYSTAL end - it "reports rule, location and message" do - source = Source.new %( - foo = 1 - 3.times { |foo| foo + 1 } - ), "source.cr" - subject.catch(source).should_not be_valid - - issue = source.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:2:12" - issue.end_location.should be_nil - issue.message.should eq "Shadowing outer local variable `foo`" - end - context "macro" do it "does not report shadowed vars in outer scope" do expect_no_issues subject, <<-CRYSTAL diff --git a/spec/ameba/rule/lint/shared_var_in_fiber_spec.cr b/spec/ameba/rule/lint/shared_var_in_fiber_spec.cr index 221845c2..3381c935 100644 --- a/spec/ameba/rule/lint/shared_var_in_fiber_spec.cr +++ b/spec/ameba/rule/lint/shared_var_in_fiber_spec.cr @@ -194,24 +194,5 @@ module Ameba::Rule::Lint end CRYSTAL end - - it "reports rule, location and message" do - s = Source.new %( - i = 0 - while true - i += 1 - spawn { i } - end - ), "source.cr" - - subject.catch(s).should_not be_valid - s.issues.size.should eq 1 - - issue = s.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:4:11" - issue.end_location.to_s.should eq "source.cr:4:11" - issue.message.should eq "Shared variable `i` is used in fiber" - end end end diff --git a/spec/ameba/rule/lint/syntax_spec.cr b/spec/ameba/rule/lint/syntax_spec.cr index 107752ac..fbbe47c3 100644 --- a/spec/ameba/rule/lint/syntax_spec.cr +++ b/spec/ameba/rule/lint/syntax_spec.cr @@ -23,16 +23,6 @@ module Ameba::Rule::Lint CRYSTAL end - it "reports rule, location and message" do - s = Source.new "def hello end", "source.cr" - subject.catch(s).should_not be_valid - issue = s.issues.first - - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:11" - issue.message.should match /unexpected token: "?end"? \(expected ["'];["'] or newline\)/ - end - it "has highest severity" do subject.severity.should eq Severity::Error end diff --git a/spec/ameba/rule/lint/useless_condition_in_when_spec.cr b/spec/ameba/rule/lint/useless_condition_in_when_spec.cr index 9fffc4a9..c31e3e31 100644 --- a/spec/ameba/rule/lint/useless_condition_in_when_spec.cr +++ b/spec/ameba/rule/lint/useless_condition_in_when_spec.cr @@ -24,22 +24,5 @@ module Ameba::Rule::Lint end CRYSTAL end - - it "reports rule, location and message" do - s = Source.new %( - case - when String - puts "hello" - when can_generate? - generate if can_generate? - end - ), "source.cr" - subject.catch(s).should_not be_valid - issue = s.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:5:15" - issue.end_location.to_s.should eq "source.cr:5:27" - issue.message.should eq "Useless condition in when detected" - end end end diff --git a/spec/ameba/rule/performance/any_after_filter_spec.cr b/spec/ameba/rule/performance/any_after_filter_spec.cr index d99a6aa8..c02cb7e5 100644 --- a/spec/ameba/rule/performance/any_after_filter_spec.cr +++ b/spec/ameba/rule/performance/any_after_filter_spec.cr @@ -66,14 +66,5 @@ module Ameba::Rule::Performance expect_no_corrections source end end - - it "reports rule, pos and message" do - source = expect_issue subject, <<-CRYSTAL - [1, 2, 3].reject { |e| e > 2 }.any? - # ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Use `any? {...}` instead of `reject {...}.any?` - CRYSTAL - - expect_no_corrections source - end end end diff --git a/spec/ameba/rule/performance/any_instead_of_empty_spec.cr b/spec/ameba/rule/performance/any_instead_of_empty_spec.cr index 2b637a8f..1812c5dc 100644 --- a/spec/ameba/rule/performance/any_instead_of_empty_spec.cr +++ b/spec/ameba/rule/performance/any_instead_of_empty_spec.cr @@ -42,18 +42,5 @@ module Ameba::Rule::Performance CRYSTAL end end - - it "reports rule, pos and message" do - source = Source.new path: "source.cr", code: %( - [1, 2, 3].any? - ) - subject.catch(source).should_not be_valid - issue = source.issues.first - - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:11" - issue.end_location.to_s.should eq "source.cr:1:14" - issue.message.should eq "Use `!{...}.empty?` instead of `{...}.any?`" - end end end diff --git a/spec/ameba/rule/performance/chained_call_with_no_bang_spec.cr b/spec/ameba/rule/performance/chained_call_with_no_bang_spec.cr index 123e36bf..eaef1a8f 100644 --- a/spec/ameba/rule/performance/chained_call_with_no_bang_spec.cr +++ b/spec/ameba/rule/performance/chained_call_with_no_bang_spec.cr @@ -54,22 +54,6 @@ module Ameba::Rule::Performance end end - it "reports rule, pos and message" do - source = Source.new path: "source.cr", code: <<-CODE - [1, 2, 3].select { |e| e > 1 }.reverse - CODE - - subject.catch(source).should_not be_valid - source.issues.size.should eq 1 - - issue = source.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:32" - issue.end_location.to_s.should eq "source.cr:1:38" - - issue.message.should eq "Use bang method variant `reverse!` after chained `select` call" - end - context "macro" do it "doesn't report in macro scope" do expect_no_issues subject, <<-CRYSTAL diff --git a/spec/ameba/rule/performance/compact_after_map_spec.cr b/spec/ameba/rule/performance/compact_after_map_spec.cr index 9c7a72e3..544e2905 100644 --- a/spec/ameba/rule/performance/compact_after_map_spec.cr +++ b/spec/ameba/rule/performance/compact_after_map_spec.cr @@ -36,18 +36,5 @@ module Ameba::Rule::Performance CRYSTAL end end - - it "reports rule, pos and message" do - s = Source.new %( - (1..3).map(&.itself).compact - ), "source.cr" - subject.catch(s).should_not be_valid - issue = s.issues.first - - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:8" - issue.end_location.to_s.should eq "source.cr:1:29" - issue.message.should eq "Use `compact_map {...}` instead of `map {...}.compact`" - end end end diff --git a/spec/ameba/rule/performance/first_last_after_filter_spec.cr b/spec/ameba/rule/performance/first_last_after_filter_spec.cr index 4352c200..d3e290ee 100644 --- a/spec/ameba/rule/performance/first_last_after_filter_spec.cr +++ b/spec/ameba/rule/performance/first_last_after_filter_spec.cr @@ -72,21 +72,6 @@ module Ameba::Rule::Performance end end - it "reports rule, pos and message" do - s = Source.new %( - [1, 2, 3].select { |e| e > 2 }.first - ), "source.cr" - subject.catch(s).should_not be_valid - s.issues.size.should eq 1 - - issue = s.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:11" - issue.end_location.to_s.should eq "source.cr:1:37" - - issue.message.should eq "Use `find {...}` instead of `select {...}.first`" - end - context "macro" do it "doesn't report in macro scope" do expect_no_issues subject, <<-CRYSTAL diff --git a/spec/ameba/rule/performance/flatten_after_map_spec.cr b/spec/ameba/rule/performance/flatten_after_map_spec.cr index 54796380..a7f89193 100644 --- a/spec/ameba/rule/performance/flatten_after_map_spec.cr +++ b/spec/ameba/rule/performance/flatten_after_map_spec.cr @@ -30,18 +30,5 @@ module Ameba::Rule::Performance CRYSTAL end end - - it "reports rule, pos and message" do - s = Source.new %( - %w[Alice Bob].map(&.chars).flatten - ), "source.cr" - subject.catch(s).should_not be_valid - issue = s.issues.first - - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:15" - issue.end_location.to_s.should eq "source.cr:1:35" - issue.message.should eq "Use `flat_map {...}` instead of `map {...}.flatten`" - end end end diff --git a/spec/ameba/rule/performance/map_instead_of_block_spec.cr b/spec/ameba/rule/performance/map_instead_of_block_spec.cr index 95cfd901..b154ce48 100644 --- a/spec/ameba/rule/performance/map_instead_of_block_spec.cr +++ b/spec/ameba/rule/performance/map_instead_of_block_spec.cr @@ -45,18 +45,5 @@ module Ameba::Rule::Performance CRYSTAL end end - - it "reports rule, pos and message" do - s = Source.new %( - (1..3).map(&.to_u64).sum - ), "source.cr" - subject.catch(s).should_not be_valid - issue = s.issues.first - - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:8" - issue.end_location.to_s.should eq "source.cr:1:25" - issue.message.should eq "Use `sum {...}` instead of `map {...}.sum`" - end end end diff --git a/spec/ameba/rule/performance/size_after_filter_spec.cr b/spec/ameba/rule/performance/size_after_filter_spec.cr index fecedc5e..f00c7c8d 100644 --- a/spec/ameba/rule/performance/size_after_filter_spec.cr +++ b/spec/ameba/rule/performance/size_after_filter_spec.cr @@ -61,18 +61,5 @@ module Ameba::Rule::Performance CRYSTAL end end - - it "reports rule, pos and message" do - s = Source.new %( - lines.split("\n").reject(&.empty?).size - ), "source.cr" - subject.catch(s).should_not be_valid - issue = s.issues.first - - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:2:4" - issue.end_location.to_s.should eq "source.cr:2:25" - issue.message.should eq "Use `count {...}` instead of `reject {...}.size`." - end end end diff --git a/spec/ameba/rule/style/constant_names_spec.cr b/spec/ameba/rule/style/constant_names_spec.cr index 00267289..23048382 100644 --- a/spec/ameba/rule/style/constant_names_spec.cr +++ b/spec/ameba/rule/style/constant_names_spec.cr @@ -37,19 +37,5 @@ module Ameba # it_reports_constant "MyBadConstant", "1", "MYBADCONSTANT" it_reports_constant "Wrong_NAME", "2", "WRONG_NAME" it_reports_constant "Wrong_Name", "3", "WRONG_NAME" - - it "reports rule, pos and message" do - s = Source.new %( - Const_Name = 1 - ), "source.cr" - subject.catch(s).should_not be_valid - issue = s.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:1" - issue.end_location.to_s.should eq "source.cr:1:10" - issue.message.should eq( - "Constant name should be screaming-cased: CONST_NAME, not Const_Name" - ) - end end end diff --git a/spec/ameba/rule/style/is_a_filter_spec.cr b/spec/ameba/rule/style/is_a_filter_spec.cr index ed01d213..234c2600 100644 --- a/spec/ameba/rule/style/is_a_filter_spec.cr +++ b/spec/ameba/rule/style/is_a_filter_spec.cr @@ -59,20 +59,5 @@ module Ameba::Rule::Style CRYSTAL end end - - it "reports rule, pos and message" do - source = Source.new path: "source.cr", code: %( - [1, 2, nil].reject(&.nil?) - ) - subject.catch(source).should_not be_valid - source.issues.size.should eq 1 - - issue = source.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:13" - issue.end_location.to_s.should eq "source.cr:1:26" - - issue.message.should eq "Use `reject(Nil)` instead of `reject {...}`" - end end end diff --git a/spec/ameba/rule/style/is_a_nil_spec.cr b/spec/ameba/rule/style/is_a_nil_spec.cr index 44454cc9..8c2c7d42 100644 --- a/spec/ameba/rule/style/is_a_nil_spec.cr +++ b/spec/ameba/rule/style/is_a_nil_spec.cr @@ -34,19 +34,5 @@ module Ameba::Rule::Style a.nil? CRYSTAL end - - it "reports rule, location and message" do - s = Source.new %( - nil.is_a? Nil - ), "source.cr" - subject.catch(s).should_not be_valid - s.issues.size.should eq 1 - - issue = s.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:11" - issue.end_location.to_s.should eq "source.cr:1:13" - issue.message.should eq IsANil::MSG - end end end diff --git a/spec/ameba/rule/style/large_numbers_spec.cr b/spec/ameba/rule/style/large_numbers_spec.cr index 4682aae2..725ec158 100644 --- a/spec/ameba/rule/style/large_numbers_spec.cr +++ b/spec/ameba/rule/style/large_numbers_spec.cr @@ -117,18 +117,6 @@ module Ameba it_transforms "3.001234", "3.001_234" it_transforms "3.0012345", "3.001_234_5" - it "reports rule, pos and message" do - s = Source.new %q( - 1200000 - ), "source.cr" - subject.catch(s).should_not be_valid - issue = s.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:1" - issue.end_location.to_s.should eq "source.cr:1:7" - issue.message.should match /1_200_000/ - end - context "properties" do it "#int_min_digits" do rule = Rule::Style::LargeNumbers.new diff --git a/spec/ameba/rule/style/method_names_spec.cr b/spec/ameba/rule/style/method_names_spec.cr index 94d2608d..c9729dc4 100644 --- a/spec/ameba/rule/style/method_names_spec.cr +++ b/spec/ameba/rule/style/method_names_spec.cr @@ -38,20 +38,5 @@ module Ameba it_reports_method_name "firstName", "first_name" it_reports_method_name "date_of_Birth", "date_of_birth" it_reports_method_name "homepageURL", "homepage_url" - - it "reports rule, pos and message" do - s = Source.new %( - def bad_Name(a) - end - ), "source.cr" - subject.catch(s).should_not be_valid - issue = s.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:5" - issue.end_location.to_s.should eq "source.cr:1:12" - issue.message.should eq( - "Method name should be underscore-cased: bad_name, not bad_Name" - ) - end end end diff --git a/spec/ameba/rule/style/negated_conditions_in_unless_spec.cr b/spec/ameba/rule/style/negated_conditions_in_unless_spec.cr index 19251c54..60edb7cf 100644 --- a/spec/ameba/rule/style/negated_conditions_in_unless_spec.cr +++ b/spec/ameba/rule/style/negated_conditions_in_unless_spec.cr @@ -53,16 +53,5 @@ module Ameba::Rule::Style end CRYSTAL end - - it "reports rule, pos and message" do - s = Source.new ":nok unless !s.empty?", "source.cr" - subject.catch(s).should_not be_valid - - issue = s.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:1" - issue.end_location.to_s.should eq "source.cr:1:21" - issue.message.should eq "Avoid negated conditions in unless blocks" - end end end diff --git a/spec/ameba/rule/style/predicate_name_spec.cr b/spec/ameba/rule/style/predicate_name_spec.cr index 29acd0aa..46e37fb6 100644 --- a/spec/ameba/rule/style/predicate_name_spec.cr +++ b/spec/ameba/rule/style/predicate_name_spec.cr @@ -27,24 +27,6 @@ module Ameba::Rule::Style CRYSTAL end - it "reports rule, pos and message" do - s = Source.new %q( - class Image - def is_valid?(x) - true - end - end - ), "source.cr" - subject.catch(s).should_not be_valid - - issue = s.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:2:3" - issue.end_location.to_s.should eq "source.cr:4:5" - issue.message.should eq( - "Favour method name 'valid?' over 'is_valid?'") - end - it "ignores if alternative name isn't valid syntax" do expect_no_issues subject, <<-CRYSTAL class Image diff --git a/spec/ameba/rule/style/redundant_begin_spec.cr b/spec/ameba/rule/style/redundant_begin_spec.cr index b9bb0617..acfa2adc 100644 --- a/spec/ameba/rule/style/redundant_begin_spec.cr +++ b/spec/ameba/rule/style/redundant_begin_spec.cr @@ -294,24 +294,5 @@ module Ameba::Rule::Style } CRYSTAL end - - it "reports rule, pos and message" do - s = Source.new %q( - def method - begin - open_connection - ensure - close_connection - end - end - ), "source.cr" - subject.catch(s).should_not be_valid - - issue = s.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:2:3" - issue.end_location.to_s.should eq "source.cr:2:7" - issue.message.should eq "Redundant `begin` block detected" - end end end diff --git a/spec/ameba/rule/style/type_names_spec.cr b/spec/ameba/rule/style/type_names_spec.cr index 31abc89b..31a84d39 100644 --- a/spec/ameba/rule/style/type_names_spec.cr +++ b/spec/ameba/rule/style/type_names_spec.cr @@ -49,20 +49,5 @@ module Ameba # ^{} error: Type name should be camelcased: NumericValue, but it was Numeric_value CRYSTAL end - - it "reports rule, pos and message" do - s = Source.new %( - class My_class - end - ), "source.cr" - subject.catch(s).should_not be_valid - issue = s.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:1" - issue.end_location.to_s.should eq "source.cr:2:3" - issue.message.should eq( - "Type name should be camelcased: MyClass, but it was My_class" - ) - end end end diff --git a/spec/ameba/rule/style/unless_else_spec.cr b/spec/ameba/rule/style/unless_else_spec.cr index cf1c065d..7d9bdb7c 100644 --- a/spec/ameba/rule/style/unless_else_spec.cr +++ b/spec/ameba/rule/style/unless_else_spec.cr @@ -22,23 +22,5 @@ module Ameba::Rule::Style end CRYSTAL end - - it "reports rule, pos and message" do - s = Source.new %( - unless something - :one - else - :two - end - ), "source.cr" - subject.catch(s).should_not be_valid - - issue = s.issues.first - issue.should_not be_nil - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:1" - issue.end_location.to_s.should eq "source.cr:5:3" - issue.message.should eq "Favour if over unless with else" - end end end diff --git a/spec/ameba/rule/style/variable_names_spec.cr b/spec/ameba/rule/style/variable_names_spec.cr index 3443ddcb..7add818e 100644 --- a/spec/ameba/rule/style/variable_names_spec.cr +++ b/spec/ameba/rule/style/variable_names_spec.cr @@ -62,19 +62,5 @@ module Ameba end CRYSTAL end - - it "reports rule, pos and message" do - s = Source.new %( - badName = "Yeah" - ), "source.cr" - subject.catch(s).should_not be_valid - issue = s.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:1" - issue.end_location.to_s.should eq "source.cr:1:7" - issue.message.should eq( - "Var name should be underscore-cased: bad_name, not badName" - ) - end end end diff --git a/spec/ameba/rule/style/verbose_block_spec.cr b/spec/ameba/rule/style/verbose_block_spec.cr index b638a65c..d7851ba0 100644 --- a/spec/ameba/rule/style/verbose_block_spec.cr +++ b/spec/ameba/rule/style/verbose_block_spec.cr @@ -273,20 +273,5 @@ module Ameba::Rule::Style (1..3).join(separator: '.', &.to_s) CRYSTAL end - - it "reports rule, pos and message" do - source = Source.new path: "source.cr", code: <<-CRYSTAL - (1..3).any? { |i| i.odd? } - CRYSTAL - subject.catch(source).should_not be_valid - source.issues.size.should eq 1 - - issue = source.issues.first - issue.rule.should_not be_nil - issue.location.to_s.should eq "source.cr:1:8" - issue.end_location.to_s.should eq "source.cr:1:26" - - issue.message.should eq "Use short block notation instead: `any?(&.odd?)`" - end end end