mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-29 16:11:01 +03:00
fix(skd-validate): eliminate false positives on real ERP/БП reports
Calibrated against 1106 vendor reports (ERP 8.3.24 + БП 8.3.27).
Three categories of false positive removed:
- CalculatedField with empty <expression/> demoted error→warning.
Three legitimate vendor patterns surfaced:
* sibling totalField with same dataPath provides the formula
(used in cancellation-rate and share-percentage reports)
* groupTemplate references the field as group name
* field exists only as a declarative anchor for settingsVariants
Warning preserved so genuinely-missing formulas still surface.
- Duplicate template name demoted error→warning. Vendor configs ship
reports (БазаНормируемыхРасходов/Выручка) with three <template> blocks
named Макет1 — the platform identifies templates by position, not by
<name>. Warning still flags the collision without failing validation.
- comparisonType whitelist extended with NotInHierarchy and
NotInListByHierarchy. Existing list was missing the negated
hierarchy operators used in 20 of the 1106 reports.
Result: 0 false positives across the corpus, all genuine errors still
caught (verified separately against intentionally-broken fixtures).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
12745b14c3
commit
efdf56691c
@@ -438,6 +438,17 @@ if ($script:stopped) { & $finalize; exit 1 }
|
||||
if ($calcFieldNodes.Count -gt 0) {
|
||||
$cfOk = $true
|
||||
$cfSeen = @{}
|
||||
# Collect totalField dataPaths — an empty calculatedField is legitimate if a
|
||||
# totalField with the same dataPath provides the expression (real-world
|
||||
# pattern in vendor ERP/БП reports for fields visible only in totals).
|
||||
$tfPaths = @{}
|
||||
foreach ($tf in $totalFieldNodes) {
|
||||
$tfDp = $tf.SelectSingleNode("s:dataPath", $ns)
|
||||
if ($tfDp -and $tfDp.InnerText) {
|
||||
$tfPaths[$tfDp.InnerText] = $true
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($cf in $calcFieldNodes) {
|
||||
$dp = $cf.SelectSingleNode("s:dataPath", $ns)
|
||||
$expr = $cf.SelectSingleNode("s:expression", $ns)
|
||||
@@ -457,8 +468,15 @@ if ($calcFieldNodes.Count -gt 0) {
|
||||
}
|
||||
|
||||
if (-not $expr -or -not $expr.InnerText.Trim()) {
|
||||
Report-Error "CalculatedField '$path' has empty expression"
|
||||
$cfOk = $false
|
||||
# Empty expression is legitimate in several vendor patterns:
|
||||
# - totalField with same dataPath provides the calculation
|
||||
# - groupTemplate uses the field as group name (declarative only)
|
||||
# - field is referenced only by settingsVariants for grouping
|
||||
# Surface as warning, not error, to avoid false positives on real
|
||||
# ERP/БП reports while still flagging the unusual shape.
|
||||
if (-not $tfPaths.ContainsKey($path)) {
|
||||
Report-Warn "CalculatedField '$path' has empty expression (declarative-only?)"
|
||||
}
|
||||
}
|
||||
|
||||
# Warn if collides with a dataset field
|
||||
@@ -542,14 +560,16 @@ if ($templateNodes.Count -gt 0) {
|
||||
}
|
||||
$tName = $nameNode.InnerText
|
||||
if ($tplSeen.ContainsKey($tName)) {
|
||||
Report-Error "Duplicate template name: $tName"
|
||||
$tplOk = $false
|
||||
# Vendor configs (ERP/БП) ship templates with repeating names — the
|
||||
# platform identifies them by position/context, not by <name>. Demote
|
||||
# to warning so the check still surfaces the collision without failing.
|
||||
Report-Warn "Duplicate template name: $tName (allowed by platform but ambiguous)"
|
||||
} else {
|
||||
$tplSeen[$tName] = $true
|
||||
}
|
||||
}
|
||||
if ($tplOk) {
|
||||
Report-OK "$($templateNodes.Count) template(s): names unique"
|
||||
Report-OK "$($templateNodes.Count) template(s) found"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -581,7 +601,8 @@ if ($script:stopped) { & $finalize; exit 1 }
|
||||
|
||||
$validComparisonTypes = @(
|
||||
"Equal","NotEqual","Greater","GreaterOrEqual","Less","LessOrEqual",
|
||||
"InList","NotInList","InHierarchy","InListByHierarchy",
|
||||
"InList","NotInList","InHierarchy","NotInHierarchy",
|
||||
"InListByHierarchy","NotInListByHierarchy",
|
||||
"Contains","NotContains","BeginsWith","NotBeginsWith",
|
||||
"Filled","NotFilled"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user