-
Notifications
You must be signed in to change notification settings - Fork 30
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
Fix validation of modified declarations #1066
Conversation
Improve the method for identifying modified service term types by addressing issues with new service additions and modified filters.
9e86530
to
ac0196a
Compare
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.
Congrats for the improvements, the fixes, the tests, and dropping a dependency! 👏
I find the code unusually hard to understand, with very long functions, shadowing variables and inconsistent data structures.
"select": "body" | ||
}, | ||
"Privacy Policy": { | ||
"fetch": "https://domain.example/tos", |
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.
"fetch": "https://domain.example/tos", | |
"fetch": "https://domain.example/privacy", |
scripts/declarations/utils/index.js
Outdated
|
||
return JSON.parse(fileContent); | ||
} catch (error) { | ||
return undefined; |
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.
return undefined; | |
return; |
const servicesTermsTypes = {}; | ||
|
||
await Promise.all(modifiedFilePaths.map(async modifiedFilePath => { | ||
const serviceId = DeclarationUtils.filePathToServiceId(modifiedFilePath); | ||
const serviceId = DeclarationUtils.getServiceIdFromFilePath(modifiedFilePath); |
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.
Extract the block in map
to new function, it is too long to be declared this way in an iteration 🙂
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.
I do not understand what you mean 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.
The whole anonymous function that is defined and called as the map
parameter is huge. I believe it would help with readability if it was extracted into its own named function.
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.
With the code simplification, I no longer find it useful.
scripts/declarations/utils/index.js
Outdated
const declaration = await this.getJSONFile(`declarations/${serviceId}.json`, this.defaultBranch); | ||
// TODO: Implement AST comparison between original and modified "filters" files to detect changes in functions, enabling identification of terms whose types depend on modified functions. | ||
// Due to the complexity involved, temporarily returning all term types. | ||
servicesTermsTypes[serviceId] = Object.keys(declaration.documents); |
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.
Since we
map
, why use an outside variable instead of using the return value ofmap
?
Co-authored-by: Matti Schneider <[email protected]>
Co-authored-by: Matti Schneider <[email protected]>
Rewrite the method used to identify modified services term types. It address two key issues:
Others improvements:
deep-diff
dependency