Skip to content

Conversation

metsma
Copy link
Contributor

@metsma metsma commented Sep 23, 2025

IB-8611

Signed-off-by: Raul Metsma raul@metsma.ee

metadata.push_back({uri, string(ref["MimeType"]), std::move(tst)});
};
add("META-INF/ASiCArchiveManifest.xml", "text/xml");
for(auto ref = doc/"DataObjectReference"; ref; ref++)

Check notice

Code scanning / CodeQL

Declaration hides variable Note

Variable ref hides another variable of the same name (on
line 80
).

Copilot Autofix

AI 4 days ago

To fix this problem, the name of the variable declared in the inner for-loop on line 87 should be changed so that it does not shadow the outer variable from line 80. The best approach is to rename the inner loop variable to something more descriptive, such as dataRef. This change only requires updating the loop variable to dataRef and updating all uses within the loop, which are currently ref. Since this for-loop is small, only a handful of places require the change:

  • Line 87: for(auto ref = ...; ref; ref++)for(auto dataRef = ...; dataRef; dataRef++)
  • Lines 89, 91, 92: All instances of ref["Rootfile"], ref["URI"], ref["MimeType"] should be replaced with dataRef[... ]

No imports or other method/variable definitions are needed: only the use of the loop variable. All changes are to src/SignatureTST.cpp in the region of lines 87–94.


Suggested changeset 1
src/SignatureTST.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/SignatureTST.cpp b/src/SignatureTST.cpp
--- a/src/SignatureTST.cpp
+++ b/src/SignatureTST.cpp
@@ -84,12 +84,12 @@
             metadata.emplace_back(std::move(uri), string(ref["MimeType"]), std::move(tst));
             file.clear();
 
-            for(auto ref = doc/"DataObjectReference"; ref; ref++)
+            for(auto dataRef = doc/"DataObjectReference"; dataRef; dataRef++)
             {
-                if(ref["Rootfile"] == "true")
+                if(dataRef["Rootfile"] == "true")
                 {
-                    file = util::File::fromUriPath(ref["URI"]);
-                    mime = ref["MimeType"];
+                    file = util::File::fromUriPath(dataRef["URI"]);
+                    mime = dataRef["MimeType"];
                 }
             }
         }
EOF
@@ -84,12 +84,12 @@
metadata.emplace_back(std::move(uri), string(ref["MimeType"]), std::move(tst));
file.clear();

for(auto ref = doc/"DataObjectReference"; ref; ref++)
for(auto dataRef = doc/"DataObjectReference"; dataRef; dataRef++)
{
if(ref["Rootfile"] == "true")
if(dataRef["Rootfile"] == "true")
{
file = util::File::fromUriPath(ref["URI"]);
mime = ref["MimeType"];
file = util::File::fromUriPath(dataRef["URI"]);
mime = dataRef["MimeType"];
}
}
}
Copilot is powered by AI and may make mistakes. Always verify output.
IB-8611

Signed-off-by: Raul Metsma <raul@metsma.ee>
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