MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / CheckEnd

Method CheckEnd

steps/cpplint.py:2844–2894  ·  view source on GitHub ↗

Check end of namespace comments.

(self, filename, clean_lines, linenum, error)

Source from the content-addressed store, hash-verified

2842 self.check_namespace_indentation = True
2843
2844 def CheckEnd(self, filename, clean_lines, linenum, error):
2845 """Check end of namespace comments."""
2846 line = clean_lines.raw_lines[linenum]
2847
2848 # Check how many lines is enclosed in this namespace. Don't issue
2849 # warning for missing namespace comments if there aren't enough
2850 # lines. However, do apply checks if there is already an end of
2851 # namespace comment and it's incorrect.
2852 #
2853 # TODO(unknown): We always want to check end of namespace comments
2854 # if a namespace is large, but sometimes we also want to apply the
2855 # check if a short namespace contained nontrivial things (something
2856 # other than forward declarations). There is currently no logic on
2857 # deciding what these nontrivial things are, so this check is
2858 # triggered by namespace size only, which works most of the time.
2859 if (linenum - self.starting_linenum < 10
2860 and not Match(r'^\s*};*\s*(//|/\*).*\bnamespace\b', line)):
2861 return
2862
2863 # Look for matching comment at end of namespace.
2864 #
2865 # Note that we accept C style "/* */" comments for terminating
2866 # namespaces, so that code that terminate namespaces inside
2867 # preprocessor macros can be cpplint clean.
2868 #
2869 # We also accept stuff like "// end of namespace <name>." with the
2870 # period at the end.
2871 #
2872 # Besides these, we don't accept anything else, otherwise we might
2873 # get false negatives when existing comment is a substring of the
2874 # expected namespace.
2875 if self.name:
2876 # Named namespace
2877 if not Match((r'^\s*};*\s*(//|/\*).*\bnamespace\s+' +
2878 re.escape(self.name) + r'[\*/\.\\\s]*$'),
2879 line):
2880 error(filename, linenum, 'readability/namespace', 5,
2881 'Namespace should be terminated with "// namespace %s"' %
2882 self.name)
2883 else:
2884 # Anonymous namespace
2885 if not Match(r'^\s*};*\s*(//|/\*).*\bnamespace[\*/\.\\\s]*$', line):
2886 # If "// namespace anonymous" or "// anonymous namespace (more text)",
2887 # mention "// anonymous namespace" as an acceptable form
2888 if Match(r'^\s*}.*\b(namespace anonymous|anonymous namespace)\b', line):
2889 error(filename, linenum, 'readability/namespace', 5,
2890 'Anonymous namespace should be terminated with "// namespace"'
2891 ' or "// anonymous namespace"')
2892 else:
2893 error(filename, linenum, 'readability/namespace', 5,
2894 'Anonymous namespace should be terminated with "// namespace"')
2895
2896
2897class _PreprocessorInfo(object):

Callers

nothing calls this directly

Calls 1

MatchFunction · 0.85

Tested by

no test coverage detected