-
Notifications
You must be signed in to change notification settings - Fork 5
[#IP-84] Change strict configuration to true #109
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
base: master
Are you sure you want to change the base?
Conversation
Example of PR titles that include pivotal stories:
New dependencies added: @types/node-fetchAuthor: Unknown Description: TypeScript definitions for node-fetch Homepage: http://npmjs.com/package/@types/node-fetch
|
Codecov Report
@@ Coverage Diff @@
## master #109 +/- ##
==========================================
+ Coverage 81.82% 82.02% +0.20%
==========================================
Files 27 27
Lines 886 907 +21
Branches 89 95 +6
==========================================
+ Hits 725 744 +19
- Misses 160 162 +2
Partials 1 1
Continue to review full report at Codecov.
|
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.
Manual casting must be considered the very very last resort. Every time we do that, we are poisoning our type system. It may happen once, but usually it's just problem-shifting - or worse: problem-hiding.
We must use alternatives; not that easy, though.
| name: "api.messages.create", | ||
| properties: { | ||
| error: isSuccess ? undefined : r.kind, | ||
| error: isSuccess ? "" : r.kind, |
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.
Why this?
CreateService/handler.ts
Outdated
| apiClient.getUser({ | ||
| email: userEmail | ||
| }), | ||
| }) as Promise<t.Validation<IResponseType<number, any, never>>>, |
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.
We must try not to use manual casting; when we do it, we are injecting unsafe assumptions into the type system, and that makes all other assumptions unsafe.
CreatedMessageOrchestrator/utils.ts
Outdated
| event: MessageProcessingEvent, | ||
| isReplaying: boolean | ||
| ): void => | ||
| ): void|null => |
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.
The function can just return void on the dead branch, so you don't have to handle a union type
GetService/handler.ts
Outdated
| apiClient.getService({ | ||
| service_id: serviceId | ||
| }), | ||
| }) as Promise<t.Validation<IResponseType<number, any, never>>>, |
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.
ditto
GetService/handler.ts
Outdated
| apiClient.getSubscriptionKeys({ | ||
| service_id: serviceId | ||
| }), | ||
| }) as Promise<t.Validation<IResponseType<number, any, never>>>, |
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.
ditto
| if (result.kind === "IResponseSuccessJson") { | ||
| expect(result.value).toEqual({ | ||
| items: aUserInfo.subscriptions.map(it => it.id) | ||
| items: (aUserInfo.subscriptions as Subscription[]).map(it => it.id) |
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.
ditto: manual casting
GetUserServices/handler.ts
Outdated
| apiClient.getUser({ | ||
| email: userEmail | ||
| }), | ||
| }) as Promise<t.Validation<IResponseType<number, any, never>>>, |
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.
ditto: manual casting
GetUserServices/handler.ts
Outdated
| .map(userInfo => | ||
| ResponseSuccessJson({ | ||
| items: userInfo.subscriptions.map(it => | ||
| items: (userInfo.subscriptions as Subscription[]).map(it => |
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.
ditto: manual casting
RegenerateServiceKey/handler.ts
Outdated
| body: subscriptionKeyTypePayload, | ||
| service_id: serviceId | ||
| }), | ||
| }) as Promise<t.Validation<IResponseType<number, any, never>>>, |
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.
ditto: manual casting
| subject | ||
| } | ||
| }).getOrElse(undefined) | ||
| }).fold(l=>undefined, r=>r) |
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.
getOrElse is actually a shortcut for this
|
I think we cannot avoid to manual cast things around, at the moment. We can group casts by their source problem into 2 groups: 1. withApiRequestWrapper method fails to narrow the type
|
Addendum: one issue is Are we experiencing production issues? Not at the moment. Other said: the case in which we receive an empty I don't have enough data to state if it is just contingency and if such event may happen. |
…gopa/io-functions-services into IP-84--enforce-strict-to-true
|
Kudos, SonarCloud Quality Gate passed!
|









Set the stirct configuration to true.
Fixed the compilation errors caused by the new settings.
The loigc/functions has not been rewritten or refactored: properly type cast has been introduced in order to pass the strict compiler check.