Skip to content

Commit 9068ae1

Browse files
committedMar 28, 2024
Add a lint for toplevel "using namespace" in headers.
We had all sorts of things using the wrong namespaces because everything was being imported into multiple namespaces if things happened to include certain headers. Remove the "using namespace" bits in core headers, fix the resulting compile issues, add a lint so people stop doing that.
1 parent ef01670 commit 9068ae1

File tree

43 files changed

+134
-108
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+134
-108
lines changed
 

‎.github/workflows/lint.yml

+15
Original file line numberDiff line numberDiff line change
@@ -285,3 +285,18 @@ jobs:
285285
if: always()
286286
run: |
287287
git grep -I -n 'SuccessOrExit([^=)]*(' -- './*' ':(exclude).github/workflows/lint.yml' && exit 1 || exit 0
288+
289+
# git grep exits with 0 if it finds a match, but we want
290+
# to fail (exit nonzero) on match.
291+
- name: Check for use of "using namespace" outside of a class/function in headers.
292+
if: always()
293+
run: |
294+
# Various platforms have `using namespace chip::Ble` in their BLEManager* headers; just exclude those for now.
295+
#
296+
# Exclude platform openiotsdk bits that do this in their persistent storage header.
297+
#
298+
# Also exclude examples (for now) and third_party, which have various instances of this.
299+
#
300+
# Ignore uses of `System::Clock::Literals`, because that's the only way to have things using _ms32 or whatnot
301+
# in a header file.
302+
git grep -I -n -e '^using namespace' --and --not -e 'System::Clock::Literals' -- './**/*.h' ':(exclude)src/platform/*/BLEManager*.h' ':(exclude)src/platform/openiotsdk/KVPsaPsStore.h' ':(exclude)./examples' ':(exclude)./third_party' && exit 1 || exit 0

‎examples/chip-tool/commands/pairing/IssueNOCChainCommand.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class IssueNOCChainCommand : public CHIPCommand
4646

4747
static void OnDeviceNOCChainGeneration(void * context, CHIP_ERROR status, const chip::ByteSpan & noc,
4848
const chip::ByteSpan & icac, const chip::ByteSpan & rcac,
49-
chip::Optional<chip::IdentityProtectionKeySpan> ipk,
49+
chip::Optional<chip::Crypto::IdentityProtectionKeySpan> ipk,
5050
chip::Optional<chip::NodeId> adminSubject)
5151
{
5252
auto command = static_cast<IssueNOCChainCommand *>(context);

0 commit comments

Comments
 (0)