-
Notifications
You must be signed in to change notification settings - Fork 80
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
chore(binding-http): enable eslint/strict-boolean-expressions #1097
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #1097 +/- ##
==========================================
- Coverage 75.71% 75.61% -0.10%
==========================================
Files 80 80
Lines 16106 16153 +47
Branches 1507 1518 +11
==========================================
+ Hits 12194 12214 +20
- Misses 3874 3898 +24
- Partials 38 41 +3
☔ View full report in Codecov by Sentry. |
f242b2c
to
640a128
Compare
7c99ec6
to
31a0adf
Compare
31a0adf
to
f7cbf23
Compare
(Rebased the PR against the latest state of |
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 selected request changes but they are mostly suggestions and comments. I'm open to changing my mind on the suggested changes, let me know!
@@ -565,35 +563,33 @@ export default class HttpServer implements ProtocolServer { | |||
return; | |||
} | |||
|
|||
if (thing.securityDefinitions) { |
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.
Given the comment, this should probably be: if(thing.security == null)
. Right?
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.
As thing.security
is a mandatory field, I think this part of the code covers the thing.security.length === 0
case (i.e., the test for thing.security.length > 0
above does not return true and we did not return from the method early).
This could definitely be a bit clearer, though – maybe we can perform some additional cleanups after this PR has been merged?
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.
It is a mandatory field in the TD but not in the ThingExposeInit
. In my understanding, there is nothing so far to check if the security
is defined. Probably, due to #911. Currently, we just ask the bindings to handle the ExposeThingInit
see https://github.com/eclipse-thingweb/node-wot/blob/master/packages/core/src/servient.ts#L38 . So thing.security
might be also null
at that point in time. Do the new changes take care of this too? 🤔 .
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.
Ohh, I see, then this case might not be covered yet! I will double-check this :)
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.
Hmm, the parameter passed into the method is of type ExposedThing
with security
being of type security: string | [string, ...string[]]
– so it is mandatory, but I suppose at least one thing that is missing is the case when security is a single string?
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 tried to provide a fix now in 7a0bd02 – I think that should work for now, however, it seems to me as if the handling of security
and securityDefinitions
needs to be revisited in general.
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.
Aparently, the code has been correct before and did not work anymore after the change, so I reverted it. Seems to me as if the typing of the security
field in the ExposedThing
class/interface might need to be fixed.
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 know that it is counter-intuitive and I agree that the bug is somewhere else (e.g. #911). If you go upwards in the call hierarchy you'll notice that after producing method nobody checks if security
is defined, tomorrow I'll try with a practical example. However for the time being we can merge the PR and track this issue in #911 .
f215aa4
to
23bd916
Compare
Hmm, the persisting linting errors are still puzzling me a bit, as I don't get the same errors on my own machine. I think I now remember that they were the reason why I used the I think the easiest resolution would be to stick to |
3fb7def
to
4f77d90
Compare
Since the updated eslint packages did not solve the issue and to make the history a bit cleaner, I dropped the commits merged in from #1103 and rebased against |
e1d7c40
to
2ada086
Compare
Rebased against |
2ada086
to
467f883
Compare
Co-authored-by: Cristiano Aguzzi <[email protected]>
467f883
to
99c1082
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.
All the comments above have been resolved. Merging. Thanks @JKRhb !!!
Awesome, thank you @relu91! :) Maybe one thing, though: It's probably best to use the squashing strategy when merging PRs like this one, as the Personally, I would prefer if we would allow to also perform some clean-up in the PR (i.e., rebasing, squashing, and reordering of commits) itself after the reviewers gave their approval since having a clean commit history in the main branch is always a nice thing to have, I think. But maybe we could discuss this also at some point (in not too much detail) in a synchronous manner (which would also probably lead to the resolution of #558). |
As said before.. rebasing, squashing, and reordering of commits while working on a PR makes it very difficult to follow what has changed between commits. I guess the only thing we need to remember (when "actually" merging the PR) is set/choose the right option to "squash all commits". Shall we continue the discussion in #558 |
You are completely right, that should only be done once all reviews have been addressed. Sorry once more for not following that principle before.
👍 |
Ticks one of the boxes of #1046 :)