mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-15 18:34:57 +03:00
fix(cfe-validate): skip own extension sub-items in check 10
Add is_borrowed_sub_item filter to distinguish borrowed vs own sub-items inside borrowed objects. Own Attributes/TabularSections/ EnumValues (added by extension) lack ObjectBelonging and ExtendedConfigurationObject — validating them as borrowed was a false positive. Inspired by PR #6. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# cfe-validate v1.2 — Validate 1C configuration extension structure (CFE)
|
# cfe-validate v1.3 — Validate 1C configuration extension structure (CFE)
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
@@ -537,6 +537,17 @@ if ($script:stopped) { & $finalize; exit 1 }
|
|||||||
$script:enumValuesIndex = @{}
|
$script:enumValuesIndex = @{}
|
||||||
$script:formList = @()
|
$script:formList = @()
|
||||||
|
|
||||||
|
# Helper: check if sub-item has explicit borrowed metadata
|
||||||
|
function Test-BorrowedSubItem {
|
||||||
|
param($subItem, $nsm)
|
||||||
|
$subProps = $subItem.SelectSingleNode("md:Properties", $nsm)
|
||||||
|
if (-not $subProps) { return $false }
|
||||||
|
$subOb = $subProps.SelectSingleNode("md:ObjectBelonging", $nsm)
|
||||||
|
if ($subOb -and $subOb.InnerText) { return $true }
|
||||||
|
$subExt = $subProps.SelectSingleNode("md:ExtendedConfigurationObject", $nsm)
|
||||||
|
return [bool]($subExt -and $subExt.InnerText)
|
||||||
|
}
|
||||||
|
|
||||||
# Helper: validate a borrowed Attribute/EnumValue sub-item
|
# Helper: validate a borrowed Attribute/EnumValue sub-item
|
||||||
function Validate-BorrowedSubItem {
|
function Validate-BorrowedSubItem {
|
||||||
param([string]$checkNum, [string]$context, [string]$subType, $subItem, $nsm)
|
param([string]$checkNum, [string]$context, [string]$subType, $subItem, $nsm)
|
||||||
@@ -638,12 +649,14 @@ if ($childObjNode) {
|
|||||||
$subType = $subItem.LocalName
|
$subType = $subItem.LocalName
|
||||||
|
|
||||||
if ($subType -eq "Attribute") {
|
if ($subType -eq "Attribute") {
|
||||||
|
if (-not (Test-BorrowedSubItem $subItem $objNs)) { continue }
|
||||||
$subItemCount++
|
$subItemCount++
|
||||||
if (-not (Validate-BorrowedSubItem "10" $ctx "Attribute" $subItem $objNs)) {
|
if (-not (Validate-BorrowedSubItem "10" $ctx "Attribute" $subItem $objNs)) {
|
||||||
$check10Ok = $false
|
$check10Ok = $false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($subType -eq "TabularSection") {
|
elseif ($subType -eq "TabularSection") {
|
||||||
|
if (-not (Test-BorrowedSubItem $subItem $objNs)) { continue }
|
||||||
$subItemCount++
|
$subItemCount++
|
||||||
if (-not (Validate-BorrowedSubItem "10" $ctx "TabularSection" $subItem $objNs)) {
|
if (-not (Validate-BorrowedSubItem "10" $ctx "TabularSection" $subItem $objNs)) {
|
||||||
$check10Ok = $false
|
$check10Ok = $false
|
||||||
@@ -673,6 +686,7 @@ if ($childObjNode) {
|
|||||||
if ($tsChildObjs) {
|
if ($tsChildObjs) {
|
||||||
foreach ($tsAttr in $tsChildObjs.ChildNodes) {
|
foreach ($tsAttr in $tsChildObjs.ChildNodes) {
|
||||||
if ($tsAttr.NodeType -ne 'Element' -or $tsAttr.LocalName -ne "Attribute") { continue }
|
if ($tsAttr.NodeType -ne 'Element' -or $tsAttr.LocalName -ne "Attribute") { continue }
|
||||||
|
if (-not (Test-BorrowedSubItem $tsAttr $objNs)) { continue }
|
||||||
$subItemCount++
|
$subItemCount++
|
||||||
if (-not (Validate-BorrowedSubItem "10" "${ctx}.ТЧ.${tsLabel}" "Attribute" $tsAttr $objNs)) {
|
if (-not (Validate-BorrowedSubItem "10" "${ctx}.ТЧ.${tsLabel}" "Attribute" $tsAttr $objNs)) {
|
||||||
$check10Ok = $false
|
$check10Ok = $false
|
||||||
@@ -682,6 +696,7 @@ if ($childObjNode) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($subType -eq "EnumValue" -and $typeName -eq "Enum") {
|
elseif ($subType -eq "EnumValue" -and $typeName -eq "Enum") {
|
||||||
|
if (-not (Test-BorrowedSubItem $subItem $objNs)) { continue }
|
||||||
$subItemCount++
|
$subItemCount++
|
||||||
if (Validate-BorrowedSubItem "10" $ctx "EnumValue" $subItem $objNs) {
|
if (Validate-BorrowedSubItem "10" $ctx "EnumValue" $subItem $objNs) {
|
||||||
$evName = $subItem.SelectSingleNode("md:Properties/md:Name", $objNs)
|
$evName = $subItem.SelectSingleNode("md:Properties/md:Name", $objNs)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# cfe-validate v1.2 — Validate 1C configuration extension XML structure (CFE)
|
# cfe-validate v1.3 — Validate 1C configuration extension XML structure (CFE)
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
"""Validates extension Configuration.xml: root, InternalInfo, extension properties, ChildObjects, borrowed objects."""
|
"""Validates extension Configuration.xml: root, InternalInfo, extension properties, ChildObjects, borrowed objects."""
|
||||||
import sys, os, argparse, re
|
import sys, os, argparse, re
|
||||||
@@ -535,6 +535,17 @@ def main():
|
|||||||
enum_values_index = {}
|
enum_values_index = {}
|
||||||
form_list = []
|
form_list = []
|
||||||
|
|
||||||
|
def is_borrowed_sub_item(sub_item):
|
||||||
|
"""Check if sub-item has explicit borrowed metadata (ObjectBelonging or ExtendedConfigurationObject)."""
|
||||||
|
sub_props = sub_item.find(f'{{{MD}}}Properties')
|
||||||
|
if sub_props is None:
|
||||||
|
return False
|
||||||
|
sub_ob = sub_props.find(f'{{{MD}}}ObjectBelonging')
|
||||||
|
if sub_ob is not None and (sub_ob.text or ''):
|
||||||
|
return True
|
||||||
|
sub_ext = sub_props.find(f'{{{MD}}}ExtendedConfigurationObject')
|
||||||
|
return sub_ext is not None and bool(sub_ext.text or '')
|
||||||
|
|
||||||
def validate_borrowed_sub_item(check_num, context, sub_type, sub_item):
|
def validate_borrowed_sub_item(check_num, context, sub_type, sub_item):
|
||||||
"""Validate a borrowed Attribute/EnumValue/TabularSection sub-item."""
|
"""Validate a borrowed Attribute/EnumValue/TabularSection sub-item."""
|
||||||
sub_props = sub_item.find(f'{{{MD}}}Properties')
|
sub_props = sub_item.find(f'{{{MD}}}Properties')
|
||||||
@@ -631,11 +642,15 @@ def main():
|
|||||||
sub_type = etree.QName(sub_item.tag).localname
|
sub_type = etree.QName(sub_item.tag).localname
|
||||||
|
|
||||||
if sub_type == 'Attribute':
|
if sub_type == 'Attribute':
|
||||||
|
if not is_borrowed_sub_item(sub_item):
|
||||||
|
continue
|
||||||
sub_item_count += 1
|
sub_item_count += 1
|
||||||
if not validate_borrowed_sub_item('10', ctx, 'Attribute', sub_item):
|
if not validate_borrowed_sub_item('10', ctx, 'Attribute', sub_item):
|
||||||
check10_ok = False
|
check10_ok = False
|
||||||
|
|
||||||
elif sub_type == 'TabularSection':
|
elif sub_type == 'TabularSection':
|
||||||
|
if not is_borrowed_sub_item(sub_item):
|
||||||
|
continue
|
||||||
sub_item_count += 1
|
sub_item_count += 1
|
||||||
if not validate_borrowed_sub_item('10', ctx, 'TabularSection', sub_item):
|
if not validate_borrowed_sub_item('10', ctx, 'TabularSection', sub_item):
|
||||||
check10_ok = False
|
check10_ok = False
|
||||||
@@ -662,11 +677,15 @@ def main():
|
|||||||
continue
|
continue
|
||||||
if etree.QName(ts_attr.tag).localname != 'Attribute':
|
if etree.QName(ts_attr.tag).localname != 'Attribute':
|
||||||
continue
|
continue
|
||||||
|
if not is_borrowed_sub_item(ts_attr):
|
||||||
|
continue
|
||||||
sub_item_count += 1
|
sub_item_count += 1
|
||||||
if not validate_borrowed_sub_item('10', f'{ctx}.ТЧ.{ts_label}', 'Attribute', ts_attr):
|
if not validate_borrowed_sub_item('10', f'{ctx}.ТЧ.{ts_label}', 'Attribute', ts_attr):
|
||||||
check10_ok = False
|
check10_ok = False
|
||||||
|
|
||||||
elif sub_type == 'EnumValue' and type_name == 'Enum':
|
elif sub_type == 'EnumValue' and type_name == 'Enum':
|
||||||
|
if not is_borrowed_sub_item(sub_item):
|
||||||
|
continue
|
||||||
sub_item_count += 1
|
sub_item_count += 1
|
||||||
if validate_borrowed_sub_item('10', ctx, 'EnumValue', sub_item):
|
if validate_borrowed_sub_item('10', ctx, 'EnumValue', sub_item):
|
||||||
ev_name = sub_item.find(f'{{{MD}}}Properties/{{{MD}}}Name')
|
ev_name = sub_item.find(f'{{{MD}}}Properties/{{{MD}}}Name')
|
||||||
|
|||||||
Reference in New Issue
Block a user