From 0b68c1c974040629fd929be1fccf098ee1c2aadd Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Fri, 15 Aug 2025 11:20:31 +0100 Subject: [PATCH] C++: Add some more tests for SloppyGlobal --- .../SloppyGlobal/SloppyGlobal.expected | 8 ++++++++ .../Best Practices/SloppyGlobal/main.cpp | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/cpp/ql/test/query-tests/Best Practices/SloppyGlobal/SloppyGlobal.expected b/cpp/ql/test/query-tests/Best Practices/SloppyGlobal/SloppyGlobal.expected index 692f7d81cd6..712c319c4c6 100644 --- a/cpp/ql/test/query-tests/Best Practices/SloppyGlobal/SloppyGlobal.expected +++ b/cpp/ql/test/query-tests/Best Practices/SloppyGlobal/SloppyGlobal.expected @@ -1,2 +1,10 @@ | main.cpp:3:5:3:5 | x | Poor global variable name 'x'. Prefer longer, descriptive names for globals (eg. kMyGlobalConstant, not foo). | | main.cpp:4:5:4:6 | ys | Poor global variable name 'ys'. Prefer longer, descriptive names for globals (eg. kMyGlobalConstant, not foo). | +| main.cpp:9:5:9:6 | v1 | Poor global variable name 'v1'. Prefer longer, descriptive names for globals (eg. kMyGlobalConstant, not foo). | +| main.cpp:10:5:10:6 | v2 | Poor global variable name 'v2'. Prefer longer, descriptive names for globals (eg. kMyGlobalConstant, not foo). | +| main.cpp:12:5:12:5 | v3 | Poor global variable name 'v3'. Prefer longer, descriptive names for globals (eg. kMyGlobalConstant, not foo). | +| main.cpp:14:3:14:3 | v4 | Poor global variable name 'v4'. Prefer longer, descriptive names for globals (eg. kMyGlobalConstant, not foo). | +| main.cpp:14:5:14:5 | v4 | Poor global variable name 'v4'. Prefer longer, descriptive names for globals (eg. kMyGlobalConstant, not foo). | +| main.cpp:16:3:16:3 | v5 | Poor global variable name 'v5'. Prefer longer, descriptive names for globals (eg. kMyGlobalConstant, not foo). | +| main.cpp:16:3:16:3 | v5 | Poor global variable name 'v5'. Prefer longer, descriptive names for globals (eg. kMyGlobalConstant, not foo). | +| main.cpp:16:5:16:5 | v5 | Poor global variable name 'v5'. Prefer longer, descriptive names for globals (eg. kMyGlobalConstant, not foo). | diff --git a/cpp/ql/test/query-tests/Best Practices/SloppyGlobal/main.cpp b/cpp/ql/test/query-tests/Best Practices/SloppyGlobal/main.cpp index 1b1b7ee0280..8ec2e49e38b 100644 --- a/cpp/ql/test/query-tests/Best Practices/SloppyGlobal/main.cpp +++ b/cpp/ql/test/query-tests/Best Practices/SloppyGlobal/main.cpp @@ -5,3 +5,19 @@ int ys[1000000]; // BAD: too short int descriptive_name; // GOOD: sufficient static int z; // GOOD: not a global + +int v1; +int v2; +template +T v3; +template +T v4; +template +T v5; + +void use_some_fs() { + v2 = 100; + v4 = 200; + v5 = 300; + v5 = "string"; +}