-
-
Notifications
You must be signed in to change notification settings - Fork 13
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 bad-import-yang-version handling #237
Conversation
It is allowed to import YANG 1.1 modules from YANG 1.0 when importing without revision-date. bad-import-yang-version was flagged even when a YANG 1.1 module was imported by YANG 1.0 module without specifying revision-date and is now fixed. This fix addresses TypeFox#228 Signed-off-by: Siddharth Sharma <[email protected]>
Added build settings for vscode Signed-off-by: Siddharth Sharma <[email protected]>
e6ebf1c
to
8760d7e
Compare
@esmasth |
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 added a minor improvement suggestion, otherwise it looks good to me.
if(baseModuleVersion != importedModuleVersion) { | ||
val message = '''Cannot import a version «importedModuleVersion» module in a version «baseModuleVersion» module.'''; | ||
val revisionDate = importStatement.substatementsOfType(RevisionDate) | ||
if (!revisionDate.nullOrEmpty && baseModuleVersion != importedModuleVersion) { |
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.
[nit] substatementsOfType
can not return null
, you can just use .empty
.
[nit] revisionDate
is a lazy evaluated iterable, if you move it after baseModuleVersion != importedModuleVersion
it will only be calculated in the erroring case and save some computation time.
Proposed change:
val revisionDate = importStatement.substatementsOfType(RevisionDate)
if (baseModuleVersion != importedModuleVersion && !revisionDate.empty) {
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.
Fixing this in following update
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.
Fixed
@esmasth |
@dhuebner Thanks, is it decided then to make these issues configurable? I rather agree with your statement on yang-vscode that it's a potential to break the engine if we allow unambiguously wrong input. |
No, but we can allow to configure it by the user. I think the user can then decide what to do.
Do you what to apply the suggestions I made, or should I merge your PR as it is? |
I will do the late evaluation and It might be good to have some strictness for MUST/SHALL statement violations in YANG RFC with some consistent policy for the project. Maybe good to discuss that on TypeFox/yang-vscode#40 to conclude? |
@esmasth |
substatementsOfType does not return null and hence only empty needs to be checked. Also changed the order of checks to improve performance. Signed-off-by: Siddharth Sharma <[email protected]>
Ok with merging this now, if you are. |
@esmasth |
It is allowed to import YANG 1.1 modules from YANG 1.0 when importing without revision-date. bad-import-yang-version was flagged even when a YANG 1.1 module was imported by YANG 1.0 module without specifying revision-date and is now fixed.
This fix addresses #228