mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Misc cleanups/refactors
This commit is contained in:
parent
547fec5a94
commit
f3f1f3a2ab
22 changed files with 49 additions and 46 deletions
|
@ -4,16 +4,16 @@ module Ameba
|
|||
subject = Rule::Lint::EmptyExpression.new
|
||||
|
||||
private def it_detects_empty_expression(code, *, file = __FILE__, line = __LINE__)
|
||||
it %(detects empty expression "#{code}"), file, line do
|
||||
s = Source.new code
|
||||
it "detects empty expression #{code.inspect}", file, line do
|
||||
source = Source.new code
|
||||
rule = Rule::Lint::EmptyExpression.new
|
||||
rule.catch(s).should_not be_valid, file: file, line: line
|
||||
rule.catch(source).should_not be_valid, file: file, line: line
|
||||
end
|
||||
end
|
||||
|
||||
describe Rule::Lint::EmptyExpression do
|
||||
it "passes if there is no empty expression" do
|
||||
s = Source.new <<-CRYSTAL
|
||||
expect_no_issues subject, <<-CRYSTAL
|
||||
def method()
|
||||
end
|
||||
|
||||
|
@ -31,7 +31,6 @@ module Ameba
|
|||
begin "" end
|
||||
[nil] << nil
|
||||
CRYSTAL
|
||||
subject.catch(s).should be_valid
|
||||
end
|
||||
|
||||
it_detects_empty_expression %(())
|
||||
|
@ -91,10 +90,10 @@ module Ameba
|
|||
)
|
||||
|
||||
it "does not report empty expression in macro" do
|
||||
s = Source.new %q(
|
||||
expect_no_issues subject, <<-CRYSTAL
|
||||
module MyModule
|
||||
macro conditional_error_for_inline_callbacks
|
||||
\{%
|
||||
\\{%
|
||||
raise ""
|
||||
%}
|
||||
end
|
||||
|
@ -102,8 +101,7 @@ module Ameba
|
|||
macro before_save(x = nil)
|
||||
end
|
||||
end
|
||||
)
|
||||
subject.catch(s).should be_valid
|
||||
CRYSTAL
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,12 +19,15 @@ module Ameba::Rule::Lint
|
|||
# ^^^^^^^^^ error: Typo found: arugments -> arguments
|
||||
def tpos
|
||||
# ^^^^ error: Typo found: tpos -> typos
|
||||
:otput
|
||||
# ^^^^^ error: Typo found: otput -> output
|
||||
end
|
||||
CRYSTAL
|
||||
|
||||
expect_correction source, <<-CRYSTAL
|
||||
# method with no arguments
|
||||
def typos
|
||||
:output
|
||||
end
|
||||
CRYSTAL
|
||||
end
|
||||
|
|
|
@ -123,7 +123,7 @@ module Ameba
|
|||
it "#int_min_digits" do
|
||||
rule = Rule::Style::LargeNumbers.new
|
||||
rule.int_min_digits = 10
|
||||
expect_no_issues rule, %q(1200000)
|
||||
expect_no_issues rule, "1200000"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue