Closed ben-002 closed 2 years ago
Hi @ben-002,
thanks for reporting this. I cannot remember that we changed anything with regards to the warning task filters, but I'll check and will fix as soon as possible.
René
Hi again,
are you really providing the regular expression as shown in your comment? That should have always failed as there aren't any delimiters for the regex. The proper syntax would be something like /^(Build.*)$/
.
We did slightly change the code to parse the regular expression for better regex option handling. This is why it is now failing because of the missing delimiters. In v6 of the task, your expression was used but it was altered due to the missing delimiters. The resulting expression was (Build.*)$
without the initial ^
character.
Could you please add the delimiters to your expression?
@ReneSchumacher you are right, it works now. Thanks! I will close the issue.
.. could I get a bit of related guidance?
I'm trying to capture the displayName "CppCheck Scan" - this regex ('/^(CppCheck\\sScan)$/i'
) should do it, right?
I validated the regex at the same site, regex101.com
But I get the following:
[WARNING] The specified task filters did not match any build task.
##[warning]The specified task filters did not match any build task.
The yaml for the BQC plugin looks like this:
- task: CmdLine@2
displayName: "CppCheck Scan"
inputs:
script: |
cppcheck $(CodeOmittedForBrevity)
workingDirectory: '$(Build.SourcesDirectory)'
- task: BuildQualityChecks@8
displayName: 'CppCheck Gate'
inputs:
# ===== Warnings Policy Inputs =====
checkWarnings: true
warningFailOption: build
showStatistics: true
evaluateTaskWarnings: true
warningTaskFilters: '/^(CppCheck\\sScan)$/i'
Hi @ncook-hxgn,
I believe the issue is caused by the double backslash, which causes the regular expression to search for the actual string \s
instead of whitespace. Just use \s
instead of \\s
and it should work.
Ah OK I'll give that a go.
.. does that mean I failed to copy the doc'd example well, or the example is over-escaped? https://github.com/MicrosoftPremier/VstsExtensions/blob/master/BuildQualityChecks/en-US/overview.md#adding-the-task-to-a-yaml-build-definition
Edit: Eyyy, it worked when I stopped overescaping :) <3
I think the docs might need a tweak?
OK, I could use a little more help with the regex for the warningFilters
..
I'm trying to capture output from cppcheck --template-vs
CppCheck will give me something like
Project\SourceFile.cpp(22): style: Variable 'arr' can be declared as const array
Project\SourceFile.cpp(40): error: Modifying string literal "[https://www.geek.."](https://www.geek..%22/) directly or indirectly is undefined behaviour.
Project\SourceFile.cpp(35): style: Variable 'ptr' is assigned a value that is never used.
I wrote this regex to capture it:
warningTaskFilters: '/^(CppCheck\sScan)$/i' # Optional
warningFilters: '/(?<filename>.+?)\((?<line>\d+)\):\s(?<identifier>.+?):\s(?<message>.+?)$/i'
And regex101.com said it works:
However, from the extension, all I can see in the Extensions tab is the filename - no line number, identifier, or message :(
.. is there another bug in my regex?
Hi @ncook-hxgn,
can you download the raw log from your CppCheck Scan task and test your regular expression with a line taken from there? BQC analyzes the raw task log which includes timestamps at the beginning. Thus, the matches might be different.
You can also send the log to PSGerExtSupport@microsoft.com, so I can have a look at it.
Describe the context
warningTaskFilters: '^(Build.*)$'
For BuildQualityChecks@8 returns: The expression '^(Build.*)$' is not a valid regular expression and will be ignored. Suceeds with BuildQualityChecks@6.
Also, I validated the regex with https://regex101.com/ and is a valid one