Config for "starts with X, but not followed by Y"
mrlacey opened this issue · comments
X-Ref a suggestion to create warnings for all comments that do not contain the specified text.
Consider the need to "Identify all TODO comments apart from ones that contain a tracking item reference."
Such TODOs already correspond to a separate issue or tracking item and so are less likely to need a warning created.
e.g. Don't want to warn about this
// TODO: this is where to make the change for #12388
(where "#12388" is an ID for a change request)
but do want to warn about
// TODO add validation
Don't want to implement "warn about all comments unless they start/contain X" as that risks reporting far more than woudl be useful without extensive configuration.
So, looking for a way to say warn about comments that "start 'TODO' but don't include '#'"
Need a clear, simple way of configuring such functionality that works with current config format.
In addition to plain text on a line that is used to indicate the start of comments of interest, it is also possible to have lines comprised of configuration blocks.
A configuration block takes the format of [KEYWORD(value)]
The following keywords are supported
- STARTS
- CONTAINS
- DOESNOTCONTAIN
You can include none, one, two, or all three blocks in a line.
But they must be listed in the order, STARTS, CONTAINS, DOESNOTCONTAIN.
for example
[STARTS(todo)][CONTAINS(Issue#)][DOESNOTCONTAIN(low-priority)]
will create warnings for a line that starts with "todo" contains the text "Issue#" and does not contain the text "low-priority."
[ERROR][CONTAINS(high-priority)]
It is only possible to include a single config block for each keyword on a line. If multiple blocks are included only the first will be used.
The value specified for a config block is matched case-insensitively.
Lines can start with output type indicators or not, and do not have an effect on filtering
The following two config lines produce identical results.
[STARTS(TODO)][DOESNOTCONTAIN(#)]
[WARN][STARTS(TODO)][DOESNOTCONTAIN(#)]
Below shows an example of a config file with multiple different lines and the effect they can have