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

chore(td-tools): enable eslint/strict-boolean-expressions and strictNullChecks #1077

Conversation

danielpeintner
Copy link
Member

@danielpeintner danielpeintner commented Sep 8, 2023

This PR addresses one checkmark in #1046.

@danielpeintner danielpeintner marked this pull request as draft September 8, 2023 10:11
@codecov
Copy link

codecov bot commented Sep 8, 2023

Codecov Report

Patch coverage: 76.47% and project coverage change: -0.03% ⚠️

Comparison is base (c10fba2) 75.34% compared to head (7762ea4) 75.31%.
Report is 12 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1077      +/-   ##
==========================================
- Coverage   75.34%   75.31%   -0.03%     
==========================================
  Files          80       80              
  Lines       16079    16052      -27     
  Branches     1502     1501       -1     
==========================================
- Hits        12114    12089      -25     
+ Misses       3926     3924       -2     
  Partials       39       39              
Files Changed Coverage Δ
packages/td-tools/src/thing-model-helpers.ts 84.41% <66.66%> (-0.34%) ⬇️
...s/td-tools/src/util/asset-interface-description.ts 81.50% <75.60%> (+0.16%) ⬆️
packages/td-tools/src/td-parser.ts 93.18% <90.90%> (-0.36%) ⬇️
packages/td-tools/src/thing-description.ts 100.00% <100.00%> (ø)

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Note: leave out  asset-interface-description.ts because of eclipse-thingweb#1052
@relu91
Copy link
Member

relu91 commented Sep 8, 2023

I started working on this, but I gave up. Thank you for bringing this up! I think we should pay double attention to the changes... because sometimes we used null as synonym of undefined

packages/td-tools/src/td-parser.ts Outdated Show resolved Hide resolved
packages/td-tools/src/td-parser.ts Outdated Show resolved Hide resolved
packages/td-tools/src/td-parser.ts Outdated Show resolved Hide resolved
packages/td-tools/src/thing-model-helpers.ts Outdated Show resolved Hide resolved
packages/td-tools/src/thing-model-helpers.ts Outdated Show resolved Hide resolved
packages/td-tools/src/thing-model-helpers.ts Outdated Show resolved Hide resolved
packages/td-tools/src/thing-model-helpers.ts Outdated Show resolved Hide resolved
packages/td-tools/src/thing-model-helpers.ts Outdated Show resolved Hide resolved
@danielpeintner
Copy link
Member Author

One more thing: Since there are lots of changes I am now more thinking about proposing PRs for each package step by step... otherwise it gets huge and hardly manageable..
What do people think?

@danielpeintner
Copy link
Member Author

I started working on this, but I gave up. Thank you for bringing this up! I think we should pay double attention to the changes... because sometimes we used null as synonym of undefined

I think after doing some more work on it I noticed this issue as well.

In a sense

if (bla !== undefined) {

is not enough and we would almost need

if (bla !== undefined && bla !== null) {

which I really don't like...

Ideas/Proposals?

@JKRhb
Copy link
Member

JKRhb commented Sep 14, 2023

In a sense

if (bla !== undefined) {

is not enough and we would almost need

if (bla !== undefined && bla !== null) {

which I really don't like...

Ideas/Proposals?

I think in this case, you can (somewhat unintuitively) cover both with bla != null. When I integrated strict null checks in node-coap, that concept was very helpful in dealing with this scenario. As mentioned somewhere else, this is apparently one of the few scenarios where it is valid to use the != operator instead of the !== operator.

@danielpeintner
Copy link
Member Author

danielpeintner commented Sep 20, 2023

@JKRhb I think some of the proposed changes are not correct and lead to issues. I suggest to keep them as is...
I think that's why the thing model helper tests are failing. I revert them ...

EDIT: Tests are still failing.. honestly not sure why since the only change is =! null 🤷‍♂️
Am I missing something!?

@danielpeintner
Copy link
Member Author

danielpeintner commented Sep 20, 2023

@JKRhb @relu91 I am a bit lost and do not understand why some TM tests are failing. Can you spot the issue!?
I think I need a break 🙈

EDIT: I think I found the issue.. options.selfComposition is actually boolean

I think the PR is ready for review

@danielpeintner danielpeintner marked this pull request as ready for review September 20, 2023 09:33
Copy link
Member

@relu91 relu91 left a comment

Choose a reason for hiding this comment

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

Some further simplifications.

packages/td-tools/src/util/asset-interface-description.ts Outdated Show resolved Hide resolved
packages/td-tools/src/util/asset-interface-description.ts Outdated Show resolved Hide resolved
packages/td-tools/src/util/asset-interface-description.ts Outdated Show resolved Hide resolved
packages/td-tools/src/util/asset-interface-description.ts Outdated Show resolved Hide resolved
packages/td-tools/src/util/asset-interface-description.ts Outdated Show resolved Hide resolved
packages/td-tools/src/util/asset-interface-description.ts Outdated Show resolved Hide resolved
packages/td-tools/src/thing-model-helpers.ts Outdated Show resolved Hide resolved
@danielpeintner
Copy link
Member Author

Note: I am not sure "why" but the CI gets stuck all the time in "Test with coverage report" with this PR. Local tests run fine...

@relu91
Copy link
Member

relu91 commented Sep 21, 2023

Note: I am not sure "why" but the CI gets stuck all the time in "Test with coverage report" with this PR. Local tests run fine...

I was surprised too, let's see if #1093 get stuck too.

@danielpeintner danielpeintner changed the title chore: enable eslint/strict-boolean-expressions and strictNullChecks chore(td-tools): enable eslint/strict-boolean-expressions and strictNullChecks Sep 21, 2023
Copy link
Member

@relu91 relu91 left a comment

Choose a reason for hiding this comment

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

Greenlight from my side too!

@danielpeintner danielpeintner merged commit a38b05b into eclipse-thingweb:master Sep 22, 2023
7 checks passed
JKRhb added a commit to JKRhb/thingweb.node-wot that referenced this pull request Sep 22, 2023
…ullChecks (eclipse-thingweb#1077)

* chore: enable eslint/strict-boolean-expressions and strictNullChecks

* fix package examples

* fix package td-tools

Note: leave out  asset-interface-description.ts because of eclipse-thingweb#1052

* Update packages/td-tools/src/td-parser.ts

Co-authored-by: Jan Romann <[email protected]>

* Update packages/td-tools/src/td-parser.ts

Co-authored-by: Jan Romann <[email protected]>

* Update packages/td-tools/src/td-parser.ts

Co-authored-by: Jan Romann <[email protected]>

* Update packages/td-tools/src/thing-model-helpers.ts

Co-authored-by: Jan Romann <[email protected]>

* Update packages/td-tools/src/thing-model-helpers.ts

Co-authored-by: Jan Romann <[email protected]>

* Update packages/td-tools/src/thing-model-helpers.ts

Co-authored-by: Jan Romann <[email protected]>

* Update packages/td-tools/src/thing-model-helpers.ts

Co-authored-by: Jan Romann <[email protected]>

* fix: issue issue introduced by commenting

* move eslint settings to td-tools package only

* fix: lint errors for AID

* refactor: revert changes in package "examples"

* refactor: revert "!== undefined" to "!= null"

OR "=== undefined" to "== null"

* refactor: revert some changes proposed by @JKRhb

leads to different results

* fix: wrong conversion

* refactor: missing one undefined change

* fix: add proper boolean check

* Update packages/td-tools/src/thing-model-helpers.ts

Co-authored-by: Cristiano Aguzzi <[email protected]>

* Update packages/td-tools/src/util/asset-interface-description.ts

Co-authored-by: Cristiano Aguzzi <[email protected]>

* Update packages/td-tools/src/util/asset-interface-description.ts

Co-authored-by: Cristiano Aguzzi <[email protected]>

* Update packages/td-tools/src/util/asset-interface-description.ts

Co-authored-by: Cristiano Aguzzi <[email protected]>

* Update packages/td-tools/src/util/asset-interface-description.ts

Co-authored-by: Cristiano Aguzzi <[email protected]>

* Update packages/td-tools/src/util/asset-interface-description.ts

Co-authored-by: Cristiano Aguzzi <[email protected]>

* Update packages/td-tools/src/util/asset-interface-description.ts

Co-authored-by: Cristiano Aguzzi <[email protected]>

* refactor: further simplifications

* Update packages/td-tools/src/td-parser.ts

Co-authored-by: Jan Romann <[email protected]>

* refactor: simplify data.version.model check

---------

Co-authored-by: Jan Romann <[email protected]>
Co-authored-by: Cristiano Aguzzi <[email protected]>
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