0

Is it possible to reject the check in of files or break the build if a file is checked in which contains a TODO (or certain string) using TFS/TeamCity?

It would need to ignore any files which already contained the TODO and would only be break the build/reject the check in if a file is changed and then checked in.

This could be used to force existing TODOs to be dealt with when a dev makes changes to a file which contains the TODO.

Could this be done?

Sam Holder
  • 32,535
  • 13
  • 101
  • 181

1 Answers1

1

One way would be to use a Custom FX Cop Rule.

  1. Create a custom FX Cop rule to find TODO in your code.
  2. Enable this Rule in All your current projects as an "Error" when found.
  3. Build the Solution.
  4. Select all of the Code Analysis Warnings that are generated by the Rule and add them to the GlobalSuppression.cs Files.
  5. Check In the above changes.

Now if anyone adds a new TODO they will have to suppress the FX Cop Rule to be able to build the code - unless they add it as a suppression.

DaveShaw
  • 52,123
  • 16
  • 112
  • 141
  • This would work for new TODOs in new files, but won't work when files with existing TODO are changed (as they are still in the global supression file), which is what I want really ie to force people to have to deal with any existing issues whilst they are changing that file... – Sam Holder Jul 06 '12 at 16:15
  • FX Cop Suppressions are "per line". So long as someone add/removes a Line, it *should* raise a new rule failure. – DaveShaw Jul 06 '12 at 16:16