Skip to content

Commit

Permalink
spec: fix ameba linter
Browse files Browse the repository at this point in the history
  • Loading branch information
icyleaf committed May 23, 2024
1 parent 8aba327 commit 897ed6f
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 10 deletions.
28 changes: 28 additions & 0 deletions .ameba.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Metrics/CyclomaticComplexity:
Excluded:
- spec/**/*
- src/markd/utils.cr
- src/markd/rules/heading.cr
- src/markd/rules/list.cr
- src/markd/parsers/inline.cr
- src/markd/parsers/block.cr
- src/markd/renderer.cr

Naming/QueryBoolMethods:
Enabled: false

Naming/BlockParameterName:
Enabled: false

Style/UnlessElse:
Enabled: false

Style/ParenthesesAroundCondition:
Enabled: false

Style/NegatedConditionsInUnless:
Enabled: false

Lint/NotNil:
Excluded:
- src/markd/parsers/inline.cr
3 changes: 0 additions & 3 deletions spec/spec_helper.cr
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ def assert_example(file, section, index, example, smart, gfm = false)
end

def extract_spec_tests(file)
data = [] of String
delimiter = "`" * 32

examples = {} of String => Hash(Int32, Hash(String, String))

current_section = 0
Expand Down
2 changes: 1 addition & 1 deletion src/markd/node.cr
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ module Markd
end
elsif current == @root
@current = nil
elsif nxt = current.next?
elsif current.next?
@current = current.next?
@entering = true
else
Expand Down
7 changes: 4 additions & 3 deletions src/markd/parsers/inline.cr
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ module Markd::Parser
}
end

return @pos - startpos
@pos - startpos
end

private def space_at_end_of_line?
Expand All @@ -765,7 +765,8 @@ module Markd::Parser
else
return false
end
return true

true
end

# Parse zero or more space characters, including at most one newline
Expand All @@ -781,7 +782,7 @@ module Markd::Parser
@pos += 1
end

return true
true
end

private def match(regex : Regex) : String?
Expand Down
2 changes: 1 addition & 1 deletion src/markd/renderers/html_renderer.cr
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ module Markd
@last_output = ">"
end

private def tag(name : String, attrs = nil)
private def tag(name : String, attrs = nil, &)
tag(name, attrs)
yield
tag(name, end_tag: true)
Expand Down
4 changes: 2 additions & 2 deletions src/markd/utils.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ require "json"

module Markd
module Utils
def self.timer(label : String, measure_time? : Bool)
def self.timer(label : String, measure_time? : Bool, &)
return yield unless measure_time?

start_time = Time.utc
Expand All @@ -14,7 +14,7 @@ module Markd
DECODE_ENTITIES_REGEX = Regex.new("\\\\" + Rule::ESCAPABLE_STRING, Regex::Options::IGNORE_CASE)

def self.decode_entities_string(text : String) : String
HTML.decode_entities(text).gsub(DECODE_ENTITIES_REGEX) { |text| text[1].to_s }
HTML.decode_entities(text).gsub(DECODE_ENTITIES_REGEX, &.[1].to_s)
end
end
end

0 comments on commit 897ed6f

Please sign in to comment.