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

Minor fix params description for addPercent function #12669

Merged
merged 1 commit into from
May 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ function generateMDTable(headers, body) {

/**
* Generates a user-readable string from a percentage change
* @param {string[]} headers
* @param {number} change
* @param {boolean} includeEmoji
*/
function addPercent(change, includeEmoji) {
if (!isFinite(change)) {
Copy link
Contributor Author

@bee0060 bee0060 Apr 22, 2018

Choose a reason for hiding this comment

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

I just read some code in dangerFile. And found code on line 65

if (/^-|^0(?:\.0+)$/.test(formatted)) {

I am not sure the purpose of this code, but when formatted equals -.2abc this .test(formatted) will also return true,( it will return true with any strings start with -) does it meet the expectation ? Or is it a bug?

If here just want to return formatted when change less than or equals 0, maybe replace this code by:

if (change <= 0) {

would be easier to understand.

Copy link
Contributor

Choose a reason for hiding this comment

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

formatted should never be an arbitrary string, so cases like -2.abc aren't really a concern.

Expand Down