-
Notifications
You must be signed in to change notification settings - Fork 6
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
[#IP-84] Change strict configuration to true #109
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.
@@ -376,7 +376,7 @@ export function CreateMessageHandler( | |||
telemetryClient.trackEvent({ | |||
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
@@ -112,7 +115,7 @@ const getUserTask = ( | |||
() => | |||
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
@@ -33,7 +33,7 @@ const telemetryClient = initTelemetryClient( | |||
export const trackMessageProcessing = ( | |||
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
@@ -74,7 +77,7 @@ const getServiceTask = ( | |||
() => | |||
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
@@ -88,7 +91,7 @@ const getSubscriptionKeysTask = ( | |||
() => | |||
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
@@ -108,7 +108,7 @@ describe("GetUserServicesHandler", () => { | |||
expect(result.kind).toBe("IResponseSuccessJson"); | |||
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
@@ -66,7 +70,7 @@ const getUserTask = ( | |||
() => | |||
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
@@ -84,7 +88,7 @@ export function GetUserServicesHandler( | |||
) | |||
.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
@@ -86,7 +89,7 @@ const regenerateServiceKeyTask = ( | |||
apiClient.RegenerateSubscriptionKeys({ | |||
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
utils/arbitraries.ts
Outdated
@@ -82,9 +84,9 @@ export const newMessageArb = fc | |||
markdown, | |||
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! 0 Bugs No Coverage information |
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.