Perform Lint function length check on block of code and return warnings. Builds up an array of lines corresponding to the code and strips comments using cpplint functions. Establishes an error collector and invokes the function length checking function following cpp
(self, code)
| 194 | return error_collector.Results() |
| 195 | |
| 196 | def PerformFunctionLengthsCheck(self, code): |
| 197 | """Perform Lint function length check on block of code and return warnings. |
| 198 | |
| 199 | Builds up an array of lines corresponding to the code and strips comments |
| 200 | using cpplint functions. |
| 201 | |
| 202 | Establishes an error collector and invokes the function length checking |
| 203 | function following cpplint's pattern. |
| 204 | |
| 205 | Args: |
| 206 | code: C++ source code expected to generate a warning message. |
| 207 | |
| 208 | Returns: |
| 209 | The accumulated errors. |
| 210 | """ |
| 211 | file_name = "foo.cc" |
| 212 | error_collector = ErrorCollector(self.assertTrue) |
| 213 | function_state = cpplint._FunctionState() |
| 214 | lines = code.split("\n") |
| 215 | cpplint.RemoveMultiLineComments(file_name, lines, error_collector) |
| 216 | lines = cpplint.CleansedLines(lines) |
| 217 | for i in range(lines.NumLines()): |
| 218 | cpplint.CheckForFunctionLengths(file_name, lines, i, function_state, error_collector) |
| 219 | return error_collector.Results() |
| 220 | |
| 221 | def PerformIncludeWhatYouUse(self, code, filename="foo.h", io=codecs): |
| 222 | # First, build up the include state. |
no test coverage detected