fix(concerto-analysis): route Map and Scalar declarations through dedicated comparison paths#1165
Open
yashhzd wants to merge 1 commit intoaccordproject:mainfrom
Open
Conversation
…icated comparison paths Fixes accordproject#1163 compareModelFiles was passing getAllDeclarations() to compareClassDeclarations, which included MapDeclaration and ScalarDeclaration instances. Since neither extends ClassDeclaration, this caused wrong finding keys (class-declaration-added instead of map-declaration-added) and a type safety violation for custom comparers. Changes: - Replace getAllDeclarations() with getClassDeclarations() in compareModelFiles - Remove instanceof MapDeclaration/ScalarDeclaration guards from compareClassDeclaration (no longer needed) - Add map-declaration-added/removed comparers in map-declarations.ts - Add scalar-declaration-added/removed comparers in scalar-declarations.ts - Add corresponding rules in compare-config.ts - Update tests to expect the correct finding keys for map and scalar types Signed-off-by: Yash Goel <yashgoel553@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1163
Compare.compareModelFileswas passinggetAllDeclarations()tocompareClassDeclarations, which includedMapDeclarationandScalarDeclarationinstances. Since neither extendsClassDeclaration(both extendDeclarationdirectly), this caused:class-declaration-added/removedinstead ofmap-declaration-added/removedComparerFactoryimplementations received non-ClassDeclarationobjects throughcompareClassDeclarationChanges
1.
compare.ts— Fix declaration routinga.getAllDeclarations()witha.getClassDeclarations()incompareModelFiles, so only actualClassDeclarationsubtypes are routed throughcompareClassDeclarationsinstanceof MapDeclaration/instanceof ScalarDeclarationguards fromcompareClassDeclaration(no longer needed since these types are no longer passed in)2.
map-declarations.ts— Add missing add/remove comparersAdded
mapDeclarationAddedandmapDeclarationRemovedcomparer factories that emitmap-declaration-addedandmap-declaration-removedfindings respectively.3.
scalar-declarations.ts— Add missing add/remove comparersAdded
scalarDeclarationAddedandscalarDeclarationRemovedcomparer factories that emitscalar-declaration-addedandscalar-declaration-removedfindings respectively.4.
compare-config.ts— Add new rules5.
compare.test.ts— Update testsforEach(['asset', ..., 'map', 'scalar'])loop so thatmapandscalarhave dedicated tests asserting the correct finding keys (map-declaration-addedinstead ofclass-declaration-added, etc.)class-declaration-*findings are emitted for map typesWhy both parts are needed
If only Part A (routing fix) were applied without Part B (new comparers), added/removed maps and scalars would produce zero findings — they'd become invisible to the comparison engine. The existing map/scalar comparers only handle type changes for matching declarations, not add/remove.
AI Disclosure
AI tools were used to assist with code analysis and drafting. All changes have been manually reviewed, verified against the codebase, and tested for correctness.
Author Checklist
concerto-analysisclass-declarations.ts