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

Further work on message validation #1758

Merged
merged 23 commits into from
Mar 5, 2024

Conversation

Kaz-ookid
Copy link
Contributor

@Kaz-ookid Kaz-ookid commented Feb 26, 2024

Addressing #1751

This PR will hold new message data object validation, to help the effort of complete message validation depicted in #1751.

Note to myself: remember to update the list of validated data in #1751, after this PR gets approved.

@CLAassistant
Copy link

CLAassistant commented Feb 26, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

Pull reviewers stats

Stats of the last 30 days for popstellar:

User Total reviews Time to review Total comments
pierluca
🥇
6
▀▀▀▀
6d 7h 35m
▀▀▀▀▀▀
10
▀▀▀▀▀▀▀
MariemBaccari
🥈
4
▀▀▀
1d 17h 15m
▀▀
1
jbsv
🥉
2
1d 7h 33m
0
sgueissa
1
1h 17m
3
▀▀
ljankoschek
1
20h 9m
0
K1li4nL
1
18m
0
emonnin-epfl
1
6h 45m
1

@Kaz-ookid Kaz-ookid self-assigned this Feb 29, 2024
@Kaz-ookid Kaz-ookid marked this pull request as ready for review February 29, 2024 15:32
@Kaz-ookid Kaz-ookid requested a review from a team as a code owner February 29, 2024 15:32
@Kaz-ookid
Copy link
Contributor Author

Hint for reviewers:

The construction of a Question is now validated. I also am checking the question handed in the ElectionQuestion for the exact same constraints. This means we are validating the question twice, thus reducing coverage (since we can't construct any invalid question to hand to the ElectionQuestion constructor). It may not be needed to validate the question in ElectionQuestion, but I stil did just in case. I am open to suggestion about it.

@Kaz-ookid Kaz-ookid linked an issue Feb 29, 2024 that may be closed by this pull request
54 tasks
@Kaz-ookid Kaz-ookid removed a link to an issue Feb 29, 2024
54 tasks
Copy link
Contributor

@matteosz matteosz left a comment

Choose a reason for hiding this comment

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

Really good work! Just some picky comments

@Kaz-ookid
Copy link
Contributor Author

Thanks a lot @matteosz for your insightful review 👍

@matteosz
Copy link
Contributor

matteosz commented Mar 3, 2024

Just a reminder also for future PRs (you can skip it for this one): try to keep commits number as low as possible.
I just saw you did a commit formatting and then runktmftm Format, plus probably 16 commits for a 300 lines change is a bit too much (but it's just my subjective opinion obv).

Commits are a great mechanism for tracking history, but if multiple commits have the same purpose this simply increases the entropy of the codebase and "obfuscate" a good commit history. So try to squash together all the commits that serve to the same purpose.

Simply run git rebase -i HEAD~<number_of_commits> and then manually go through commits and decide whether to squash or keep them. Keep in mind that if you squash commits already pushed you'd need to force push, so be careful about it.

@matteosz matteosz self-requested a review March 3, 2024 23:07
Comment on lines 22 to 23
init {
verify().isNotEmptyBase64(electionId, "election ID").validQuestions(listOf(question))
Copy link
Contributor

Choose a reason for hiding this comment

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

Saw that you did a commit named ElectionQuestion : removed overlapping Question validations but it's actually an empty commit (just some formatting), so I guess you forgot to remove the validQuestions check here

Copy link
Contributor Author

@Kaz-ookid Kaz-ookid Mar 4, 2024

Choose a reason for hiding this comment

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

I actually removed the redundant checks performed in validQuestions, line 245 of MessageValidator (calling validQuestion for each Question in the list). validQuestions is still used, as it checks for duplicates and requires the list not to be empty. Maybe it makes it not relevant anymore to be a function in MessageValidator tho.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah the point was: why are you still calling .validQuestions(listOf(question)) in ElectionQuestion? The fact that the list is not empty and without duplicates is given by the construction of it (a list of 1 element)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh yes that makes a lot of sense, I overlooked

quadcopterman
quadcopterman previously approved these changes Mar 4, 2024
Copy link
Contributor

@quadcopterman quadcopterman left a comment

Choose a reason for hiding this comment

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

Seems OK to me

matteosz
matteosz previously approved these changes Mar 5, 2024
Copy link
Contributor

@matteosz matteosz left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link

sonarcloud bot commented Mar 5, 2024

Quality Gate Passed Quality Gate passed for 'PoP - PoPCHA-Web-Client'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

sonarcloud bot commented Mar 5, 2024

Quality Gate Passed Quality Gate passed for 'PoP - Be1-Go'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

sonarcloud bot commented Mar 5, 2024

Quality Gate Passed Quality Gate passed for 'PoP - Be2-Scala'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

sonarcloud bot commented Mar 5, 2024

Copy link

sonarcloud bot commented Mar 5, 2024

Quality Gate Passed Quality Gate passed for 'PoP - Fe1-Web'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@matteosz matteosz self-requested a review March 5, 2024 17:25
@Kaz-ookid Kaz-ookid merged commit ec20ed0 into master Mar 5, 2024
18 checks passed
@Kaz-ookid Kaz-ookid deleted the work-fe2-maxime-message-validation branch March 5, 2024 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants