rubocop-markdown
Note
This project is archived because I no longer actively use it, and there seems to be no recent activity from other users either. If you are still using it and would like to take over maintenance, please reach out to me.
RuboCop plugin for Ruby code blocks in Markdown.
Installation
Install the gem and add to the application's Gemfile by executing:
bundle add rubocop-markdown
If bundler is not being used to manage dependencies, install the gem by executing:
gem install rubocop-markdown
Usage
Require rubocop-markdown in your RuboCop config.
# .rubocop.yml
require:
- rubocop-markdownNow you can use RuboCop also for Ruby code block in Markdown.
$ bundle exec rubocop README.md
Inspecting 1 file
W
Offenses:
README.md:69:6: C: [Correctable] Style/NumericPredicate: Use array.size.positive? instead of array.size > 0.
a if array.size > 0
^^^^^^^^^^^^^^
README.md:69:6: C: [Correctable] Style/ZeroLengthPredicate: Use !empty? instead of size > 0.
a if array.size > 0
^^^^^^^^^^^^^^
README.md:57:1: W: Lint/Void: Literal "a" used in void context.
"a"
^^^
README.md:57:1: C: [Correctable] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
"a"
^^^
README.md:59:1: C: [Correctable] Style/CharacterLiteral: Do not use the character literal - use string literal instead.
?c
^^
1 file inspected, 5 offenses detected, 4 offenses autocorrectable
# Ruby code block.
"a"
b
?c# Not Ruby code block.
"a"
# Ruby code block.
a if array.size > 0