Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 315417

Summary: Missing baseline warning cannot be disabled
Product: [Eclipse Project] PDE Reporter: Olivier Thomann <Olivier_Thomann>
Component: API ToolsAssignee: Dani Megert <daniel_megert>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: angvoz.dev, ankur_sharma, curtis.windatt.public, Curtis_Windatt, daniel_megert, markus.kell.r, Michael_Rennie, raksha.vasisht, saurav.sarkar1
Version: 3.6Flags: Michael_Rennie: review+
Target Milestone: 3.7 RC1   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Proposed fix
none
Possible fix for 3.7 none

Description Olivier Thomann CLA 2010-06-02 12:09:16 EDT
This warning is reported when a baseline has not been set for the workspace, but the project is set to use api tooling.
This is an option defined only against the workspace and cannot be customized per project.
If I uncheck it inside the baseline preference page, I still get the warning after a build.
The problem seems to come from the fact that the instance scope is not checked when the project is not null in org.eclipse.pde.api.tools.internal.provisional.ApiPlugin.getSeverityLevel(String, IProject).
Comment 1 Olivier Thomann CLA 2010-06-02 12:09:50 EDT
This should be fixed for 3.6.1 as this warning should be removed if set to be ignored.
Comment 2 Olivier Thomann CLA 2010-06-02 12:19:14 EDT
Created attachment 170830 [details]
Proposed fix
Comment 3 Olivier Thomann CLA 2010-06-02 12:20:15 EDT
Michael, please review.
Comment 4 Michael Rennie CLA 2010-06-18 10:56:50 EDT
this fix brings back the problem described in bug 280619 comment #13 - if a project has settings but a pref does not appear in them we improperly cascade to lookup the workspace setting.
Comment 5 Olivier Thomann CLA 2010-06-18 11:00:51 EDT
Then we need to revisit it.
Maybe the previous fix was not exactly what it should be.
Comment 6 Michael Rennie CLA 2010-06-18 13:23:36 EDT
I think the bigger issue might be that our getSeverity(...) method only really works with preferences that exist in all three scopes (project, instance, default). 

Maybe we could add the baseline notification pref to the project scope, or have a different method like getSeverity(pref_id, scopes[])?
Comment 7 Olivier Thomann CLA 2010-07-13 13:13:11 EDT
Michael, I let you take care of this since you change the scopes to fix bug 280619.
Thanks.
Comment 8 Dani Megert CLA 2010-12-02 03:32:29 EST
The correct fix is to also have that option on the project. Why? Because currently many committers simply ignore the warning and forget to add the baseline and then they introduce API errors in their code without noticing it (see bug 326926 comment 22) for latest example I ran into). The project (owner) itself has no way to force developers to use API Tools since there is no way to have the missing baseline being reported as error. Also, setting the workspace severity to 'Error' would be a bit harsh at this point.

I'd really like to see this in 3.7.
Comment 9 Dani Megert CLA 2010-12-02 10:26:20 EST
> Also, setting the workspace severity to 'Error' would be a bit harsh at this 
> point.
Actually not. We should consider doing that: if a project decides to enable API Tools then it wants its committers to use it and that can only be signaled by reporting an error for the missing baseline. This also makes sense because some of the API Tools errors have severity 'Error' by default. If a user is annoyed by that then he can easily reduce the severity on the preference page.
Comment 10 Dani Megert CLA 2010-12-02 10:28:42 EST
Ankur, Curtis, what do you think about setting the severity to 'Error'? I think this would be a great improvement for API Tools.
Comment 11 Dani Megert CLA 2010-12-06 11:37:50 EST
(In reply to comment #10)
> Ankur, Curtis, what do you think about setting the severity to 'Error'? I think
> this would be a great improvement for API Tools.

We've discussed this on our weekly PDE call and decided to go forward with this. Filed bug 331924 to track that.
Comment 12 Dani Megert CLA 2010-12-06 11:56:32 EST
Olivier, I tried your steps and I cannot reproduce the problem using I20101205-2000. Can you still reproduce? If so, can you provide more detailed steps?
Comment 13 Michael Rennie CLA 2011-05-02 10:16:11 EDT
*** Bug 344417 has been marked as a duplicate of this bug. ***
Comment 14 Curtis Windatt CLA 2011-05-04 11:01:50 EDT
Marking as WORKSFORME.  The default setting was changed for 3.7.
Comment 15 Ankur Sharma CLA 2011-05-04 12:02:58 EDT
The problem is real and not related to the default setting. But yes that has exposed it.

Steps to repro

1. Have a project with API analysis.
2. Do not add baseline.
3. Enable project specific PDE errors/warning preferences
4. Turn the Missing Baseline preference to Ignore

The error marker appears for the project even when the pref is marked Ignore


The cause of the error is the pref fetch logic in APIPlugin. When the project specific prefs are enable, the fall back should be Workspace prefs (InstanceScope) and not the Defaults (DefaultScope).

The patch has been attached to Bug #344417
Comment 16 Andrew Gvozdev CLA 2011-05-04 12:13:08 EDT
Yes I confirm, it is a problem for me too. I downloaded latest build N20110503 and it is still there.

I am working on changes to CDT which spans across several releases and by that reason I cannot set definite @since tags. With the change of default settings I always get baseline errors on all CDT projects and not able to reduce those to warnings.
Comment 17 Michael Rennie CLA 2011-05-04 16:57:00 EDT
The problem with applying the patch Bug #344417 is that if a project has older project specific settings that do not contain a given key (for example the auto-remove filters key from bug 280619) we end up cascading to the workspace preference.

What should we be doing in the case a key is not present in the project scope (but expected to be)?

Should we initialize it to the workspace value - which is what we do if you set up project specific settings for the first time on a project? If so, then the patch from bug 344417 would fix this, with a minor update to the ApiErrorsAndWarningsConfigurationBlock#addCheckbox(..) method

Should a non-existent key in the project scope be initialized to the value from the default scope?

Dani / Olivier what does JDT do when a new preference is added as a workspace + project specific setting and the user has not updated existing project specific settings?
Comment 18 Dani Megert CLA 2011-05-05 12:15:10 EDT
> Dani / Olivier what does JDT do when a new preference is added as a workspace 
> + project specific setting and the user has not updated existing project 
> specific settings?
See org.eclipse.jdt.ui.PreferenceConstants.getPreference(String, IJavaProject). In that sense the patch doesn't even go far enough - it should set the context to:
new IScopeContext[] {new ProjectScope(project), InstanceScope.INSTANCE, DefaultScope.INSTANCE};

But I would not make that change now in RC1.

For 3.7 we could consider to keep a list of workspace only preference keys (is there another one besides the missing baseline?) and treat it specially.
Comment 19 Dani Megert CLA 2011-05-05 12:17:36 EDT
Created attachment 194850 [details]
Possible fix for 3.7

Shows direction of a fix using a list of workspace only preference keys. If it turns out that there's only one, then we could inline this directly into ApiPlugin.hasProjectSettings(String, IProject) for 3.7.
Comment 20 Dani Megert CLA 2011-05-11 09:59:21 EDT
Ping!
Comment 21 Michael Rennie CLA 2011-05-11 12:05:25 EDT
+1 the patch works well.
Comment 22 Markus Keller CLA 2011-05-11 13:03:55 EDT
Mike, can you commit this? Dani can't do it any more for RC1.
Comment 23 Michael Rennie CLA 2011-05-11 15:22:42 EDT
(In reply to comment #22)
> Mike, can you commit this? Dani can't do it any more for RC1.

done.
Comment 24 Raksha Vasisht CLA 2011-05-16 10:22:29 EDT
Verified for RC1 with  I20110514-0800.