-
Notifications
You must be signed in to change notification settings - Fork 868
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
@@ -16,9 +16,14 @@ | |||
// DateTime | |||
#include "Clock.cpp" | |||
#include "DateTime.cpp" | |||
#include "DateTimeFormat.cpp" | |||
#include "DateTimeFormatter.cpp" |
Check notice
Code scanning / CodeQL
Include header files only Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 16 days ago
To fix the issue, we need to refactor the code to include only header files in Foundation.cpp
. This involves the following steps:
- Move the declarations of classes, functions, and other interfaces from the
.cpp
files (e.g.,DateTimeFormatter.cpp
) to corresponding.h
header files (e.g.,DateTimeFormatter.h
). - Ensure that the
.cpp
files contain only the implementation of the declarations in the header files. - Replace the
#include
directives for.cpp
files inFoundation.cpp
with#include
directives for the corresponding.h
files.
This approach ensures that Foundation.cpp
adheres to the principle of including only header files and avoids exposing implementation details unnecessarily.
-
Copy modified line R20
@@ -19,3 +19,3 @@ | ||
#include "DateTimeFormat.cpp" | ||
#include "DateTimeFormatter.cpp" | ||
#include "DateTimeFormatter.h" | ||
#include "DateTimeParser.cpp" |
switch (yych) { | ||
case '=': goto yy36; | ||
default: goto yy2; | ||
} |
Check notice
Code scanning / CodeQL
No trivial switch statements Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 20 hours ago
To fix the issue, the trivial switch
statement on line 131 should be replaced with an if
/else
statement. Specifically:
- Replace the
switch
statement with anif
condition to check for the single non-default case (yych == '='
). - Use an
else
block to handle thedefault
case.
This change will simplify the control flow while preserving the existing functionality.
-
Copy modified lines R131-R134
@@ -130,5 +130,6 @@ | ||
yych = *++YYCURSOR; | ||
switch (yych) { | ||
case '=': goto yy36; | ||
default: goto yy2; | ||
if (yych == '=') { | ||
goto yy36; | ||
} else { | ||
goto yy2; | ||
} |
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 5 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 about 20 hours 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 5 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 about 20 hours ago
To fix the issue, the trivial switch
statement on line 228 should be replaced with an if
/else
statement. This simplifies the control flow while maintaining the same functionality. The replacement will involve checking the value of yych
using an if
condition for =
and an else
block for the default case.
-
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 about 20 hours ago
To fix the issue, the trivial switch
statement on line 238 should be replaced with an equivalent if
/else
structure. Specifically:
- The case for
'='
should be converted into anif
condition. - The
default
case should be converted into anelse
block.
This change will simplify the control flow while preserving the existing functionality. The replacement should be made directly in the Src/FilterEngine/FilterLexer.cpp
file.
-
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 about 20 hours ago
To fix the issue, the trivial switch
statement on line 248 should be replaced with an equivalent if
/else
structure. Specifically:
- Replace the
switch
statement with anif
condition to check for the single non-default case (yych == '='
). - Use an
else
block to handle the default case (goto yy22
).
This change will simplify the control flow while preserving the original behavior.
-
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 about 20 hours ago
To fix the issue, we will add comments to document the purpose of the SetMask2
test function and its individual test cases. The comments will explain the expected behavior of the SetMask
method for different inputs and the reasoning behind the assertions. This will make the function easier to understand and maintain without altering its functionality.
-
Copy modified lines R158-R159 -
Copy modified line R161 -
Copy modified line R165 -
Copy modified lines R170-R171 -
Copy modified lines R173-R174 -
Copy modified line R176
@@ -157,4 +157,6 @@ | ||
{ | ||
// Test case 1: SetMask with an empty string. | ||
// Expect all files and directories to be included, as no specific mask is applied. | ||
m_fileFilterHelper.SetMask(_T("")); | ||
EXPECT_EQ(true, m_fileFilterHelper.includeFile(_T("a.c"))); | ||
EXPECT_EQ(true, m_fileFilterHelper.includeFile(_T("a.c"))); // Any file should be 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(""))); // Any directory should be included. | ||
EXPECT_EQ(true, m_fileFilterHelper.includeDir(_T("svn"))); | ||
@@ -167,7 +169,9 @@ | ||
|
||
// Test case 2: SetMask with "*.c". | ||
// Expect only files with the ".c" extension to be included. | ||
m_fileFilterHelper.SetMask(_T("*.c")); | ||
EXPECT_EQ(true, m_fileFilterHelper.includeFile(_T("a.c"))); | ||
EXPECT_EQ(false, m_fileFilterHelper.includeFile(_T("a.cpp"))); | ||
EXPECT_EQ(true, m_fileFilterHelper.includeFile(_T("a.c"))); // Files with ".c" extension should be included. | ||
EXPECT_EQ(false, m_fileFilterHelper.includeFile(_T("a.cpp"))); // Files with other extensions should not be included. | ||
EXPECT_EQ(false, m_fileFilterHelper.includeFile(_T("a.ext"))); | ||
EXPECT_EQ(true, m_fileFilterHelper.includeDir(_T(""))); | ||
EXPECT_EQ(true, m_fileFilterHelper.includeDir(_T(""))); // Directories are not affected by file masks. | ||
EXPECT_EQ(true, m_fileFilterHelper.includeDir(_T("a"))); |
No description provided.