Help writing a new lint test #289
-
My team has a team specific formating for state names: $FORUMLA - $STATE - $OPT_SUBSTATE - description Based on the filename, I think I can figure out what the formula, state and option substate names should be. My question is - how do I identify the state name in the text? Is that even regexable? Suggestions welcome. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I've converted the GitHub issue (#281) to a discussion. |
Beta Was this translation helpful? Give feedback.
-
If you filter out all the Jinja placeholders and comments you could easily identify the state names in a SLS file using the regex Using this regex you could write a rule that checks if the found state name starts with the formula, state and option substate you already know based upon the filename. If one of the state names doesn't match, it's not following your teams convention and should return the found regex capture group(s). The filename can be obtain the filename inside your |
Beta Was this translation helpful? Give feedback.
If you filter out all the Jinja placeholders and comments you could easily identify the state names in a SLS file using the regex
^(\S[^:]+):
. This will get you all the lines starting without a whitespace (indentation) up to the:
character in a capture group.Using this regex you could write a rule that checks if the found state name starts with the formula, state and option substate you already know based upon the filename. If one of the state names doesn't match, it's not following your teams convention and should return the found regex capture group(s).
The filename can be obtain the filename inside your
match(self, file, line)
function using thefile['path']
variable.