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

errors,tools: ASCIIbetical instead of alphabetical #15578

Merged
merged 0 commits into from
Sep 28, 2017

Conversation

refack
Copy link
Contributor

@refack refack commented Sep 23, 2017

Fixes: #15576

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

errors,tools

@nodejs-github-bot nodejs-github-bot added errors Issues and PRs related to JavaScript errors originated in Node.js core. tools Issues and PRs related to the tools directory. labels Sep 23, 2017
@refack
Copy link
Contributor Author

refack commented Sep 23, 2017

/cc @maclover7

if (prev >= curr) {
context.report({
node: node,
message: message + ` - pref:${prev} < curr:${curr}`
Copy link
Member

Choose a reason for hiding this comment

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

typo: pref -> prev

@refack
Copy link
Contributor Author

refack commented Sep 24, 2017

I reworked the error message completely:
image

d:\code\node-cur\lib\internal\errors.js
  147:1  error  Out of ASCIIbetical order - ERR_HTTP_TRAILER_INVALID >= ERR_HTTP2_CONNECT_AUTHORITY           alphabetize-errors
  147:1  error                                  (95)_                >=         2(50)                         alphabetize-errors
  165:1  error  Out of ASCIIbetical order - ERR_HTTP2_HEADER_SINGLE_VALUE >= ERR_HTTP2_HEADERS_AFTER_RESPOND  alphabetize-errors
  165:1  error                                          (95)_             >=                 S(83)            alphabetize-errors
  262:1  error  Out of ASCIIbetical order - ERR_OUT_OF_RANGE >= ERR_OUTOFMEMORY                               alphabetize-errors
  262:1  error                                 (95)_         >=        O(79)                                  alphabetize-errors

✖ 6 problems (6 errors, 0 warnings)

let tmp = ' '.repeat(j) + opStr + ' '.repeat(l - oLen - j);
const k2 = k - lm.length + 1;
const k3 = k2 + km.length;
const message2 = tmp.substr(0, k2) + km + tmp.substr(k3) + lm;
Copy link
Member

Choose a reason for hiding this comment

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

Isn't it easier to just show the index where the two strings differ?

Copy link
Member

Choose a reason for hiding this comment

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

This is not really readable. Especially the variable names are pretty bad. Without checking to closely I am also pretty sure this could probably be simplified a bit so it is better to read afterwards.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Easy? 😤 easy for someone else...
yeah I was bored this morning

But seriously, I think it's a nice and informative feedback, and I don't assume this error should happen too often, so I can take it or leave it..

Copy link
Member

Choose a reason for hiding this comment

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

My point is that I don't care if _ >= O for example. I find it sufficient to know the index where the issue happens (e.g. 7 for ERR_OUT_OF_RANGE and ERR_OUTOFMEMORY) but I understand this is very personal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack.

@maclover7
Copy link
Contributor

@refack interesting PR! Overall looks good, only concern is that the new "is there a problem" / message generating logic is a little bit hard to grok -- would it be possible to move these back to separate functions?

@refack
Copy link
Contributor Author

refack commented Sep 24, 2017

message generating logic is a little bit hard to grok

Yeah a little bit overboard. Not sure if I could understand it in a week...

@refack
Copy link
Contributor Author

refack commented Sep 25, 2017

Removed obfus code. Now the errors looks like:

d:\code\node-cur\lib\internal\errors.js
  147:1  error  Out of ASCIIbetical order - ERR_HTTP_TRAILER_INVALID >= ERR_HTTP2_CONNECT_AUTHORITY           alphabetize-errors
  165:1  error  Out of ASCIIbetical order - ERR_HTTP2_HEADER_SINGLE_VALUE >= ERR_HTTP2_HEADERS_AFTER_RESPOND  alphabetize-errors
  262:1  error  Out of ASCIIbetical order - ERR_OUT_OF_RANGE >= ERR_OUTOFMEMORY                               alphabetize-errors

✖ 3 problems (3 errors, 0 warnings)

and IMHO it's informative enough.

Linter CI: https://ci.nodejs.org/job/node-test-linter/12025/

@maclover7
Copy link
Contributor

I'm not a collaborator, but 👍, much simpler now

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

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

I see the point but I'm not a fan of landing this right now. Perhaps after we get all of the codes migrated, otherwise it just ends up causing additional churn.

@refack
Copy link
Contributor Author

refack commented Sep 26, 2017

I see the point but I'm not a fan of landing this right now. Perhaps after we get all of the codes migrated, otherwise it just ends up causing additional churn.

Other way around. It's already in and has been breaking the lint CI for over a week. I had to hack the lint machine to use LC_ALL=en_US.

@refack
Copy link
Contributor Author

refack commented Sep 28, 2017

@jasnell linter fails when it runs on the other (unpatched) machine test-rackspace-freebsd10-x64-1 https://ci.nodejs.org/job/node-test-linter/12073/

@jasnell
Copy link
Member

jasnell commented Sep 28, 2017

hmm... ok. I'd just generally prefer that we not shuffle these ids around too much more until we get them all migrated as it makes getting those PRs landed much more difficult.

@jasnell jasnell dismissed their stale review September 28, 2017 12:56

Removing my -1

@refack refack closed this Sep 28, 2017
@refack refack merged commit 5f46944 into nodejs:master Sep 28, 2017
@refack refack deleted the reorder-errorcodes branch September 28, 2017 13:18
@refack
Copy link
Contributor Author

refack commented Sep 28, 2017

@nodejs/release you might want to cherry-pick to v8.x-staging (https://ci.nodejs.org/job/node-test-linter/12101/)

not ok 3 - /usr/home/iojs/build/workspace/node-test-linter/lib/internal/errors.js
  ---
  message: Errors in lib/internal/errors.js must be alphabetized
  severity: error
  data:
    line: 244
    column: 1
    ruleId: alphabetize-errors
  messages:
    - message: Errors in lib/internal/errors.js must be alphabetized
      severity: error
      data:
        line: 251
        column: 1
        ruleId: alphabetize-errors
  ...

addaleax pushed a commit to addaleax/ayo that referenced this pull request Sep 30, 2017
PR-URL: nodejs/node#15578
Fixes: nodejs/node#15576
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
refack added a commit to refack/node that referenced this pull request Oct 3, 2017
PR-URL: nodejs#15578
Fixes: nodejs#15576
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
MylesBorins pushed a commit that referenced this pull request Oct 3, 2017
PR-URL: #15578
Fixes: #15576
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Oct 3, 2017
@MylesBorins
Copy link
Contributor

MylesBorins commented Oct 3, 2017

I lied... need it one more time

please open a new PR

MylesBorins pushed a commit that referenced this pull request Dec 19, 2017
PR-URL: #15578
Fixes: #15576
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@gibfahn gibfahn mentioned this pull request Dec 20, 2017
gibfahn pushed a commit that referenced this pull request Dec 20, 2017
PR-URL: #15578
Fixes: #15576
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@gibfahn gibfahn mentioned this pull request Dec 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
errors Issues and PRs related to JavaScript errors originated in Node.js core. tools Issues and PRs related to the tools directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

linter is sensitive to locale
7 participants