-
Notifications
You must be signed in to change notification settings - Fork 10
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
Expression is already of boolean type #5
Comments
Problem with this code is not only with "already boolean", it has redundant logic According to tests this code can be rewritten in much simplier way be-pkg-utils/tests/unit/applicationUtils.spec.ts Lines 813 to 819 in e969374
So
So check for null can be removed |
@vird last condition can also be simplified to: static isItnFormatValid(itn: string): boolean {
// valid format should contain 10 digits, no letters allowed
if (!/^\d{10}$/.test(itn)) return false
// edge case. We don't allow all digits to be 0
return +itn !== 0
} No additional RegExp is required. |
Last condition should be not simplified |
It sounds strange to me in several ways:
...
// edge case. We don't allow all digits to be 0
return +itn !== 0
} ...
return true
} Moreover, in this case I would personally prefer the format with a single line format provided by @tshemsedinov : ...
// valid format should contain 10 digits, no letters allowed
// edge case. We don't allow all digits to be 0
return !/^\d{10}$/.test(itn) && +itn !== 0
} Perhaps I don't fully understand your position... Can you explain with an example please? |
|
be-pkg-utils/src/applicationUtils.ts
Lines 178 to 184 in e969374
Also it will be better to remove
null
comparison and use string operations like .startsWith, .contains and so on in such simple cases at least we do not need regexp.The text was updated successfully, but these errors were encountered: