Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
hugurhf
Post subject: Javascript validation: Using ++ and -- is considered harmful  PostPosted: Dec 17, 2005 - 12:11 AM
Registered Member
Registered Member


Joined: Oct 27, 2003
Posts: 4

The javascript validation in MyEclipse 4.1 M2 warns about using ++ and -- operators, why?

I use the ++ operator in all my for-loops [in both Java and Javascript] and I've never considered them harmful.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
support-greg
Post subject:   PostPosted: Dec 17, 2005 - 05:23 AM
Moderator
Moderator


Joined: Mar 31, 2004
Posts: 1502

Here is a quote from the JSLint guys concerning javascript.

Quote:
The ++ (post-increment) and -- (post-decrement) operators have been known to contribute to bad code by encouraging excessive trickiness. They are second only to faulty architecture in enabling to viruses and other security menaces.


So our validator by default marks them as warnings. However, you can remove them from being marked during validation by going to the Preferences > MyEclipse > Editors > Javascript > Content Assist & Validation and you can uncheck that option for ++/--. Then you can right click your file in the package explorer and run "MyEclipse > Remove All Validation Markers" and those warnings should go away.[/quote]

_________________
Greg
MyEclipse Support


Last edited by support-greg on Dec 17, 2005 - 05:24 AM; edited 1 time in total
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
mr_hyro
Post subject:   PostPosted: Apr 14, 2006 - 04:46 PM
Registered Member
Registered Member


Joined: May 31, 2005
Posts: 1

But JSLint document complains mostly about post-increment/post-decrement operators (i++), and allows pre-increment/pre-decrement operators (++i), while MyEclipse marks both cases as a warning.
 
 View user's profile Send private message  
Reply with quote Back to top
LOGUSR
Post subject:   PostPosted: Apr 24, 2006 - 02:54 PM
Registered Member
Registered Member


Joined: Apr 12, 2006
Posts: 2

Hi,

I have the same warning. I want to disable it by changing the properties but the path you gave: "Preferences > MyEclipse > Editors > Javascript > Content Assist & Validation" is not existing the myEclispe I use (4.1.1 GA)

Any suggestion ? I tried to find these settings in Project Properties -> Java Complier -> Errors/Warning without success (these are only for Java and not javascript).

Thanks
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
rateoty
Post subject:   PostPosted: Apr 27, 2006 - 10:54 AM
Registered Member
Registered Member


Joined: May 03, 2004
Posts: 71

Preferences->MyEclipse->Editors->Javascript->Javascript Source

regards Jürgen
 
 View user's profile Send private message  
Reply with quote Back to top
LOGUSR
Post subject:   PostPosted: Apr 27, 2006 - 11:26 AM
Registered Member
Registered Member


Joined: Apr 12, 2006
Posts: 2

Ok sorry,

:oops:

I had confusion between project properties and preferences because these windows looks the same...

Thanks for help.

Patrick - newbie in Eclipse
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
jacob@well.com
Post subject:   PostPosted: May 01, 2006 - 03:26 AM
Veteran Member
Veteran Member


Joined: Apr 03, 2004
Posts: 2

"The ++ (post-increment) and -- (post-decrement) operators have been known to contribute to bad code by encouraging excessive trickiness. They are second only to faulty architecture in enabling to viruses and other security menaces."

This is a really, really dumb warning to have on by default. ++ and -- can be used to make tricky code. I almost invariably only use them in loop increments where they are not dangerous AT ALL.

Someone's strange idea that they are so dangerous they should be flagged as warnings any time they are used anywhere is a very poor default.
 
 View user's profile Send private message  
Reply with quote Back to top
pbannister
Post subject:   PostPosted: May 09, 2006 - 11:51 PM



Joined: May 09, 2006
Posts: 1

I am going to have to agree with Jacob - this warning should not be on by default.

This bit of brain-damage is one of the very first things I saw when firing up MyEclipse for the first time - not encouraging.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Roguen.Keller
Post subject:   PostPosted: Jun 01, 2006 - 04:55 PM
Veteran Member
Veteran Member


Joined: Dec 08, 2004
Posts: 8

/agrees,
I don't really see the justification here, and imho I don't think this should be a default warning.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
machershell
Post subject:   PostPosted: Aug 26, 2006 - 09:31 AM
Registered Member
Registered Member


Joined: Mar 30, 2006
Posts: 7

As a subscriber to the Professional MyEclipse License, I agree whole-heartedly. pre- and post-increment (decrement) operators are the NORM. JSLint folks are in the extreme minority and these should be off by default. I use MyEclipse extensively and therefore create Many workspaces for various projects and clients. It is a very bothersome chore to have to remember to go in and set defaults to what should be considered STANDARD BEST PRACTICE. Please listen to your customers and change these defaults.

In fact, I'll go one better. Why not introduce something like the Bug Parades that other projects use? Then, you could get a realistic picture of how various settings are affecting your client-base.

And because of my rant, let me be clear: I have used Eclipse for more than 2 years now. I was introduced to MyEclipse by a recent customer (March 2006); and haven't looked back. Overall, this is a great value! Thanks for the hard work and excellent product!
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
jurriaan
Post subject: Javascript validation: Using ++ and -- is considered harmful  PostPosted: Oct 04, 2006 - 10:15 AM
Registered Member
Registered Member


Joined: Oct 04, 2006
Posts: 2

support-greg wrote:
Here is a quote from the JSLint guys concerning javascript.
Quote:
The ++ (post-increment) and -- (post-decrement) operators have been known to contribute to bad code by encouraging excessive trickiness. They are second only to faulty architecture in enabling to viruses and other security menaces.



There are no JSLint guys. It is just one guy: Douglas Crockford. While he is obviously very well versed in JavaScript, his opinions should not be taken seriously. Just to illustrate why Mr. Crockford should be considered harmful himself, here's a very simple implementation of the factorial function:

Code:
function factorial(n) {
   var f = 1;
   for( var i=1; i<n; i++ ) {
      f = f * i;
   }
   return f;
}


Mr. Crockford wants us to believe this is harmful and proposes a "better" implementation on http://javascript.crockford.com/little.html.

Code:
function y(le) {
    return function (f) {
        return f(f);
    }(function (f) {
        return le(function (x) {
            return f(f)(x);
        });
    });
}

var factorial = y(function (fac) {
    return function (n) {
        return n <= 2 ? n : n * fac(n - 1);
    };
});


I dare say that nobody except the five lispers left in this world would find the latter piece of code more concise or clear or understandable than the first.

Worse, Mr. Crockfords code is orders of magnitudes slower then the simpler one in any JS engine that I know of; and it is incorrect: Mr. Crockford's implementation computes factorial(0) wrongly as 0, instead of 1.

That said, Mr. Corckford's JSLint validator is much better than the MyEclipse validator. For example: JSLint understands extern function calls; JSLint understands W3C DOM constructions such as document.defaultView that ME does not.
 
 View user's profile Send private message  
Reply with quote Back to top
jurriaan
Post subject:   PostPosted: Oct 04, 2006 - 10:22 AM
Registered Member
Registered Member


Joined: Oct 04, 2006
Posts: 2

Oops, that should be
Quote:
for( var i=1; i<=n; i++ )
...
Guess I'm harmful myself as well... but I stick to the point I wanted to make.
 
 View user's profile Send private message  
Reply with quote Back to top
jyutzler
Post subject:   PostPosted: Oct 24, 2006 - 03:46 PM
Registered Member
Registered Member


Joined: May 06, 2005
Posts: 3

I think having this warning turned on by default is a bit much. Instances of people creating bugs by confusing prefix and postfix incremental operators have got to be extremely rare. If you are going to be excessively pedantic, you might as well flag something that is actually dangerous like:

for(i = 0; i <= n; i++)

where 'i' is not declared as a local variable and might stomp on (or be stomped on by) some other bit of code. A significant percentage of the infinite loops caused by JavaScript code can be traced back to this easily flagged mistake.
 
 View user's profile Send private message  
Reply with quote Back to top
bilbothebaggins
Post subject:   PostPosted: Jan 16, 2007 - 04:34 PM



Joined: Jun 16, 2005
Posts: 8

I'd just like to add that I also find it rather silly for this to be a default-on warning ...
 
 View user's profile Send private message  
Reply with quote Back to top
sszabo
Post subject: Javascript validation: Using ++ and -- is considered harmful  PostPosted: Aug 13, 2007 - 09:51 PM
Registered Member
Registered Member


Joined: Jan 25, 2005
Posts: 3

In my humble opinion, the core issue here that the editor's validation is TOO simple. Rather than having a warning for ON or OFF, why cant the validator check to see if the operator is contained within brackets or other risky position before presenting a warning?
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits