diff options
author | Yu Jin Kang Park <yujin.kang@mongodb.com> | 2022-11-25 11:02:03 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-11-25 11:33:03 +0000 |
commit | fe588e79d92b90eaf3a057e8fca78c0b8b8169fd (patch) | |
tree | 40d2e3d78e35af0fc2ee4e5fc37c7403b39e8f98 /buildscripts/linter | |
parent | 161677aca8bae3853e0d000afb65d6655b21fa7b (diff) | |
download | mongo-fe588e79d92b90eaf3a057e8fca78c0b8b8169fd.tar.gz |
SERVER-68867 Add simplecpplint check for UninterruptibleLockGuard
Diffstat (limited to 'buildscripts/linter')
-rw-r--r-- | buildscripts/linter/simplecpplint.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/buildscripts/linter/simplecpplint.py b/buildscripts/linter/simplecpplint.py index a237b4c84b7..959f4781504 100644 --- a/buildscripts/linter/simplecpplint.py +++ b/buildscripts/linter/simplecpplint.py @@ -61,6 +61,7 @@ _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_UNINTERRUPTIBLE_LOCK_GUARD = re.compile(r'\bUninterruptibleLockGuard\s+.+\s*;') _RE_GENERIC_FCV_COMMENT = re.compile(r'\(Generic FCV reference\):') GENERIC_FCV = [ @@ -155,6 +156,7 @@ class Linter: self._check_for_std_optional(linenum) self._check_for_tracing_support(linenum) self._check_for_collection_sharding_runtime(linenum) + self._check_for_uninterruptible_lock_guard(linenum) # Relax the rule of commenting generic FCV references for files directly related to FCV # implementations. @@ -300,6 +302,16 @@ class Linter: 'CollectionShardingRuntime outside of mongo/db/s/; use CollectionShardingState ' 'instead; see src/mongo/db/s/collection_sharding_state.h for details.') + def _check_for_uninterruptible_lock_guard(self, linenum): + line = self.clean_lines[linenum] + if _RE_UNINTERRUPTIBLE_LOCK_GUARD.search(line): + self._error( + linenum, 'mongodb/uninterruptible_lock_guard', + 'Potentially incorrect use of UninterruptibleLockGuard, ' + 'the programming model inside MongoDB requires that all operations be interruptible. ' + 'Review with care and if the use is warranted, add NOLINT and a comment explaining why.' + ) + 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)) |