Class: RuboCop::Cop::Sane::OutdatedComments

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/sane/outdated_comments.rb

Overview

Detects TODO/NOTE/FIXME comments with dates that are in the past.

This cop helps ensure that dated comments are reviewed when their target date has passed.

Examples:

# bad (when date is in the past)
# TODO[2024-01-01]: Remove this after migration
# NOTE[2023-06-15]: Temporary workaround
# FIXME[2024-03-01]: Fix this bug

# good (when date is in the future or today)
# TODO[2025-12-31]: Remove this after migration

Constant Summary collapse

COMMENT_PATTERN =
/^#\s*(NOTE|TODO|FIXME)\[(\d{4}-\d{2}-\d{2})\]:/i
MSG =
"Review or remove this outdated comment dated %<date>s"

Instance Method Summary collapse

Instance Method Details

#on_new_investigationObject



26
27
28
29
30
31
32
# File 'lib/rubocop/cop/sane/outdated_comments.rb', line 26

def on_new_investigation
  return unless processed_source.valid_syntax?

  processed_source.comments.each do |comment|
    check_comment(comment)
  end
end