MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / CheckEnd

Method CheckEnd

rtpose_wrapper/scripts/cpp_lint.py:1856–1899  ·  view source on GitHub ↗

Check end of namespace comments.

(self, filename, clean_lines, linenum, error)

Source from the content-addressed store, hash-verified

1854 self.starting_linenum = linenum
1855
1856 def CheckEnd(self, filename, clean_lines, linenum, error):
1857 """Check end of namespace comments."""
1858 line = clean_lines.raw_lines[linenum]
1859
1860 # Check how many lines is enclosed in this namespace. Don't issue
1861 # warning for missing namespace comments if there aren't enough
1862 # lines. However, do apply checks if there is already an end of
1863 # namespace comment and it's incorrect.
1864 #
1865 # TODO(unknown): We always want to check end of namespace comments
1866 # if a namespace is large, but sometimes we also want to apply the
1867 # check if a short namespace contained nontrivial things (something
1868 # other than forward declarations). There is currently no logic on
1869 # deciding what these nontrivial things are, so this check is
1870 # triggered by namespace size only, which works most of the time.
1871 if (linenum - self.starting_linenum < 10
1872 and not Match(r'};*\s*(//|/\*).*\bnamespace\b', line)):
1873 return
1874
1875 # Look for matching comment at end of namespace.
1876 #
1877 # Note that we accept C style "/* */" comments for terminating
1878 # namespaces, so that code that terminate namespaces inside
1879 # preprocessor macros can be cpplint clean.
1880 #
1881 # We also accept stuff like "// end of namespace <name>." with the
1882 # period at the end.
1883 #
1884 # Besides these, we don't accept anything else, otherwise we might
1885 # get false negatives when existing comment is a substring of the
1886 # expected namespace.
1887 if self.name:
1888 # Named namespace
1889 if not Match((r'};*\s*(//|/\*).*\bnamespace\s+' + re.escape(self.name) +
1890 r'[\*/\.\\\s]*$'),
1891 line):
1892 error(filename, linenum, 'readability/namespace', 5,
1893 'Namespace should be terminated with "// namespace %s"' %
1894 self.name)
1895 else:
1896 # Anonymous namespace
1897 if not Match(r'};*\s*(//|/\*).*\bnamespace[\*/\.\\\s]*$', line):
1898 error(filename, linenum, 'readability/namespace', 5,
1899 'Namespace should be terminated with "// namespace"')
1900
1901
1902class _PreprocessorInfo(object):

Callers

nothing calls this directly

Calls 2

MatchFunction · 0.85
errorFunction · 0.85

Tested by

no test coverage detected