MCPcopy Create free account
hub / github.com/Kitware/VTK / CheckIncludes

Method CheckIncludes

Testing/Core/HeaderTesting.py:198–262  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

196 self.Error('Missing VTK_ABI_NAMESPACE_END.')
197
198 def CheckIncludes(self):
199 if not self.HasIncludes or not self.HasClass:
200 return
201
202 count = 0
203 lines = []
204 nplines = []
205 unlines = []
206 includere = "^\\s*#\\s*include\\s*[\"<]([^>\"]+)"
207 ignincludere = ".*\\/\\/.*"
208 regx = re.compile(includere)
209 regx1 = re.compile(ignincludere)
210 cc = 0
211 includeparent = 0
212 stdIncludes = {'any', 'bitset', 'chrono', 'csetjmp', 'csignal',
213 'cstddef', 'ctime', 'functional', 'initializer_list',
214 'tuple', 'type_traits', 'typeindex', 'typeinfo', 'utility', 'memory',
215 'new', 'scoped_allocator', 'cfloat', 'cinttypes', 'climits', 'limits',
216 'cstdint', 'cassert', 'cerrno', 'exception', 'stdexcept',
217 'system_error', 'cctype', 'cuchar', 'cwchar', 'cwctyp',
218 'string', 'array', 'deque', 'forward_list', 'list', 'map', 'queue',
219 'set', 'stack', 'unordered_map', 'unordered_set', 'vector',
220 'iterator', 'algorithm', 'cfenv', 'cmath', 'complex', 'numeric',
221 'random', 'ratio', 'valarray', 'clocale', 'codecvt', 'locale',
222 'ostream', 'istream', 'thread', 'mutex', 'future',
223 'condition_variable'}
224 for a in self.FileLines:
225 line = a.strip()
226 rm = regx.match(line)
227 if rm and not regx1.match(line):
228 file = rm.group(1)
229 if file in stdIncludes:
230 continue
231 lines.append(" %4d: %s" % (cc, line))
232 if file == (self.ParentName + ".h"):
233 includeparent = 1
234 if not StringEndsWith(file, ".h"):
235 nplines.append(" %4d: %s" % (cc, line))
236 if file in self.UnnecessaryIncludes:
237 unlines.append(" %4d: %s" % (cc, line))
238 cc = cc + 1
239 if len(lines) > 1:
240 self.Print()
241 self.Print( "File: %s has %d includes: " %
242 ( self.FileName, len(lines)) )
243 for a in lines:
244 self.Print( a )
245 self.Error("Multiple includes")
246 if len(nplines) > 0:
247 self.Print( )
248 self.Print( "File: %s has non-portable include(s): " % self.FileName )
249 for a in nplines:
250 self.Print( a )
251 self.Error("Non-portable includes")
252 if len(unlines) > 0:
253 self.Print( )
254 self.Print( "File: %s has unnecessary include(s): " % self.FileName )
255 for a in unlines:

Callers 1

HeaderTesting.pyFile · 0.80

Calls 7

PrintMethod · 0.95
ErrorMethod · 0.95
StringEndsWithFunction · 0.85
compileMethod · 0.80
matchMethod · 0.45
groupMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected