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

Bug 490125

Summary: Incorrect warning for "Inconsistent return types: 'null', 'String'"
Product: [ECD] Orion Reporter: Steve Northover <steve_northover>
Component: JS ToolsAssignee: Olivier Thomann <Olivier_Thomann>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: curtis.windatt.public, Olivier_Thomann
Version: 12.0   
Target Milestone: 12.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Steve Northover CLA 2016-03-21 18:08:32 EDT
This code fragment causes: Inconsistent return types: 'null', 'String'

var getProjectName = function(name2){
	if(name2.indexOf(" | ") !== -1){
		var s = name2.split(" | ");
		return s.length > 1 ?name2.split(" | ")[1].trim() : name2;
	}
	return name2;
};

Is the message correct?  If name2 is null, then the if-statement blows up before the return is hit.
Comment 1 Olivier Thomann CLA 2016-03-22 09:39:30 EDT
I'll take it. I added that check.
Comment 2 Olivier Thomann CLA 2016-03-29 13:15:50 EDT
I was checking for "string" and not "String". In some cases, the toString() on the retrieved type from tern returns "string" and sometimes it returns "String".
I'll check for both.
Comment 3 Olivier Thomann CLA 2016-03-29 13:34:16 EDT
Delivered.