-
Notifications
You must be signed in to change notification settings - Fork 869
WIP #2802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
WIP #2802
Conversation
INSTANTIATE_TEST_SUITE_P( | ||
OptimizationCases, | ||
FilterExpressionTest, | ||
::testing::Values( | ||
FilterTestParam{ true }, | ||
FilterTestParam{ false } | ||
) | ||
); |
Check notice
Code scanning / CodeQL
Unused static function Note
gtest_OptimizationCasesFilterExpressionTest_dummy_
Static function gtest_OptimizationCasesFilterExpressionTest_EvalGenerator_ is unreachable (
gtest_OptimizationCasesFilterExpressionTest_dummy_
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 11 days ago
To fix the issue, the unused static function generated by the INSTANTIATE_TEST_SUITE_P
macro should be removed. This involves removing the macro invocation itself, as it is responsible for generating the unused function. Additionally, any associated test cases or parameters that rely on this macro should be reviewed and removed if they are redundant or unnecessary.
Steps to fix:
- Remove the
INSTANTIATE_TEST_SUITE_P
macro invocation on line 670 and its associated parameters. - Ensure that the removal does not affect other parts of the test suite or the functionality of the codebase.
- Verify that the remaining tests still execute correctly and cover the intended functionality.
-
Copy modified line R670
@@ -669,10 +669,3 @@ | ||
|
||
INSTANTIATE_TEST_SUITE_P( | ||
OptimizationCases, | ||
FilterExpressionTest, | ||
::testing::Values( | ||
FilterTestParam{ true }, | ||
FilterTestParam{ false } | ||
) | ||
); | ||
// Removed unused INSTANTIATE_TEST_SUITE_P macro invocation. | ||
|
INSTANTIATE_TEST_SUITE_P( | ||
OptimizationCases, | ||
FilterExpressionTest, | ||
::testing::Values( | ||
FilterTestParam{ true }, | ||
FilterTestParam{ false } | ||
) | ||
); |
Check notice
Code scanning / CodeQL
Unused static variable Note
Copilot Autofix
AI 1 day ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
|
||
} | ||
|
||
TEST_P(FilterExpressionTest, FileAttributes) |
Check warning
Code scanning / CodeQL
Poorly documented large function Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 11 days ago
To fix the issue, we will add comments to document the purpose and logic of the FilterExpressionTest, FileAttributes
function. This includes explaining the setup of contexts, the initialization of test data, and the purpose of each major block of code. The comments will provide clarity on what the function is testing and how it achieves its goals, without altering the existing functionality.
-
Copy modified line R385 -
Copy modified lines R387-R388 -
Copy modified lines R390-R391 -
Copy modified lines R393-R395 -
Copy modified lines R400-R401 -
Copy modified lines R406-R407 -
Copy modified lines R410-R411
@@ -384,6 +384,13 @@ | ||
{ | ||
// Set up the path context with multiple source directories. | ||
PathContext paths(L"C:\\dev\\winmerge\\src", L"D:\\dev\\winmerge\\src", L"E:\\dev\\winmerge\\src"); | ||
|
||
// Initialize the diff context for the test. | ||
CDiffContext ctxt(paths, 0); | ||
|
||
// Create and configure a DIFFITEM object to represent file attributes and metadata. | ||
DIFFITEM di; | ||
int tzd; | ||
int tzd; // Timezone offset variable. | ||
|
||
// Configure the first file's attributes and metadata. | ||
di.diffFileInfo[0].path = L"abc"; | ||
@@ -392,2 +399,4 @@ | ||
di.diffFileInfo[0].flags.attributes = FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE; | ||
|
||
// Parse and set the file's modification and creation timestamps. | ||
Poco::DateTime dt0 = Poco::DateTimeParser::parse("%Y-%m-%d %H:%M:%S", "2025-05-16 15:34:56", tzd); | ||
@@ -396,4 +405,8 @@ | ||
di.diffFileInfo[0].ctime = dt0.timestamp(); | ||
|
||
// Set the file's encoding and version information. | ||
di.diffFileInfo[0].encoding.SetCodepage(65001); | ||
di.diffFileInfo[0].version.SetFileVersion(0x00020010, 0x00300002); | ||
|
||
// Configure additional files for the test. | ||
di.diffFileInfo[1].path = L"abc"; |
switch (yych) { | ||
case '=': goto yy46; | ||
default: goto yy18; | ||
} |
Check notice
Code scanning / CodeQL
No trivial switch statements Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 days ago
To fix the issue, the trivial switch
statement on line 228 should be replaced with an if
/else
structure. This will simplify the control flow while maintaining the same functionality. Specifically:
- Replace the
switch
statement with anif
condition for the=
case and anelse
block for the default case. - Ensure the replacement preserves the behavior of the original code.
-
Copy modified lines R228-R231
@@ -227,5 +227,6 @@ | ||
yych = *++YYCURSOR; | ||
switch (yych) { | ||
case '=': goto yy46; | ||
default: goto yy18; | ||
if (yych == '=') { | ||
goto yy46; | ||
} else { | ||
goto yy18; | ||
} |
switch (yych) { | ||
case '=': goto yy47; | ||
default: goto yy20; | ||
} |
Check notice
Code scanning / CodeQL
No trivial switch statements Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 days ago
To fix the issue, the trivial switch
statement on line 238 should be replaced with an if
/else
structure. The if
condition will check for the '='
case, and the else
block will handle the default
case. This change will simplify the code while preserving its functionality. No additional imports, methods, or definitions are required.
-
Copy modified lines R238-R241
@@ -237,5 +237,6 @@ | ||
yych = *++YYCURSOR; | ||
switch (yych) { | ||
case '=': goto yy47; | ||
default: goto yy20; | ||
if (yych == '=') { | ||
goto yy47; | ||
} else { | ||
goto yy20; | ||
} |
switch (yych) { | ||
case '=': goto yy48; | ||
default: goto yy22; | ||
} |
Check notice
Code scanning / CodeQL
No trivial switch statements Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 days ago
To fix the issue, the trivial switch
statement on line 248 should be replaced with an equivalent if
/else
structure. This will simplify the control flow while maintaining the same functionality. Specifically:
- Replace the
switch
statement with anif
condition for the'='
case. - Use an
else
block for thedefault
case.
This change will only affect the highlighted switch
statement and will not interfere with the rest of the code.
-
Copy modified lines R248-R251
@@ -247,5 +247,6 @@ | ||
yych = *++YYCURSOR; | ||
switch (yych) { | ||
case '=': goto yy48; | ||
default: goto yy22; | ||
if (yych == '=') { | ||
goto yy48; | ||
} else { | ||
goto yy22; | ||
} |
@@ -140,11 +153,8 @@ | |||
|
|||
} | |||
|
|||
TEST_F(FileFilterHelperTest, SetMask) | |||
TEST_F(FileFilterHelperTest, SetMask2) |
Check warning
Code scanning / CodeQL
Poorly documented large function Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 days ago
To address the issue, comments will be added to the SetMask2
function to document its purpose, the logic behind the test cases, and the expected outcomes. This will improve readability and maintainability without altering the functionality of the code. Specifically:
- Add a comment at the beginning of the function to explain its overall purpose.
- Add inline comments to describe the purpose of each block of test cases and the expected results.
-
Copy modified lines R158-R159 -
Copy modified line R161 -
Copy modified line R165 -
Copy modified line R170 -
Copy modified line R172 -
Copy modified lines R175-R176
@@ -157,4 +157,6 @@ | ||
{ | ||
// Test the behavior of SetMask with different patterns and its effect on includeFile and includeDir. | ||
// The first block tests the default mask (empty string), which should include all files and directories. | ||
m_fileFilterHelper.SetMask(_T("")); | ||
EXPECT_EQ(true, m_fileFilterHelper.includeFile(_T("a.c"))); | ||
EXPECT_EQ(true, m_fileFilterHelper.includeFile(_T("a.c"))); // All files are included. | ||
EXPECT_EQ(true, m_fileFilterHelper.includeFile(_T("a.cpp"))); | ||
@@ -162,3 +164,3 @@ | ||
EXPECT_EQ(true, m_fileFilterHelper.includeFile(_T(""))); | ||
EXPECT_EQ(true, m_fileFilterHelper.includeDir(_T(""))); | ||
EXPECT_EQ(true, m_fileFilterHelper.includeDir(_T(""))); // All directories are included. | ||
EXPECT_EQ(true, m_fileFilterHelper.includeDir(_T("svn"))); | ||
@@ -167,8 +169,9 @@ | ||
|
||
// The second block tests a specific mask (*.c), which should include only files with the .c extension. | ||
m_fileFilterHelper.SetMask(_T("*.c")); | ||
EXPECT_EQ(true, m_fileFilterHelper.includeFile(_T("a.c"))); | ||
EXPECT_EQ(true, m_fileFilterHelper.includeFile(_T("a.c"))); // Only .c files are included. | ||
EXPECT_EQ(false, m_fileFilterHelper.includeFile(_T("a.cpp"))); | ||
EXPECT_EQ(false, m_fileFilterHelper.includeFile(_T("a.ext"))); | ||
EXPECT_EQ(true, m_fileFilterHelper.includeDir(_T(""))); | ||
EXPECT_EQ(true, m_fileFilterHelper.includeDir(_T("a"))); | ||
EXPECT_EQ(true, m_fileFilterHelper.includeDir(_T(""))); // Directories are still included. | ||
EXPECT_EQ(true, m_fileFilterHelper.includeDir(_T("a"))); // Directories are unaffected by file masks. | ||
EXPECT_EQ(true, m_fileFilterHelper.includeDir(_T("a.b"))); |
No description provided.