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

fix (CoRIM Extensions) : Incorrect Assumptions on Measurement Values Map validity #141

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion comid/measurement.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ func (o Mval) MarshalJSON() ([]byte, error) {
}

func (o Mval) Valid() error {
// Check if all base types are nil and Extensions are not nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please move this to be a method comment, “Valid returns true if all […]” since Valid is exported but doesn’t have a comment.

Choose a reason for hiding this comment

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

I have updated the Valid method to include a comment and moved the check for empty extensions as suggested.

if o.Ver == nil &&
o.SVN == nil &&
o.Digests == nil &&
Expand All @@ -436,7 +437,10 @@ func (o Mval) Valid() error {
o.UEID == nil &&
o.UUID == nil &&
o.IntegrityRegisters == nil {
return fmt.Errorf("no measurement value set")

if o.Extensions.IsEmpty() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not include this in the conjunction? I don’t see a reason for the nested if.

Choose a reason for hiding this comment

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

I uses nested if statements for simpler view of the conditions. However, if using a conjunction is preferred for better readability, I can change it accordingly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would prefer it. I don’t think there’s anything about this condition that needs special attention

Choose a reason for hiding this comment

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

Thanks for the feedback! it's cleaner with conjunctions. I've updated the code

return fmt.Errorf("no measurement value set")
}
}

if o.Ver != nil {
Expand Down