-
-
Notifications
You must be signed in to change notification settings - Fork 24
eask analyze should exit with 1 on errors #359
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
Conversation
cceca43 to
f25b01e
Compare
|
I remembered why it was outputted to
Yes, but I guess we don't need it anymore since it should go to
The message commands are a bit out of control. This indeed requires some refactoring due to inconsistencies and a lack of standards. 😅
👍 Thanks for taking care of this!
Exiting code with There is a conflict between the options |
|
Cool! I didn't know about flycheck-eask. If mixed JSON+text output works there, then that's good enough. I'll figure out some way of replicating that in tests.
I meant that |
|
FYI, there is also flymake-eask too! :D
Oh, yeah! In that case, yes! 👍 |
|
Ok so I've reverted to use only stderr. In order to test the JSON output I've made it so all JSON output is on a single line. This matches how flycheck works, and I've tested that flycheck-eask still works in the updated version. |
lisp/core/analyze.el
Outdated
| (cond ((eask-json-p) ; JSON format | ||
| ;; Fill content with result. | ||
| (when (or eask-analyze--warnings eask-analyze--errors) | ||
| (setq content (json-encode |
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 pretty print eask-analyze--pretty-json is probably still better?
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.
There needs to be a way to separate JSON from plain text in tests. See the function tryJSON in analyze.test.js. It wont work if the JSON is pretty printed.
I'm assuming that the output from analyze --json is just for flycheck/flymake and so it doesn't need to be pretty printed.
The other alternative would be to write something like this https://stackoverflow.com/a/54608716, which is kind of messy and likely fragile.
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.
What if we convert the pretty print result to a single line result in the tryJSON function? 🤔
A printed result is a better UX, since I seldom read the JSON output directly from the terminal. Additionally, it's easier to debug and add new content to the output. :)
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.
Ok I made a compromise solution that assumes that all non-JSON lines don't begin with whitespace and there is a single JSON object in the output. See the comments in the code. It allows pretty-printing the output, but the test may fail while flycheck still accepts the output.
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.
I wonder why the test may fail. It seems fine and the CI passed! :D
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.
I mean, in general, you can change the code in analyze.el so that analyze --json prints output that causes the test to fail while flycheck-eask is still working.
JSON now printed without pretty-printing to ease testing
39f4059 to
0fc0e05
Compare
|
Let me know if this is ready to merge! I'll be happy to merge this! :) |
|
Yep ready to merge. I've updated the PR description to just show what was actually changed after revisions. |
|
Awesome! Merged now! Thank you so much for your hard work! 🚀 🥳 |
This moves the test for
eask analyzefrom #275 and also matches the command's behavior to what was proposed in the tests.Changes
Exit codes
eask analyzeexits with 1 if there are any errors in any of the files checked.--allow-errorhas no effect--strictflag makes any warnings cause an exit with code 1(This does not include lexical binding cookie warnings)
Others
--jsonis set, but there are no warnings or errors, output{}(Checked N files)whether there are errors or not(Checked N files)includes files with and without errors