Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: JAVASCRIPT-1.2
-
Component/s: JavaScript
-
Labels:None
-
Number of attachments :
Description
References: Google guidelines
title
Do not use Internet Explorer's conditional comments
description
Internet Explorer offers a way to change the JavaScript code at runtime using conditional comments (activated by a <code>@cc_on</code> statement found in a comment). Using this preprocessing feature decreases readability and maintainability, and can hinder automated tools. What's more, it is specific to Internet Explorer and won't work for other browsers.
Most of the time, using those conditional comments can be easily avoided with some refactoring - using modern cross-browsers JavaScript frameworks and libraries.
The following code snippet illustrates the use of conditional comments:
/*@cc_on
/*@if (@_jscript_version >= 5)
... // some JavaScript 5 code
@else @*/
... // some "old" JavaScript code
/*@end
@*/
message
Refactor your code to avoid using Internet Explorer's conditional comments.
severity
Major
in Sonar way?
Yes
Issue Links
- is related to
-
SONARPLUGINS-2515
Update the SQALE mapping for new rules
-
Actually, I found out that "@cc_on" on single line comments may also activate the conditional comments (http://msdn.microsoft.com/en-us/library/ie/6s6fab9k%28v=vs.94%29.aspx).
My bad, I updated the description of the rule (first sentence) to reflect this.