SA5008: check for missing closing quote#1517
SA5008: check for missing closing quote#1517nanzhong wants to merge 1 commit intodominikh:masterfrom
Conversation
|
There's a bunch of other cases with quotes that should probably trigger an error; with your patch: So no error on a missing starting quote or double quotes. |
|
@arp242 you're totally right, however, the reason those are resulting in a pass is because the current implementation of I suspect the intent here is to be conservative since the language spec doesn't go beyond specifying that struct tags must be a string literal value. I'm not sure how strong @dominikh wants to preserve this behaviour. If not, then I can certainly update the struct tag parsing to fail more loudly, if so, then perhaps I could introduce a separate optional check that's more strict about the format of struct tags? |
This PR attempts to address handling the missing closing quote case for the struct tag parser.
I could be naive here, but changing the current implementation of the scanner from
breaking when it's unable to find the closing double quote to returning an error would achieve this. This does the change the behaviour to now ignore partially valid tags (i.e.`xml:"complete" json:"missing`would no longer result in thexml:"complete"being checked), instead it will highlight the missing closing quote violation.I'm not familiar with the intended
testdataorganization, so I've proposed a test case for this under theexample.com/CheckStructTags.