-
-
Notifications
You must be signed in to change notification settings - Fork 156
feat(compare-config): add optional includeInherited property and apply it to comparison logic #1069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(compare-config): add optional includeInherited property and apply it to comparison logic #1069
Conversation
…reConfig type Signed-off-by: Gaurav <[email protected]>
…configuration Signed-off-by: Gaurav <[email protected]>
|
@gaumrab Could you update the PR title to follow commit conventions please? https://www.conventionalcommits.org/en/v1.0.0/ |
|
sure @ekarademir Is this looks good: feat(compare-config): add optional includeInherited property and apply it to comparison logic according to the commit conventions. let me know if still any change required. |
|
@gaumrab could you also add test cases for the fix? |
| export type CompareConfig = { | ||
| comparerFactories: ComparerFactory[]; | ||
| rules: Record<string, CompareResult>; | ||
| includeInherited?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would you need this setting? Is there anything breaking do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ekarademir
I added the includeInherited property to accommodate two different user needs:
- Users who need to compare only properties defined in the child class
- Users who need to compare properties from both child and inherited classes
By making it optional, we satisfy both groups without introducing breaking changes. This ensures backward compatibility while providing the flexibility to handle inheritance chains when needed.
If You Want me to remove this Setting and directly want to use getProperties(), I wil Update.
But We can't Depends here directly on a getProperties().
If its return something un-relatable at that time User have Choice to Switch other Property getOwnProperties by using Setting includeInherited.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To Test the new property exists:
Create CompareConfig with includeInherited: true
Verify it's accepted
Test the logic change:
Compare with includeInherited: false → should get MAJOR result
Compare with includeInherited: true → should get PATCH result
Test backward compatibility:
Default behavior (no includeInherited) → should work as before
You Want me to add unit test case for that.
Currently I didn't Pushed it but i am on my local using it
#!/usr/bin/env node
/*
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
*/
'use strict';
const globPattern = process.argv[2];
const util = require('util');
const fs = require('fs');
const path = require('path');
const copyFilePromise = util.promisify(fs.copyFile);
const glob = require('glob');
function copyFiles(files, destDir) {
if (!fs.existsSync('coverage')){
fs.mkdirSync('coverage');
}
return Promise.all(files.map(f => {
return copyFilePromise(f.source, path.join(destDir, f.destination));
}));
}
const lcovs = glob.sync(globPattern).map((dir) => {
const packageName = dir.split(path.sep).join('/').split('/').pop();
return {
source: path.join(dir.split(path.sep).join('/'), 'coverage/coverage-final.json'),
destination: ${packageName}.json
};
});
// usage
copyFiles(lcovs, 'coverage').then(() => {
console.log("done");
}).catch(err => {
console.log(err);
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gaumrab it's best to push the change and have discussion about it. Once you push it it'll also run on our ci pipeline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it @ekarademir.
After it's done i will update you here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit Tests Added for Inheritance Bug Fix
Hi @ekarademir ,
I've pushed unit tests for the inheritance comparison bug fix. The test file packages/concerto-analysis/test/unit/inheritance-bug-fix.test.ts verifies that the includeInherited option works correctly.
Status: CI pipeline is awaiting approval from a maintainer in #1069

Test Coverage:
- ✅ Bug reproduction (MAJOR result with default behavior)
- ✅ Bug fix verification (PATCH result with includeInherited: true)
- ✅ Behavior comparison between old/new approaches
- ✅ Property inheritance analysis
To test locally:
git clone https://github.com/gaumrab/concerto.git
cd concerto && git checkout fix/1067/inheritance-comparison-bug
npm install && cd packages/concerto-analysis
npm test -- test/unit/inheritance-bug-fix.test.tsCould someone please approve the workflow? The inheritance bug fix is ready for review.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ekarademir any update??
- Add comprehensive unit tests for includeInherited option - Test bug reproduction with default behavior - Test bug fix verification with includeInherited: true - Test behavior comparison between old and new approaches - Test property inheritance analysis - All tests pass confirming the inheritance bug fix works correctly Closes accordproject#1067 Signed-off-by: Gaurav <[email protected]>
|
This PR is stale because it has been open 15 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
Summary
Fixed inheritance chain comparison bug in Concerto analysis where inherited properties were incorrectly reported as "removed" when comparing model versions. Added
includeInheritedoption to CompareConfig to properly handle inherited properties during model comparison.Changes
includeInherited?: booleanoption toCompareConfigtype incompare-config.tscompare.tsto usegetProperties()instead ofgetOwnProperties()whenincludeInheritedis trueincludeInheritedoptional with defaultfalseFlags
includeInherited: trueto get the new behaviorScreenshots or Video
Related Issues
Author Checklist
--signoffoption of git commit.mainfromfork:branchname