diff --git a/.ameba.yml b/.ameba.yml new file mode 100644 index 0000000..812b3b2 --- /dev/null +++ b/.ameba.yml @@ -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 diff --git a/spec/spec_helper.cr b/spec/spec_helper.cr index 646e34e..80ffc02 100644 --- a/spec/spec_helper.cr +++ b/spec/spec_helper.cr @@ -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 diff --git a/src/markd/node.cr b/src/markd/node.cr index 1f4ee80..c43c061 100644 --- a/src/markd/node.cr +++ b/src/markd/node.cr @@ -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 diff --git a/src/markd/parsers/inline.cr b/src/markd/parsers/inline.cr index bc6da59..5f39fb9 100644 --- a/src/markd/parsers/inline.cr +++ b/src/markd/parsers/inline.cr @@ -750,7 +750,7 @@ module Markd::Parser } end - return @pos - startpos + @pos - startpos end private def space_at_end_of_line? @@ -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 @@ -781,7 +782,7 @@ module Markd::Parser @pos += 1 end - return true + true end private def match(regex : Regex) : String? diff --git a/src/markd/renderers/html_renderer.cr b/src/markd/renderers/html_renderer.cr index 4d8505b..fdaa019 100644 --- a/src/markd/renderers/html_renderer.cr +++ b/src/markd/renderers/html_renderer.cr @@ -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) diff --git a/src/markd/utils.cr b/src/markd/utils.cr index deb4066..cd15719 100644 --- a/src/markd/utils.cr +++ b/src/markd/utils.cr @@ -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 @@ -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