Skip to content
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

Draft
wants to merge 62 commits into
base: master
Choose a base branch
from
Draft

WIP #2663

wants to merge 62 commits into from

Conversation

sdottaka
Copy link
Member

@sdottaka sdottaka commented Mar 1, 2025

No description provided.

@@ -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

Raw arrays should not be used in interfaces. A container class should be used instead.

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[] with const std::vector<FileLocation>& ifileloc.
  • Replace const String descs[] with const 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.

Suggested changeset 1
Src/MergeFrameCommon.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Src/MergeFrameCommon.cpp b/Src/MergeFrameCommon.cpp
--- a/Src/MergeFrameCommon.cpp
+++ b/Src/MergeFrameCommon.cpp
@@ -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));
+}
 
EOF
@@ -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));
}

Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
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

Raw arrays should not be used in interfaces. A container class should be used instead.

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[] to const std::vector<String>& descs in the function CMergeFrameCommon::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.
Suggested changeset 1
Src/MergeFrameCommon.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Src/MergeFrameCommon.cpp b/Src/MergeFrameCommon.cpp
--- a/Src/MergeFrameCommon.cpp
+++ b/Src/MergeFrameCommon.cpp
@@ -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));
+}
 
EOF
@@ -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));
}

Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@@ -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

Multiple inheritance should not be used with 2 interfaces, 0 private implementations, 0 protected implementations, and 1 public implementations.

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:

  1. Ensure that IMergeDoc and IMDITab are pure virtual classes (interfaces).
  2. Change the inheritance of IMergeDoc and IMDITab to public to indicate they are interfaces.
  3. Ensure CDocument is the only class providing implementation and is inherited as protected.
Suggested changeset 1
Src/HexMergeDoc.h

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Src/HexMergeDoc.h b/Src/HexMergeDoc.h
--- a/Src/HexMergeDoc.h
+++ b/Src/HexMergeDoc.h
@@ -25,3 +25,3 @@
  */
-class CHexMergeDoc : public CDocument, public IMergeDoc, public IMDITab
+class CHexMergeDoc : protected CDocument, public IMergeDoc, public IMDITab
 {
EOF
@@ -25,3 +25,3 @@
*/
class CHexMergeDoc : public CDocument, public IMergeDoc, public IMDITab
class CHexMergeDoc : protected CDocument, public IMergeDoc, public IMDITab
{
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@@ -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

Multiple inheritance should not be used with 2 interfaces, 0 private implementations, 0 protected implementations, and 1 public implementations.

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.

Suggested changeset 1
Src/ImgMergeFrm.h

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Src/ImgMergeFrm.h b/Src/ImgMergeFrm.h
--- a/Src/ImgMergeFrm.h
+++ b/Src/ImgMergeFrm.h
@@ -30,3 +30,3 @@
  */
-class CImgMergeFrame : public CMergeFrameCommon, public IMergeDoc, public IMDITab
+class CImgMergeFrame : protected CMergeFrameCommon, public IMergeDoc, public IMDITab
 {
EOF
@@ -30,3 +30,3 @@
*/
class CImgMergeFrame : public CMergeFrameCommon, public IMergeDoc, public IMDITab
class CImgMergeFrame : protected CMergeFrameCommon, public IMergeDoc, public IMDITab
{
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@@ -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

Multiple inheritance should not be used with 2 interfaces, 0 private implementations, 0 protected implementations, and 1 public implementations.

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.

Suggested changeset 1
Src/MergeDoc.h

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Src/MergeDoc.h b/Src/MergeDoc.h
--- a/Src/MergeDoc.h
+++ b/Src/MergeDoc.h
@@ -123,3 +123,3 @@
  */
-class CMergeDoc : public CDocument, public IMergeDoc, public IMDITab
+class CMergeDoc : public CDocument, public IMergeDoc, private IMDITab
 {
EOF
@@ -123,3 +123,3 @@
*/
class CMergeDoc : public CDocument, public IMergeDoc, public IMDITab
class CMergeDoc : public CDocument, public IMergeDoc, private IMDITab
{
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@@ -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

Multiple inheritance should not be used with 2 interfaces, 0 private implementations, 0 protected implementations, and 1 public implementations.

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:

  1. Identify which of the inherited classes (CMergeFrameCommon, IMergeDoc, IMDITab) are pure virtual interfaces.
  2. Change the inheritance of CWebPageDiffFrame to inherit from only one public/protected class and the rest as pure virtual interfaces.
Suggested changeset 1
Src/WebPageDiffFrm.h

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Src/WebPageDiffFrm.h b/Src/WebPageDiffFrm.h
--- a/Src/WebPageDiffFrm.h
+++ b/Src/WebPageDiffFrm.h
@@ -27,3 +27,3 @@
  */
-class CWebPageDiffFrame : public CMergeFrameCommon, public IMergeDoc, public IMDITab
+class CWebPageDiffFrame : public CMergeFrameCommon, public IMergeDoc, private IMDITab
 {
EOF
@@ -27,3 +27,3 @@
*/
class CWebPageDiffFrame : public CMergeFrameCommon, public IMergeDoc, public IMDITab
class CWebPageDiffFrame : public CMergeFrameCommon, public IMergeDoc, private IMDITab
{
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant