Sha256: 0ef2508c99d6650232f30f89d670b7a04af403bc84184d3ca68bcc552a51e0f3
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true require 'smart_todo/parser/metadata_parser' module RuboCop module Cop module SmartTodo # 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 https://rubocop.readthedocs.io/en/latest/extensions/#loading-extensions class SmartTodoCop < Cop MSG = "Don't write regular TODO comments. Write SmartTodo compatible syntax comments." \ "For more info please look at https://github.com/shopify/smart_todo" # @param processed_source [RuboCop::ProcessedSource] # @return [void] 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 # @param comment [String] # @return [true, false] def smart_todo?(comment) metadata = ::SmartTodo::Parser::MetadataParser.parse(comment.gsub(/^#/, '')) metadata.events.any? end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
smart_todo-1.0.1 | lib/smart_todo_cop.rb |
smart_todo-1.0.0 | lib/smart_todo_cop.rb |