-
Notifications
You must be signed in to change notification settings - Fork 837
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
WIP #2663
base: master
Are you sure you want to change the base?
WIP #2663
Conversation
@@ -145,6 +137,95 @@ | |||
} | |||
} | |||
|
|||
void CMergeFrameCommon::LogComparisonStart(int nFiles, const FileLocation ifileloc[], const String descs[], const PackingInfo* infoUnpacker, const PrediffingInfo* infoPrediffer) |
Check notice
Code scanning / CodeQL
No raw arrays in interfaces Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 24 hours ago
To fix the problem, we should replace the raw arrays in the function CMergeFrameCommon::LogComparisonStart
with container classes such as std::vector
. This will ensure that the function parameters are handled safely and avoid issues related to array decay.
- Replace
const FileLocation ifileloc[]
withconst std::vector<FileLocation>& ifileloc
. - Replace
const String descs[]
withconst std::vector<String>& descs
.
This change will require updating the function signature and the corresponding function calls to use std::vector
instead of raw arrays.
-
Copy modified lines R17-R19 -
Copy modified lines R142-R156
@@ -16,4 +16,5 @@ | ||
#include "CompareStats.h" | ||
#include "IMergeDoc.h" | ||
#include <../src/mfc/afximpl.h> | ||
#include "IMergeDoc.h" | ||
#include <vector> | ||
#include <../src/mfc/afximpl.h> | ||
|
||
@@ -140,17 +141,17 @@ | ||
|
||
void CMergeFrameCommon::LogComparisonStart(int nFiles, const FileLocation ifileloc[], const String descs[], const PackingInfo* infoUnpacker, const PrediffingInfo* infoPrediffer) | ||
{ | ||
String str[3]; | ||
for (int i = 0; i < nFiles; ++i) | ||
{ | ||
str[i] = ifileloc[i].filepath; | ||
if (descs && !descs[i].empty()) | ||
str[i] += _T("(") + descs[i] + _T(")"); | ||
} | ||
String s = (nFiles < 3 ? | ||
strutils::format_string2(_("Comparing %1 with %2"), str[0], str[1]) : | ||
strutils::format_string3(_("Comparing %1 with %2 and %3"), str[0], str[1], str[2]) | ||
); | ||
RootLogger::Info(s + GetPluginInfoString(infoUnpacker, infoPrediffer)); | ||
} | ||
void CMergeFrameCommon::LogComparisonStart(int nFiles, const std::vector<FileLocation>& ifileloc, const std::vector<String>& descs, const PackingInfo* infoUnpacker, const PrediffingInfo* infoPrediffer) | ||
{ | ||
String str[3]; | ||
for (int i = 0; i < nFiles; ++i) | ||
{ | ||
str[i] = ifileloc[i].filepath; | ||
if (!descs.empty() && !descs[i].empty()) | ||
str[i] += _T("(") + descs[i] + _T(")"); | ||
} | ||
String s = (nFiles < 3 ? | ||
strutils::format_string2(_("Comparing %1 with %2"), str[0], str[1]) : | ||
strutils::format_string3(_("Comparing %1 with %2 and %3"), str[0], str[1], str[2]) | ||
); | ||
RootLogger::Info(s + GetPluginInfoString(infoUnpacker, infoPrediffer)); | ||
} | ||
|
RootLogger::Info(s + GetPluginInfoString(infoUnpacker, infoPrediffer)); | ||
} | ||
|
||
void CMergeFrameCommon::LogComparisonStart(const PathContext& paths, const String descs[], const PackingInfo* infoUnpacker, const PrediffingInfo* infoPrediffer) |
Check notice
Code scanning / CodeQL
No raw arrays in interfaces Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 24 hours ago
To fix the problem, we should replace the raw array parameter const String descs[]
with a container class such as std::vector<String>
. This change will ensure that the size of the array is correctly managed and prevent any issues related to array decay.
- Change the parameter type from
const String descs[]
toconst std::vector<String>& descs
in the functionCMergeFrameCommon::LogComparisonStart
. - Update the function implementation to work with
std::vector
instead of raw arrays. - Ensure that any calls to this function are updated to pass a
std::vector<String>
instead of a raw array.
-
Copy modified lines R157-R170
@@ -156,16 +156,16 @@ | ||
|
||
void CMergeFrameCommon::LogComparisonStart(const PathContext& paths, const String descs[], const PackingInfo* infoUnpacker, const PrediffingInfo* infoPrediffer) | ||
{ | ||
String str[3]; | ||
for (int i = 0; i < paths.GetSize(); ++i) | ||
{ | ||
str[i] = paths[i]; | ||
if (descs && !descs[i].empty()) | ||
str[i] += _T("(") + descs[i] + _T(")"); | ||
} | ||
String s = (paths.GetSize() < 3) ? | ||
strutils::format_string2(_("Comparing %1 with %2"), str[0], str[1]) : | ||
strutils::format_string3(_("Comparing %1 with %2 and %3"), str[0], str[1], str[2]); | ||
RootLogger::Info(s + GetPluginInfoString(infoUnpacker, infoPrediffer)); | ||
} | ||
void CMergeFrameCommon::LogComparisonStart(const PathContext& paths, const std::vector<String>& descs, const PackingInfo* infoUnpacker, const PrediffingInfo* infoPrediffer) | ||
{ | ||
String str[3]; | ||
for (int i = 0; i < paths.GetSize(); ++i) | ||
{ | ||
str[i] = paths[i]; | ||
if (!descs.empty() && !descs[i].empty()) | ||
str[i] += _T("(") + descs[i] + _T(")"); | ||
} | ||
String s = (paths.GetSize() < 3) ? | ||
strutils::format_string2(_("Comparing %1 with %2"), str[0], str[1]) : | ||
strutils::format_string3(_("Comparing %1 with %2 and %3"), str[0], str[1], str[2]); | ||
RootLogger::Info(s + GetPluginInfoString(infoUnpacker, infoPrediffer)); | ||
} | ||
|
@@ -22,7 +23,7 @@ | |||
/** | |||
* @brief Document class for bytewise merging two files presented as hexdumps | |||
*/ | |||
class CHexMergeDoc : public CDocument, public IMergeDoc | |||
class CHexMergeDoc : public CDocument, public IMergeDoc, public IMDITab |
Check notice
Code scanning / CodeQL
Undisciplined multiple inheritance Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 24 hours ago
To fix the problem, we need to ensure that CHexMergeDoc
conforms to the restricted form of multiple inheritance. This means:
- Inheriting from only one protected base class.
- Inheriting from multiple interfaces (pure virtual classes).
- Inheriting from multiple private implementations if needed.
In this case, we should:
- Ensure that
IMergeDoc
andIMDITab
are pure virtual classes (interfaces). - Change the inheritance of
IMergeDoc
andIMDITab
to public to indicate they are interfaces. - Ensure
CDocument
is the only class providing implementation and is inherited as protected.
-
Copy modified line R26
@@ -25,3 +25,3 @@ | ||
*/ | ||
class CHexMergeDoc : public CDocument, public IMergeDoc, public IMDITab | ||
class CHexMergeDoc : protected CDocument, public IMergeDoc, public IMDITab | ||
{ |
@@ -27,7 +28,7 @@ | |||
/** | |||
* @brief Frame class for file compare, handles panes, statusbar etc. | |||
*/ | |||
class CImgMergeFrame : public CMergeFrameCommon,public IMergeDoc | |||
class CImgMergeFrame : public CMergeFrameCommon, public IMergeDoc, public IMDITab |
Check notice
Code scanning / CodeQL
Undisciplined multiple inheritance Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 24 hours ago
To fix the problem, we need to refactor the CImgMergeFrame
class to conform to the restricted form of multiple inheritance. This involves:
- Ensuring that the class inherits from only one protected base class.
- Inheriting from multiple interfaces (pure virtual classes) if needed.
- Using private inheritance for any implementation classes.
In this case, we can make IMergeDoc
and IMDITab
interfaces (pure virtual classes) and inherit from them publicly. We will keep CMergeFrameCommon
as the single protected base class.
-
Copy modified line R31
@@ -30,3 +30,3 @@ | ||
*/ | ||
class CImgMergeFrame : public CMergeFrameCommon, public IMergeDoc, public IMDITab | ||
class CImgMergeFrame : protected CMergeFrameCommon, public IMergeDoc, public IMDITab | ||
{ |
@@ -120,15 +121,15 @@ | |||
/** | |||
* @brief Document class for merging two files | |||
*/ | |||
class CMergeDoc : public CDocument, public IMergeDoc | |||
class CMergeDoc : public CDocument, public IMergeDoc, public IMDITab |
Check notice
Code scanning / CodeQL
Undisciplined multiple inheritance Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 24 hours ago
To fix the problem, we need to ensure that CMergeDoc
conforms to the restricted form of multiple inheritance. This means:
- Inheriting from only one protected base class.
- Inheriting from multiple interfaces (pure virtual classes).
- Inheriting from multiple private implementations.
In this case, we can assume that IMergeDoc
and IMDITab
are interfaces (pure virtual classes). We should change the inheritance of IMDITab
to private to conform to the restricted form of multiple inheritance.
-
Copy modified line R124
@@ -123,3 +123,3 @@ | ||
*/ | ||
class CMergeDoc : public CDocument, public IMergeDoc, public IMDITab | ||
class CMergeDoc : public CDocument, public IMergeDoc, private IMDITab | ||
{ |
@@ -24,7 +25,7 @@ | |||
/** | |||
* @brief Frame class for file compare, handles panes, statusbar etc. | |||
*/ | |||
class CWebPageDiffFrame : public CMergeFrameCommon,public IMergeDoc | |||
class CWebPageDiffFrame : public CMergeFrameCommon, public IMergeDoc, public IMDITab |
Check notice
Code scanning / CodeQL
Undisciplined multiple inheritance Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 24 hours ago
To fix the problem, we need to ensure that CWebPageDiffFrame
conforms to the restricted form of multiple inheritance. This means it should inherit from only one public/protected class and any number of pure virtual interfaces.
The best way to fix this without changing existing functionality is to:
- Identify which of the inherited classes (
CMergeFrameCommon
,IMergeDoc
,IMDITab
) are pure virtual interfaces. - Change the inheritance of
CWebPageDiffFrame
to inherit from only one public/protected class and the rest as pure virtual interfaces.
-
Copy modified line R28
@@ -27,3 +27,3 @@ | ||
*/ | ||
class CWebPageDiffFrame : public CMergeFrameCommon, public IMergeDoc, public IMDITab | ||
class CWebPageDiffFrame : public CMergeFrameCommon, public IMergeDoc, private IMDITab | ||
{ |
No description provided.