Skip to content
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

Validation restructure #163

Merged
merged 9 commits into from
Jun 2, 2022

Conversation

ReeceHumphreys
Copy link
Contributor

No description provided.

@ReeceHumphreys ReeceHumphreys marked this pull request as draft June 1, 2022 17:23
@ReeceHumphreys ReeceHumphreys marked this pull request as ready for review June 1, 2022 17:55
src/validators/attribute.rs Outdated Show resolved Hide resolved
src/validators/attribute.rs Outdated Show resolved Hide resolved
src/validators/attribute.rs Outdated Show resolved Hide resolved
src/validators/mod.rs Outdated Show resolved Hide resolved
src/validators/mod.rs Outdated Show resolved Hide resolved
src/validators/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@InsertCreativityHere InsertCreativityHere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty fancy to me!

I think some cleanup is in order, but with the breadth of this PR, probably better to do it separately.

Also, I think you should change your functions to take an ErrorReporter, and report directly into it, instead of keeping their own errors, and returning them. It leads to unnecessary copying, and the new function in the error reporter.

src/error.rs Outdated Show resolved Hide resolved
@@ -52,6 +52,16 @@ impl ErrorReporter {
self.report(message.into(), location, ErrorLevel::Warning);
}

pub fn report_errors(&mut self, errors: &[Error]) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a little weird to me, making clones of every error, then adding the clones to the array.
I understand why you had to though, since report takes the pieces, and not the errors themselves.

Hopefully Joe's changes to error reporting make this function unnecessary, but if not, we should probably change report to just take an error, and change this to take an owned Vec<Error> instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be addressing this in a follow-up PR where I cleanup some of the names too!

src/grammar/elements/mod.rs Outdated Show resolved Hide resolved
fn visit_operation_start(&mut self, operation_def: &Operation) {
self.validate_stream_member(operation_def.parameters());
self.validate_stream_member(operation_def.return_members());
fn visit_parameter(&mut self, parameter: &Parameter) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The visitor visits parameters and return_members differently.
This only visits parameters at the moment, so probably want an identical visit_return_member function too.

There's a chance that this distinction isn't useful anymore, so we can maybe change this behavior. But for now, your validator isn't validating any return members.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will make an issue!

tests/structs/tags.rs Outdated Show resolved Hide resolved
/// Validate that the enumerators are within the bounds of the specified underlying type.
fn backing_type_bounds(enum_def: &Enum) -> ValidationResult {
let mut errors = vec![];
if enum_def.supported_encodings().supports(&Encoding::Slice1) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated to the PR, but this check is incorrect. An enum isn't limited to supporting 1 encoding, or the other. It can support both.

encoding = 1;
enum MyEnum { Foo }

This enum is supportable by both Slice1 and Slice2, but we're only validating the Slice1 side.

src/validators/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@externl externl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just need to fix @InsertCreativityHere's comments.

Comment on lines +10 to +13
Validate::Attributable(validate_compress_attribute),
Validate::Operation(validate_format_attribute),
Validate::Parameter(validate_deprecated_parameters),
Validate::Members(validate_deprecated_data_members),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a followup PR, I think names should be more descriptive. Eg.

Validate::Members(can_not_be_marked_as_deprecated),

src/validators/mod.rs Show resolved Hide resolved
@ReeceHumphreys ReeceHumphreys merged commit dddfe88 into icerpc:main Jun 2, 2022
@ReeceHumphreys ReeceHumphreys deleted the validation-restructure branch June 2, 2022 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants