Sha256: 51b232f1d2186e3c931cc069c5250d4536202145f7d0ebb5a3e35ceaca82ca23
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 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? && metadata.assignee end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
smart_todo-1.0.2 | lib/smart_todo_cop.rb |