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

Bug 314394

Summary: [validation] validation doesn't handle redundant null checks and null point access detection correctly
Product: [WebTools] JSDT Reporter: Sven Asp <asp.sven>
Component: GeneralAssignee: Chris Jaun <cmjaun>
Status: RESOLVED WONTFIX QA Contact: Chris Jaun <cmjaun>
Severity: normal    
Priority: P3 CC: ccc, cmjaun
Version: 3.2   
Target Milestone: Future   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Complete project with preference settings none

Description Sven Asp CLA 2010-05-26 02:24:53 EDT
Build Identifier: I20100513-1500

The details are best explained by looking at the comments in this code (attached as project with project specific settings).

function getfoo() {
	return null;
}

function check1() {
	var foo = null;
	
	// The condition in the if statement should be flagged
	// as a redundant null check. That doesn't happen
	if(foo == null) {
		
		// This is correctly flagged as a null pointer
		// access
		foo.doSomething();
	}
}

function check2() {
	var foo = getfoo();
	if(foo == null) {

		// This is NOT flagged as a null pointer
		// access although it really should be.
		foo.doSomething();
	}
}

function check3() {
	var foo = null;
	
	// The condition in the if statement should be flagged
	// as a redundant null check. That doesn't happen
	if(foo != null) {
		
		// This is incorrectly flagged as a null pointer
		// access. foo cannot be null at this location.
		// This is in fact dead code but is not flagged
		// as such.
		foo.length();
	}
}


Reproducible: Always
Comment 1 Sven Asp CLA 2010-05-26 02:26:30 EDT
Created attachment 169936 [details]
Complete project with preference settings
Comment 2 Carl Anderson CLA 2010-05-26 08:46:56 EDT
Sven, judging by the build identifier, I believe you are using a Helios build.  Helios (Eclipse 3.6) corresponds to WTP 3.2. If that is not correct, please let us know.
Comment 3 Sven Asp CLA 2010-05-26 10:24:11 EDT
Yes I'm using 3.6 and everything is checked out from Helios. The IDE and other stuff that is in sync.
Comment 4 Nitin Dahyabhai CLA 2011-04-27 22:52:24 EDT
I think these checks are no longer available in 3.2.4 and 3.3.  Chris, please keep this test case in mind for when you go back to fix and enable them.
Comment 5 Chris Jaun CLA 2013-10-23 17:33:45 EDT
Most code analysis validation has been disabled and more is likely to be. These error messages are gone and won't be coming back, so closing this bug.