class RuboCop::Cop::SmartTodo::SmartTodoCop
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.
@see rubocop.readthedocs.io/en/latest/extensions/#loading-extensions
Constants
- MSG
Public Instance Methods
investigate(processed_source)
click to toggle source
@param processed_source [RuboCop::ProcessedSource] @return [void]
# File lib/smart_todo_cop.rb, line 18 def investigate(processed_source) processed_source.comments.each do |comment| next unless /^#\sTODO/ =~ comment.text next if smart_todo?(comment.text) add_offense(comment) end end
smart_todo?(comment)
click to toggle source
@param comment [String] @return [true, false]
# File lib/smart_todo_cop.rb, line 29 def smart_todo?(comment) metadata = ::SmartTodo::Parser::MetadataParser.parse(comment.gsub(/^#/, '')) metadata.events.any? && metadata.events.all? { |event| event.is_a?(::SmartTodo::Parser::MethodNode) } && metadata.assignee end