Class: RuboCop::Cop::SmartTodo::SmartTodoCop
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::SmartTodo::SmartTodoCop
- Defined in:
- lib/smart_todo_cop.rb
Overview
A RuboCop used to restrict the usage of regular TODO comments in code. This Cop does not run by default. It should be added to the RuboCop host’s configuration file.
Constant Summary collapse
- HELP =
"For more info please look at https://github.com/Shopify/smart_todo/wiki/Syntax"
- MSG =
"Don't write regular TODO comments. Write SmartTodo compatible syntax comments. #{HELP}"
Instance Method Summary collapse
Instance Method Details
#investigate(processed_source) ⇒ void
This method returns an undefined value.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/smart_todo_cop.rb', line 18 def investigate(processed_source) processed_source.comments.each do |comment| next unless /^#\sTODO/.match?(comment.text) = (comment.text) if .errors.any? add_offense(comment, message: "Invalid TODO format: #{.errors.join(", ")}. #{HELP}") elsif !smart_todo?() add_offense(comment) elsif (methods = invalid_event_methods(.events)).any? add_offense(comment, message: "Invalid event method(s): #{methods.join(", ")}. #{HELP}") end end end |