Skip to content

Commit fea14fe

Browse files
committed
AC-3483:: SVC false-positive: modifying system.xml file from another module
1 parent e73049d commit fea14fe

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/Analyzer/SystemXml/Analyzer.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function analyze($registryBefore, $registryAfter)
9898
if ($addedNodes) {
9999
$afterFile = $registryAfter->mapping[XmlRegistry::NODES_KEY][$moduleName];
100100
if (strpos($afterFile, '_files') !== false) {
101-
$this->reportAddedNodes($afterFile,$addedNodes);
101+
$this->reportAddedNodes($afterFile, $addedNodes);
102102
} else {
103103
$baseDir = $this->getBaseDir($afterFile);
104104
foreach ($addedNodes as $nodeId => $node) {
@@ -116,7 +116,13 @@ public function analyze($registryBefore, $registryAfter)
116116
list($sectionId, $groupId, $fieldId) = $extractedData;
117117

118118
// Call function to check if this field is duplicated in other system.xml files
119-
$isDuplicated = $this->isDuplicatedFieldInXml($baseDir, $sectionId, $groupId, $fieldId, $afterFile);
119+
$isDuplicated = $this->isDuplicatedFieldInXml(
120+
$baseDir,
121+
$sectionId,
122+
$groupId,
123+
$fieldId,
124+
$afterFile
125+
);
120126

121127
foreach ($isDuplicated as $isDuplicatedItem) {
122128
if ($isDuplicatedItem['status'] === 'duplicate') {
@@ -162,7 +168,7 @@ private function getSystemXmlFiles($magentoBaseDir, $excludeFile = null)
162168
{
163169
$systemXmlFiles = [];
164170
$directoryToSearch = [
165-
$magentoBaseDir.'/app/code'
171+
$magentoBaseDir . '/app/code'
166172
];
167173

168174
// Check if 'vendor' directory exists, and only add it if it does
@@ -363,8 +369,13 @@ private function reportRemovedNodes(string $file, array $nodes)
363369
* @return array
364370
* @throws \Exception
365371
*/
366-
private function isDuplicatedFieldInXml(?string $baseDir, string $sectionId, string $groupId, ?string $fieldId, string $afterFile): array
367-
{
372+
private function isDuplicatedFieldInXml(
373+
?string $baseDir,
374+
string $sectionId,
375+
string $groupId,
376+
?string $fieldId,
377+
string $afterFile
378+
): array {
368379
$hasDuplicate = false;
369380

370381
$result = [

0 commit comments

Comments
 (0)