diff options
author | Jordi Serra Torrens <jordi.serra-torrens@mongodb.com> | 2022-09-29 09:37:43 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-09-29 10:06:35 +0000 |
commit | dc15e9c5fd0d8bb8b50679e5cf1170f426de60fb (patch) | |
tree | 908c5fd9d1818a3b9e18c2377a42688e14a1c79d | |
parent | f02d19996ec911d128642565ddcfbce5ae079956 (diff) | |
download | mongo-dc15e9c5fd0d8bb8b50679e5cf1170f426de60fb.tar.gz |
SERVER-70047 Add linter rule that checks CollectionSharingRuntime is not used outside sharding code
-rw-r--r-- | buildscripts/linter/simplecpplint.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/buildscripts/linter/simplecpplint.py b/buildscripts/linter/simplecpplint.py index e9e28ff2d2a..a237b4c84b7 100644 --- a/buildscripts/linter/simplecpplint.py +++ b/buildscripts/linter/simplecpplint.py @@ -60,6 +60,7 @@ _RE_ASSERT = re.compile(r'\bassert\s*\(') _RE_UNSTRUCTURED_LOG = re.compile(r'\blogd\s*\(') _RE_STD_OPTIONAL = re.compile(r'\bstd::optional\b') _RE_TRACING_SUPPORT = re.compile(r'\bTracerProvider::(get|initialize)\b') +_RE_COLLECTION_SHARDING_RUNTIME = re.compile(r'\bCollectionShardingRuntime\b') _RE_GENERIC_FCV_COMMENT = re.compile(r'\(Generic FCV reference\):') GENERIC_FCV = [ @@ -153,6 +154,7 @@ class Linter: self._check_for_ctype(linenum) self._check_for_std_optional(linenum) self._check_for_tracing_support(linenum) + self._check_for_collection_sharding_runtime(linenum) # Relax the rule of commenting generic FCV references for files directly related to FCV # implementations. @@ -289,6 +291,15 @@ class Linter: linenum, 'mongodb/tracing', 'Illegal use of tracing support, ' 'this is only for local development use and should not be committed.') + def _check_for_collection_sharding_runtime(self, linenum): + line = self.clean_lines[linenum] + if _RE_COLLECTION_SHARDING_RUNTIME.search( + line) and "/src/mongo/db/s/" not in self.file_name: + self._error( + linenum, 'mongodb/collection_sharding_runtime', 'Illegal use of ' + 'CollectionShardingRuntime outside of mongo/db/s/; use CollectionShardingState ' + 'instead; see src/mongo/db/s/collection_sharding_state.h for details.') + def _license_error(self, linenum, msg, category='legal/license'): style_url = 'https://github.com/mongodb/mongo/wiki/Server-Code-Style' self._error(linenum, category, '{} See {}'.format(msg, style_url)) |