Bug 490392 - [quickfix] Investigate quickfix to change ignore/warning/error level
Summary: [quickfix] Investigate quickfix to change ignore/warning/error level
Status: RESOLVED FIXED
Alias: None
Product: Orion (Archived)
Classification: ECD
Component: JS Tools (show other bugs)
Version: 12.0   Edit
Hardware: PC Windows 7
: P2 normal (vote)
Target Milestone: 14.0   Edit
Assignee: Curtis Windatt CLA
QA Contact:
URL:
Whiteboard: 2017-02-24
Keywords: noteworthy, triaged
Depends on: 511598
Blocks: 512316 512318 512330
  Show dependency tree
 
Reported: 2016-03-24 14:47 EDT by Steve Northover CLA
Modified: 2017-02-16 16:32 EST (History)
2 users (show)

See Also:


Attachments
The hover (12.59 KB, image/png)
2017-01-27 14:13 EST, Steve Northover CLA
no flags Details
Adds Ignore in file quickfix (12.02 KB, patch)
2017-02-01 17:03 EST, Curtis Windatt CLA
no flags Details | Diff
Example of using links (6.63 KB, image/png)
2017-02-06 17:07 EST, Curtis Windatt CLA
no flags Details
JDT fixes (95.35 KB, image/png)
2017-02-07 11:21 EST, Michael Rennie CLA
no flags Details
Links on separate lines (7.67 KB, image/png)
2017-02-07 12:03 EST, Curtis Windatt CLA
no flags Details
3 buttons on lone line (4.72 KB, image/png)
2017-02-07 12:03 EST, Curtis Windatt CLA
no flags Details
Comparison of different UIs (22.21 KB, image/png)
2017-02-07 12:13 EST, Curtis Windatt CLA
no flags Details
Matching Eclipse style (7.22 KB, image/png)
2017-02-07 16:08 EST, Curtis Windatt CLA
no flags Details
Use an expanding div (9.48 KB, patch)
2017-02-15 16:37 EST, Curtis Windatt CLA
no flags Details | Diff
Screenshot of expanding div (15.57 KB, image/png)
2017-02-15 16:38 EST, Curtis Windatt CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Northover CLA 2016-03-24 14:47:30 EDT

    
Comment 1 Steve Northover CLA 2016-03-24 16:02:52 EDT
This is just an idea.  The point is this.  When you have a warning, sometimes you just want to ignore this particular one (like @callback) or change the settings for everyone.

Let's explore what makes sense in the context of a quickfix.
Comment 2 Steve Northover CLA 2016-03-25 09:01:35 EDT
Here is another example:

function mouseDown(event) {
	//TODO - not used
}

This function has 3 warnings associated with it.  I might decide that it is ok to shadow "event" everywhere in my code.  How can I tell Orion to that shadowing this variable is ok?  Likely there is an ESLint syntax.  It would be cool to be able to do this in a quickfix ... maybe?  Discussion needed.
Comment 3 Michael Rennie CLA 2016-03-28 10:27:13 EDT
(In reply to Steve Northover from comment #2)
> Here is another example:
> 
> function mouseDown(event) {
> 	//TODO - not used
> }
> 
> This function has 3 warnings associated with it.  I might decide that it is
> ok to shadow "event" everywhere in my code.  How can I tell Orion to that
> shadowing this variable is ok?  Likely there is an ESLint syntax.  It would
> be cool to be able to do this in a quickfix ... maybe?  Discussion needed.

I envision a few fixes for this:

1. "ignore in-file" - which would add the /*eslint-disable <rule id>*/ to the file
2. "ignore all problems like this in workspace" - sets the prefs to be ignore
3. "ignore all problems like this in this project" - sets the prefs in the eslintrc file
Comment 4 Steve Northover CLA 2016-03-28 10:32:13 EDT
From a discussion with Mike, he suggests: /*eslint-disable <rule-id>*/ but I only want to disable the rule for shadowing of "event".  I know you can turn of linting for a section of code but this gets messy when the section is one variable.
Comment 5 Michael Rennie CLA 2017-01-10 15:44:32 EST
Closing as part of a mass clean up of inactive bugs. Please reopen if this problem still occurs or is relevant to you. For more details see:

https://dev.eclipse.org/mhonarc/lists/orion-dev/msg04002.html
Comment 6 Michael Rennie CLA 2017-01-12 11:59:54 EST
Reopening
Comment 7 Steve Northover CLA 2017-01-25 13:13:15 EST
We need to address this one.  Sometimes shadowing is ok in some code but not in general because I have looked at the code and decided that it is ok here, but in general, I want to be warned when I do it.

I need something like @callback pragma.
Comment 8 Steve Northover CLA 2017-01-27 14:13:58 EST
Created attachment 266499 [details]
The hover
Comment 9 Steve Northover CLA 2017-01-27 14:16:02 EST
Here is an example.  For some reason, I don't want to fix this error.  

1) I might want to go to the settings and turn it off
2) I might want to ignore this particular instance

Others?  The thing is that I want to deal with it in place and move on.  I don't want to keep seeing it.
Comment 10 Steve Northover CLA 2017-01-30 12:33:41 EST
Another options is to insert eslint directives at the top of the file as part of the quickfix.

/*eslint-env node */

/*eslint no-else-return: "none"*/

var test = require('./some_module.js');

function fred () {
	if (FRED) {
		return 12;
	} else {
		return 13;
	}
}

BTW, this currently fails but should work.
Comment 11 Steve Northover CLA 2017-01-30 12:35:46 EST
It is super painful to decide you don't want an eslint error and then try to find it in the UI.  Where is the "no-else-return" on the settings page?
Comment 12 Curtis Windatt CLA 2017-01-30 12:43:02 EST
(In reply to Steve Northover from comment #11)
> It is super painful to decide you don't want an eslint error and then try to
> find it in the UI.  Where is the "no-else-return" on the settings page?

I started a discussion previously of adding the rule names to the settings page, but we agreed that it was better to provide tooling to fix it for the user.

no-else-return
"Unnecessary else after return"
https://wiki.eclipse.org/Orion/ESLint
Comment 13 Steve Northover CLA 2017-01-30 13:04:57 EST
The idea:  I am right there in the code and I should be able to fix the code, ignore the warning for the file or ignore the warning globally without losing context.
Comment 14 Steve Northover CLA 2017-01-31 09:29:31 EST
I like these:

0. "ingore this-instance" - insert @callback or pragma around the code
1. "ignore in-file" - which would add the /*eslint-disable <rule id>*/ to the file
2. "ignore all problems like this in workspace" - sets the prefs to be ignore
3. "ignore all problems like this in this project" - sets the prefs in the eslintrc file

2) and 3) depend on whether an .eslintrc file is being used.

Mike, SSQ?
Comment 15 Curtis Windatt CLA 2017-01-31 10:07:04 EST
(In reply to Steve Northover from comment #14)
> I like these:
> 
> 0. "ingore this-instance" - insert @callback or pragma around the code
> 1. "ignore in-file" - which would add the /*eslint-disable <rule id>*/ to
> the file
> 2. "ignore all problems like this in workspace" - sets the prefs to be ignore
> 3. "ignore all problems like this in this project" - sets the prefs in the
> eslintrc file
> 
> 2) and 3) depend on whether an .eslintrc file is being used.
> 
> Mike, SSQ?

That would be a lot of quickfixes with long names, tooltips will be quite large for every single linting problem.  Might have to look at some new UI bits.
Comment 16 Michael Rennie CLA 2017-01-31 10:13:03 EST
(In reply to Steve Northover from comment #14)
> I like these:
> 
> 0. "ingore this-instance" - insert @callback or pragma around the code
> 1. "ignore in-file" - which would add the /*eslint-disable <rule id>*/ to
> the file
> 2. "ignore all problems like this in workspace" - sets the prefs to be ignore
> 3. "ignore all problems like this in this project" - sets the prefs in the
> eslintrc file
> 
> 2) and 3) depend on whether an .eslintrc file is being used.
> 
> Mike, SSQ?

Those all make sense to me, but I have the same concern as Curtis - thats a lot of fixes to show for every single problem. My fear is that the useful fixes will be lost in the noise of the ignore fixes - unless we could have some other kind of UI for the ignore fix (like a drop down or something to choose the way to ignore, I dunno)
Comment 17 Steve Northover CLA 2017-01-31 12:15:25 EST
Are these the cases?

Fix ( ) here, ( ) in file, ( ) in project, ( ) in workspace
Ignore ( ) here, ( ) in file, ( ) in project, ( ) in workspace

Fixing all the code everywhere would be incredible (possibly).  This is like refactoring where you get a UI to review the changes, with things selected etc.
Comment 18 Michael Rennie CLA 2017-01-31 13:39:53 EST
(In reply to Steve Northover from comment #17)
> Are these the cases?
> 
> Fix ( ) here, ( ) in file, ( ) in project, ( ) in workspace
> Ignore ( ) here, ( ) in file, ( ) in project, ( ) in workspace

That looks correct to me.

> 
> Fixing all the code everywhere would be incredible (possibly).  This is like
> refactoring where you get a UI to review the changes, with things selected
> etc.

That would be very cool. There are certain classes of problems we could easily make a "fix in project" scheme for (because we know 100% the code change is non-breaking, like the "semi" rule)
Comment 19 Curtis Windatt CLA 2017-02-01 17:03:59 EST
Created attachment 266578 [details]
Adds Ignore in file quickfix

This patch adds a quick fix that will add an eslint-disable property to your file to disable whatever lint warning you are hovering on.  It sets up the framework for more such quickfixes by passing along the rule ID in the annotation data.  Next steps:

1) Finish the logic to handle updating eslint-enable, working around eslint-env directives, etc.
2) Add a test suite for the quick fix
3) Create a quick fix that will update project settings
4) Look at a custom UI in the quick fix rendering
Comment 20 Curtis Windatt CLA 2017-02-02 17:18:23 EST
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=660ee2d75baf017163d4d784c6dc3e96e61d20ac
I pushed in the framework bits, quickfix implementation and the test suite to master.

The quick fix command is hidden behind a dark launch flag. Set localStorage.ignoreQuickfix = true, then have the javascript tooling plugin restart.
Comment 21 Steve Northover CLA 2017-02-02 17:32:44 EST
Perfect.  Will try it out tomorrow.
Comment 22 Steve Northover CLA 2017-02-05 08:18:12 EST
There is a bug that 'Ignore in file' scrolls to the top of the file, causing you to lose context.  Please fix this.
Comment 23 Steve Northover CLA 2017-02-05 08:27:28 EST
The quickfix should provide a link to the global setting or eslint.rc, depending on which is being used.  

IDEA: The simplest UI could be a 3 buttons and a link: 

    Fix, Fix All, Ignore All, Settings ...

We forget about telling the guy what we are going to do (ie. 'Update Operator') on the text of the button (or we could tell him elsewhere).
Comment 24 Curtis Windatt CLA 2017-02-06 09:56:05 EST
(In reply to Steve Northover from comment #22)
> There is a bug that 'Ignore in file' scrolls to the top of the file, causing
> you to lose context.  Please fix this.

Whilte I could see some user wanting to know what was changed in the file, I agree that we shouldn't interrupt the user's workflow.  I will use some of the logic we use for quick fix all to keep the annotation location visible.

(In reply to Steve Northover from comment #23)
>     Fix, Fix All, Ignore All, Settings ...
> 
> We forget about telling the guy what we are going to do (ie. 'Update
> Operator') on the text of the button (or we could tell him elsewhere).

While having a simpler UI would be great, I would have difficulty trusting a tool to Fix All problems when I have no idea what kind of change it is going to make (remember some quick fixes delete code).

I think we should keep the existing quick fix text, possibly reopening the discussion on styling them as links rather than buttons.  Then have some separate UI changing ignore settings.
Comment 25 Curtis Windatt CLA 2017-02-06 13:50:13 EST
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=e50c54f29dc1d3ae96776d92758a17cda0968115
Fixed issues with the eslint-enable edit and added tests

(In reply to Steve Northover from comment #22)
> There is a bug that 'Ignore in file' scrolls to the top of the file, causing
> you to lose context.  Please fix this.

This is more difficult than expected, turning off the show selection flag is not enough.  After the edits are done, all the previous offsets are wrong.  If I don't find another workaround I will have to add the support in the setText function.
Comment 26 Curtis Windatt CLA 2017-02-06 14:27:05 EST
(In reply to Curtis Windatt from comment #25)
> (In reply to Steve Northover from comment #22)
> > There is a bug that 'Ignore in file' scrolls to the top of the file, causing
> > you to lose context.  Please fix this.
> 
> This is more difficult than expected, turning off the show selection flag is
> not enough.  After the edits are done, all the previous offsets are wrong. 
> If I don't find another workaround I will have to add the support in the
> setText function.

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=97d20d1baf4d821573766a3eb3e8ff5c665e5fb8
Ok, found a workaround, I include an additional no-op edit that will set the selection to where the hovered annotation was.
Comment 27 Curtis Windatt CLA 2017-02-06 17:07:12 EST
Created attachment 266688 [details]
Example of using links

After experimenting with a few UI controls, I still think links are the way to go. I'm thinking a line of text "Ignore in:" followed by links with better spacing "File" "Workspace" ".eslintrc".
Comment 28 Steve Northover CLA 2017-02-06 17:42:34 EST
Hmm ... looks confusing.  Please mock up 3 buttons:

[Fix][Fix all][Ignore all]

The text that describes the fix can be a hover.  This will catch all the cases we have today and be clear about will happen when I press the button.  If this looks ok, we can revisit doing better and capturing all the cases in a better UI.
Comment 29 Curtis Windatt CLA 2017-02-07 09:57:28 EST
(In reply to Steve Northover from comment #28)
> Hmm ... looks confusing.  Please mock up 3 buttons:
> 
> [Fix][Fix all][Ignore all]
> 
> The text that describes the fix can be a hover.  This will catch all the
> cases we have today and be clear about will happen when I press the button. 
> If this looks ok, we can revisit doing better and capturing all the cases in
> a better UI.

Would [Ignore all] set the disable directive in the file or modify your workspace settings or modify eslintrc? For the mockup it will just use eslint-disable as I have that implemented.
Comment 30 Michael Rennie CLA 2017-02-07 11:21:04 EST
Created attachment 266707 [details]
JDT fixes

I think we should follow JDT's lead here. The attached screen shot shows all the fixes for a given problem (in JDT), and includes a link to changes the prefs. The presentation is clear, concise and the user understands what each link will do with a glance.

In our case though, we would also want a fix to "ignore in file".
Comment 31 Steve Northover CLA 2017-02-07 11:49:50 EST
The Eclipse UI looks nice.  These are all separate and different fixes for the same problem.  Would we unroll the (x) check box?  What does the UI look like with links for the particular case?  Three links?

We need to provide this functionality:

[Fix][Fix all][Ignore all]

Are these the links:

"Update operator"
"Update operator in file"
"Ignore in file"

Are we making sentences out of "Update operator"?  Where does that string come from.
Comment 32 Curtis Windatt CLA 2017-02-07 12:03:01 EST
Created attachment 266708 [details]
Links on separate lines
Comment 33 Curtis Windatt CLA 2017-02-07 12:03:23 EST
Created attachment 266709 [details]
3 buttons on lone line
Comment 34 Curtis Windatt CLA 2017-02-07 12:13:29 EST
Created attachment 266710 [details]
Comparison of different UIs
Comment 35 Curtis Windatt CLA 2017-02-07 16:08:30 EST
Created attachment 266716 [details]
Matching Eclipse style

3 links, indents the fix all when available just like Eclipse.  This is fully functional, not just a mock up.  Changing the link color and underline is a little harder because the page theme overrides link (a) elements.
Comment 36 Steve Northover CLA 2017-02-07 16:27:04 EST
I'm guessing that if I hover with the mouse, I see the links?  Without the hover, it looks like the text is mis-aligned/badly formatted.

If we are giving links, then these are like Windows 7 "Command Buttons".  They contain sentences and icons.  This is essentially what Eclipse is doing.  This sounds like work because you need an ignore sentence and it should not be constructed from the "fix action" sentence fragment.
Comment 37 Curtis Windatt CLA 2017-02-15 16:37:39 EST
Created attachment 266833 [details]
Use an expanding div
Comment 38 Curtis Windatt CLA 2017-02-15 16:38:05 EST
Created attachment 266834 [details]
Screenshot of expanding div
Comment 39 Curtis Windatt CLA 2017-02-16 12:32:57 EST
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=b443c3506fb296c184dda3a403485b21e607040b
Removed dark launch flag
Fixed command to only show when ruleID is set
Disable fix will always show at bottom of quick fix list

Closing as FIXED.  I will open new bugs for future enhancements.