Skip to content

Restrict regular TODO

Edouard Chin edited this page Jul 19, 2019 · 2 revisions

If you want to enforce SmartTodo comments over regular TODO comments, you'll need to install RuboCop in your project.

Once installed, inside the .rubocop.yml configuration file, you'll just need to add this:

require:
  - smart_todo_cop

Refer to the RuboCop doc in case you have issues loading the extension.


After doing this, regular TODO comments will be reported and RuboCop will warn the user. Please note that malformated SmartTodo comments will be reported the same way as if they were regular TODO.

bundle exec rubocop
Inspecting 799 files


Offenses:

test/dev/some_file.rb:8:5: C: SmartTodo/SmartTodoCop: Don't write regular TODO comments. Write SmartTodo compatible syntax comments.For more info please look at https://github.com/shopify/smart_todo
    # TODO(2019-01-01): Don't forget to do this
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
# Bad
#
# TODO: Do this on September 1st

# Bad
#
# TODO(@John.cena) Do this on September 1st 

# Bad
#
# TODO(to: 'john@example.com')

# Good
#
# TODO(on: date('2019-09-01'), to: 'john@example.com')
Clone this wiki locally