From a96e834d2101a31a363c7488ec2af81a7ba38f1a Mon Sep 17 00:00:00 2001 From: Ryan Ho Date: Wed, 24 Apr 2024 22:42:24 -0400 Subject: [PATCH] Removed violation.cpp + added to .gitignore --- .gitignore | 3 ++- tests/setup/violation.cpp | 41 --------------------------------------- 2 files changed, 2 insertions(+), 42 deletions(-) delete mode 100644 tests/setup/violation.cpp diff --git a/.gitignore b/.gitignore index 5575a0d..659846b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /build -/vscode \ No newline at end of file +/vscode +/tests/setup/violation.cpp \ No newline at end of file diff --git a/tests/setup/violation.cpp b/tests/setup/violation.cpp deleted file mode 100644 index 03614bd..0000000 --- a/tests/setup/violation.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include // For std::rand -#include -#include - -// Function with an uninitialized variable -int calculate(int x) { - int result; // Uninitialized variable, can cause unpredictable behavior - if (x > 10) { - result = x * 2; - } - // If x <= 10, result is uninitialized, causing an issue - return result; // This could return an indeterminate value -} - -// Function with raw pointers and no null checks -void useRawPointer() { - int *ptr = new int(10); // Raw pointer allocation - std::cout << "Pointer value: " << *ptr << std::endl; - delete ptr; // Manual memory management -} - -// Function with deprecated function usage -void useDeprecatedFunction() { - int randomNumber = std::rand(); // std::rand() is considered outdated - std::cout << "Random number: " << randomNumber << std::endl; -} - -// Code with style issues (inconsistent naming, spacing) -void styleIssue() { // Inconsistent spacing - int MixedCaseVar = - 10; // Inconsistent naming (use lowerCamelCase or snake_case) - std::cout << "Value: " << MixedCaseVar << std::endl; -} - -// Function without return value (missing return in non-void function) -int missingReturn(int x) { - if (x > 5) { - return x * 2; - } - // Missing return statement for cases where x <= 5 -}