mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-10 16:14:54 +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
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -537,6 +537,17 @@ if ($script:stopped) { & $finalize; exit 1 }
|
||||
$script:enumValuesIndex = @{}
|
||||
$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
|
||||
function Validate-BorrowedSubItem {
|
||||
param([string]$checkNum, [string]$context, [string]$subType, $subItem, $nsm)
|
||||
@@ -638,12 +649,14 @@ if ($childObjNode) {
|
||||
$subType = $subItem.LocalName
|
||||
|
||||
if ($subType -eq "Attribute") {
|
||||
if (-not (Test-BorrowedSubItem $subItem $objNs)) { continue }
|
||||
$subItemCount++
|
||||
if (-not (Validate-BorrowedSubItem "10" $ctx "Attribute" $subItem $objNs)) {
|
||||
$check10Ok = $false
|
||||
}
|
||||
}
|
||||
elseif ($subType -eq "TabularSection") {
|
||||
if (-not (Test-BorrowedSubItem $subItem $objNs)) { continue }
|
||||
$subItemCount++
|
||||
if (-not (Validate-BorrowedSubItem "10" $ctx "TabularSection" $subItem $objNs)) {
|
||||
$check10Ok = $false
|
||||
@@ -673,6 +686,7 @@ if ($childObjNode) {
|
||||
if ($tsChildObjs) {
|
||||
foreach ($tsAttr in $tsChildObjs.ChildNodes) {
|
||||
if ($tsAttr.NodeType -ne 'Element' -or $tsAttr.LocalName -ne "Attribute") { continue }
|
||||
if (-not (Test-BorrowedSubItem $tsAttr $objNs)) { continue }
|
||||
$subItemCount++
|
||||
if (-not (Validate-BorrowedSubItem "10" "${ctx}.ТЧ.${tsLabel}" "Attribute" $tsAttr $objNs)) {
|
||||
$check10Ok = $false
|
||||
@@ -682,6 +696,7 @@ if ($childObjNode) {
|
||||
}
|
||||
}
|
||||
elseif ($subType -eq "EnumValue" -and $typeName -eq "Enum") {
|
||||
if (-not (Test-BorrowedSubItem $subItem $objNs)) { continue }
|
||||
$subItemCount++
|
||||
if (Validate-BorrowedSubItem "10" $ctx "EnumValue" $subItem $objNs) {
|
||||
$evName = $subItem.SelectSingleNode("md:Properties/md:Name", $objNs)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/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
|
||||
"""Validates extension Configuration.xml: root, InternalInfo, extension properties, ChildObjects, borrowed objects."""
|
||||
import sys, os, argparse, re
|
||||
@@ -535,6 +535,17 @@ def main():
|
||||
enum_values_index = {}
|
||||
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):
|
||||
"""Validate a borrowed Attribute/EnumValue/TabularSection sub-item."""
|
||||
sub_props = sub_item.find(f'{{{MD}}}Properties')
|
||||
@@ -631,11 +642,15 @@ def main():
|
||||
sub_type = etree.QName(sub_item.tag).localname
|
||||
|
||||
if sub_type == 'Attribute':
|
||||
if not is_borrowed_sub_item(sub_item):
|
||||
continue
|
||||
sub_item_count += 1
|
||||
if not validate_borrowed_sub_item('10', ctx, 'Attribute', sub_item):
|
||||
check10_ok = False
|
||||
|
||||
elif sub_type == 'TabularSection':
|
||||
if not is_borrowed_sub_item(sub_item):
|
||||
continue
|
||||
sub_item_count += 1
|
||||
if not validate_borrowed_sub_item('10', ctx, 'TabularSection', sub_item):
|
||||
check10_ok = False
|
||||
@@ -662,11 +677,15 @@ def main():
|
||||
continue
|
||||
if etree.QName(ts_attr.tag).localname != 'Attribute':
|
||||
continue
|
||||
if not is_borrowed_sub_item(ts_attr):
|
||||
continue
|
||||
sub_item_count += 1
|
||||
if not validate_borrowed_sub_item('10', f'{ctx}.ТЧ.{ts_label}', 'Attribute', ts_attr):
|
||||
check10_ok = False
|
||||
|
||||
elif sub_type == 'EnumValue' and type_name == 'Enum':
|
||||
if not is_borrowed_sub_item(sub_item):
|
||||
continue
|
||||
sub_item_count += 1
|
||||
if validate_borrowed_sub_item('10', ctx, 'EnumValue', sub_item):
|
||||
ev_name = sub_item.find(f'{{{MD}}}Properties/{{{MD}}}Name')
|
||||
|
||||
Reference in New Issue
Block a user