@@ -84,110 +84,116 @@ namespace HtmlLib {
84
84
85
85
} // namespace HtmlLib
86
86
87
- namespace CsLib {
88
- std::string digTitle (const TScanProps &props) {
89
- const TScanProps::const_iterator NA = props.end ();
90
- TScanProps::const_iterator it = props.find (" title" );
91
- if (NA != it)
92
- return it->second ;
93
-
94
- std::string title;
95
- it = props.find (" project-name" );
96
- if (NA == it) {
97
- it = props.find (" tool-args" );
98
- if (props.end () == it)
99
- return " " ;
100
-
101
- const std::string &args = it->second ;
102
- const RE reSrpm (" ^.*[ /']([^ /']*)\\ .src\\ .rpm.*$" );
103
-
104
- boost::smatch sm;
105
- if (!boost::regex_match (args, sm, reSrpm))
106
- return " " ;
87
+ std::string digTitle (const TScanProps &props) {
88
+ const TScanProps::const_iterator NA = props.end ();
89
+ TScanProps::const_iterator it = props.find (" title" );
90
+ if (NA != it)
91
+ return it->second ;
92
+
93
+ std::string title;
94
+ it = props.find (" project-name" );
95
+ if (NA == it) {
96
+ it = props.find (" tool-args" );
97
+ if (props.end () == it)
98
+ return " " ;
99
+
100
+ const std::string &args = it->second ;
101
+ const RE reSrpm (" ^.*[ /']([^ /']*)\\ .src\\ .rpm.*$" );
102
+
103
+ boost::smatch sm;
104
+ if (!boost::regex_match (args, sm, reSrpm))
105
+ return " " ;
106
+
107
+ title = sm[/* NVR */ 1 ];
108
+ }
109
+ else
110
+ title = it->second ;
107
111
108
- title = sm[/* NVR */ 1 ];
109
- }
110
- else
111
- title = it->second ;
112
+ it = props.find (" diffbase-project-name" );
113
+ if (NA != it) {
114
+ title += " - defects not occurring in " ;
115
+ title += it->second ;
116
+ }
112
117
113
- it = props.find (" diffbase-project-name" );
114
- if (NA != it) {
115
- title += " - defects not occurring in " ;
116
- title += it->second ;
117
- }
118
+ return title;
119
+ }
118
120
119
- return title;
121
+ void writeParseWarnings (std::ostream &str, const TScanProps &props) {
122
+ TScanProps::const_iterator itCount, itRatio;
123
+ itCount = props.find (" cov-compilation-unit-count" );
124
+ itRatio = props.find (" cov-compilation-unit-ratio" );
125
+ if (props.end () == itCount || props.end () == itRatio) {
126
+ // fallback to deprecated format produced by cov-mockbuild
127
+ itCount = props.find (" compilation-unit-count" );
128
+ itRatio = props.find (" compilation-unit-ratio" );
120
129
}
130
+ if (props.end () == itCount || props.end () == itRatio)
131
+ return ;
121
132
122
- void writeParseWarnings (std::ostream &str, const TScanProps &props) {
123
- TScanProps::const_iterator itCount, itRatio;
124
- itCount = props.find (" cov-compilation-unit-count" );
125
- itRatio = props.find (" cov-compilation-unit-ratio" );
133
+ try {
134
+ const int count = boost::lexical_cast<int >(itCount->second );
135
+ const int ratio = boost::lexical_cast<float >(itRatio->second );
136
+ if (ratio < parsingRatioThr)
137
+ str << " <p><b style='color: #FF0000;'>warning:</b> "
138
+ " low parsing ratio: " << ratio << " %</p>\n " ;
139
+
140
+ itCount = props.find (" diffbase-cov-compilation-unit-count" );
141
+ itRatio = props.find (" diffbase-cov-compilation-unit-ratio" );
126
142
if (props.end () == itCount || props.end () == itRatio) {
127
143
// fallback to deprecated format produced by cov-mockbuild
128
- itCount = props.find (" compilation-unit-count" );
129
- itRatio = props.find (" compilation-unit-ratio" );
144
+ itCount = props.find (" diffbase- compilation-unit-count" );
145
+ itRatio = props.find (" diffbase- compilation-unit-ratio" );
130
146
}
131
147
if (props.end () == itCount || props.end () == itRatio)
132
148
return ;
133
149
134
- try {
135
- const int count = boost::lexical_cast<int >(itCount->second );
136
- const int ratio = boost::lexical_cast<float >(itRatio->second );
137
- if (ratio < parsingRatioThr)
138
- str << " <p><b style='color: #FF0000;'>warning:</b> "
139
- " low parsing ratio: " << ratio << " %</p>\n " ;
140
-
141
- itCount = props.find (" diffbase-cov-compilation-unit-count" );
142
- itRatio = props.find (" diffbase-cov-compilation-unit-ratio" );
143
- if (props.end () == itCount || props.end () == itRatio) {
144
- // fallback to deprecated format produced by cov-mockbuild
145
- itCount = props.find (" diffbase-compilation-unit-count" );
146
- itRatio = props.find (" diffbase-compilation-unit-ratio" );
147
- }
148
- if (props.end () == itCount || props.end () == itRatio)
149
- return ;
150
-
151
- const int baseCount = boost::lexical_cast<int >(itCount->second );
152
- const int baseRatio = boost::lexical_cast<float >(itRatio->second );
153
- if (baseRatio < parsingRatioThr && baseRatio < ratio)
154
- str << " <p><b style='color: #FF0000;'>warning:</b> "
155
- " low parsing ratio in diff base: "
156
- << baseRatio << " %</p>\n " ;
157
-
158
- if (!count || 100 * baseCount / count < parsingOldToNewRatioThr)
159
- str << " <p><b style='color: #FF0000;'>warning:</b> "
160
- " low count of parsed units in diff base: "
161
- << baseCount << " </p>\n " ;
162
- }
163
- catch (boost::bad_lexical_cast &) {
164
- // failed to parse count/ratio
165
- }
150
+ const int baseCount = boost::lexical_cast<int >(itCount->second );
151
+ const int baseRatio = boost::lexical_cast<float >(itRatio->second );
152
+ if (baseRatio < parsingRatioThr && baseRatio < ratio)
153
+ str << " <p><b style='color: #FF0000;'>warning:</b> "
154
+ " low parsing ratio in diff base: "
155
+ << baseRatio << " %</p>\n " ;
156
+
157
+ if (!count || 100 * baseCount / count < parsingOldToNewRatioThr)
158
+ str << " <p><b style='color: #FF0000;'>warning:</b> "
159
+ " low count of parsed units in diff base: "
160
+ << baseCount << " </p>\n " ;
166
161
}
162
+ catch (boost::bad_lexical_cast &) {
163
+ // failed to parse count/ratio
164
+ }
165
+ }
167
166
168
- void writeScanProps (std::ostream &str, const TScanProps &props) {
169
- if (props.empty ())
170
- return ;
171
-
172
- HtmlLib::initSection (str, " Scan Properties" );
167
+ void writeScanProps (std::ostream &str, const TScanProps &props) {
168
+ if (props.empty ())
169
+ return ;
173
170
174
- str << " <table style='font-family: monospace;'>\n " ;
175
- int i = 0 ;
171
+ HtmlLib::initSection (str, " Scan Properties" );
176
172
177
- for (TScanProps::const_reference item : props) {
178
- const char *trStyle = " " ;
179
- if (++i & 1 )
180
- trStyle = " style='background-color: #EEE;'" ;
173
+ str << " <table style='font-family: monospace;'>\n " ;
174
+ int i = 0 ;
181
175
182
- const char *tdStyle0 = " padding-right: 8px; white-space: nowrap; " ;
183
- str << " <tr " << trStyle << " ><td style=' " << tdStyle0 << " '> "
184
- << item. first << " </td><td> " << item. second << " </td></tr> \n " ;
185
- }
176
+ for (TScanProps::const_reference item : props) {
177
+ const char * trStyle = " " ;
178
+ if (++i & 1 )
179
+ trStyle = " style='background-color: #EEE;' " ;
186
180
187
- str << " </table>\n " ;
181
+ const char *tdStyle0 = " padding-right: 8px; white-space: nowrap;" ;
182
+ str << " <tr" << trStyle << " ><td style='" << tdStyle0 << " '>"
183
+ << item.first << " </td><td>" << item.second << " </td></tr>\n " ;
188
184
}
189
185
190
- } // namespace CsLib
186
+ str << " </table>\n " ;
187
+ }
188
+
189
+ void linkifyShellCheckMsg (std::string *pMsg)
190
+ {
191
+ static const RE reShellCheckMsg (" (\\ [)?SC([0-9]+)(\\ ])?$" );
192
+ *pMsg = boost::regex_replace (*pMsg, reShellCheckMsg,
193
+ " <a href=\" https://github.com/koalaman/shellcheck/wiki/SC\\ 2\" "
194
+ " title=\" description of ShellCheck's checker SC\\ 2\" >"
195
+ " \\ 1SC\\ 2\\ 3</a>" );
196
+ }
191
197
192
198
class HtmlWriterCore {
193
199
public:
@@ -245,7 +251,7 @@ void HtmlWriterCore::writeHeaderOnce(
245
251
return ;
246
252
247
253
// resolve title of the document
248
- std::string title = CsLib:: digTitle (props);
254
+ std::string title = digTitle (props);
249
255
if (title.empty ())
250
256
title = titleFallback_;
251
257
@@ -255,9 +261,9 @@ void HtmlWriterCore::writeHeaderOnce(
255
261
HtmlLib::writeLink (str_, plainTextUrl, " [Show plain-text results]" );
256
262
257
263
// write scan properties
258
- CsLib:: writeParseWarnings (str_, props);
264
+ writeParseWarnings (str_, props);
259
265
if (spOnTop_)
260
- CsLib:: writeScanProps (str_, props);
266
+ writeScanProps (str_, props);
261
267
262
268
// initialize the section for defects
263
269
HtmlLib::initSection (str_, " List of Defects" );
@@ -275,7 +281,7 @@ void HtmlWriterCore::closeDocument(const TScanProps &props)
275
281
HtmlLib::finalizePre (str_);
276
282
277
283
if (spBottom_)
278
- CsLib:: writeScanProps (str_, props);
284
+ writeScanProps (str_, props);
279
285
280
286
HtmlLib::finalizeHtml (str_);
281
287
@@ -426,15 +432,6 @@ void HtmlWriter::Private::writeNewDefWarning(const Defect &def)
426
432
<< this ->newDefMsg << " ]</span>" ;
427
433
}
428
434
429
- void linkifyShellCheckMsg (std::string *pMgs)
430
- {
431
- static const RE reShellCheckMsg (" (\\ [)?SC([0-9]+)(\\ ])?$" );
432
- *pMgs = boost::regex_replace (*pMgs, reShellCheckMsg,
433
- " <a href=\" https://github.com/koalaman/shellcheck/wiki/SC\\ 2\" "
434
- " title=\" description of ShellCheck's checker SC\\ 2\" >"
435
- " \\ 1SC\\ 2\\ 3</a>" );
436
- }
437
-
438
435
void HtmlWriter::handleDef (const Defect &def)
439
436
{
440
437
d->core .writeHeaderOnce (d->scanProps , d->plainTextUrl );
0 commit comments