Repository navigation
Guideline statistics bugs - #5188
gulyasgergely902 wants to merge 2 commits into
Conversation
|
I have some "none" checkers in the exported CSV: sei-cert-c,arr32-c,,core.VLASize,High,Enabled in all selected runs,0,0
sei-cert-c,arr36-c,,security.PointerSub,High,Enabled in all selected runs,0,0
sei-cert-c,arr36-c,,cppcheck-subtractPointers,High,Not enabled in all selected runs,0,0
sei-cert-c,arr36-c,,gcc-analyzer-undefined-behavior-ptrdiff,Unspecified,Not enabled in all selected runs,0,0
sei-cert-c,arr37-c,,none,,,,
sei-cert-c,arr38-c,,unix.StdCLibraryFunctions,High,Enabled in all selected runs,0,2
sei-cert-c,arr38-c,,gcc-analyzer-out-of-bounds,Unspecified,Not enabled in all selected runs,0,0
sei-cert-c,arr38-c,,gcc-analyzer-use-of-uninitialized-value,Unspecified,Not enabled in all selected runs,0,0
sei-cert-c,arr39-c,,clang-diagnostic-array-bounds-pointer-arithmetic,Medium,Enabled in all selected runs,0,0
sei-cert-c,arr39-c,,misc-sizeof-expression,Unspecified,Not enabled in all selected runs,0,0
sei-cert-c,arr39-c,,gcc-analyzer-out-of-bounds,Unspecified,Not enabled in all selected runs,0,0
sei-cert-c,con30-c,,none,,,,
sei-cert-c,con31-c,,none,,,,
sei-cert-c,con32-c,,none,,,,
sei-cert-c,con33-c,,concurrency-mt-unsafe,Medium,Not enabled in all selected runs,0,0
sei-cert-c,con34-c,,none,,,,Also, couldn't we use some csv library in JS instead of manually escaping csv characters? |
|
Since the only job here is to escape the CSV, I don't think it is worth using any lib here. The function is simple enough to be used IMHO. |
Guideline statistics export does not contain rules which does not have an attached rule to it. This change adds them just like in the gui table.
7d6aced to
2631408
Compare
| function escapeCSVField(value) { | ||
| const _str = value === null || value === undefined ? "" : String(value); | ||
|
|
||
| if (/[",\n\r]/.test(_str)) { |
There was a problem hiding this comment.
why using double quotes only if there are these special characters in the string. I think we should always use double quotes.
There was a problem hiding this comment.
The specification of CSV format (RFC 4180) does not explicitly say that every field should or should not be enclosed in quotes although what they say is that if the fields are not enclosed in quotes then there may not be any inside the field either. I'm not against using quotes for every field to make them homologous.
| const _str = value === null || value === undefined ? "" : String(value); | ||
|
|
||
| if (/[",\n\r]/.test(_str)) { | ||
| return `"${_str.replace(/"/g, "\"\"")}"`; |
There was a problem hiding this comment.
Could we use
return "${_str.replaceAll('"', '""')}";
it just easier to read.
| stat.guidelineName, | ||
| stat.guidelineRule, | ||
| stat.guidelineRuleTitle, | ||
| "", |
There was a problem hiding this comment.
could we use "none" instead of empty string to match what we have in the GUI table?
There was a problem hiding this comment.
This issue came up previously on this PR, where the result of the dicussion was to simly omit the none word and use the empty string instead. I see your point to make the CSV similar to the UI but whilst UI is for humans, CSV will be read by code and it is easier to distiguish between string or "" than a string or another string. Also currently all other columns also have the none word on the UI whereas the CSV does not.
If the rule title contains a comma, it breaks the exported JSON thus encapsulating it in quotation marks to prevent breaking of titles with commas in them.
2631408 to
b4cb13b
Compare
fixes CODECHKR-7158
This change fixes a bug and adds an enhancement in the guideline statistics feature.