Hi, Andy. To be clear I'm not talking about bugs but only about warnings.

On Friday, November 23, 2012 12:54:20 PM UTC+3, Andy Fingerhut wrote:
>
> I'm not advocating all of the Java coding practices that cause warnings in 
> IDEA, but my guess would be that most folks looking at the Java code used 
> to implement Clojure don't use IDEA.  It all compiles without warnings 
> using javac and ant or Maven.
>
>
But it can't - see below.
 

> Also, in looking at some of these warnings myself in IDEA, out of 
> curiosity, many of them seem to be wrong.  See in-line below for details.
>
> On Nov 23, 2012, at 12:45 AM, Alexander Semenov wrote:
>
> Hi guys.
>
> I've opened Clojure source in IDEA and wondered why are there so many 
> warnings? For example in 
> https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.javaclass
>  there are such perls as
>
> * manual array copy;
>
>
> A performance warning, sure, but not a bug.
>
> * initialization of parameterized types using non-parametrized constructor 
> (like ArrayList<Class[]> params = new ArrayList(););
> * using for loops where for each is possible;
>
>
> Seems like a style warning.
>
>
It's not a style warning. It will cause compilation warnings.

$ cat Test.java 
import java.util.List;
import java.util.ArrayList;

public class Test {
  static List<String> list = new ArrayList();
}
$ javac Test.java 
Note: Test.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
$ javac -Xlint:unchecked Test.java 
Test.java:5: warning: [unchecked] unchecked conversion
  static List<String> list = new ArrayList();
                             ^
  required: List<String>
  found:    ArrayList
1 warning
 

> * a bunch of conditional statements which are always true or false;
>
>
> I saw one warning like this that was actually true (an "if (true)" 
> statement), and a bunch that seem wrong to me, e.g. like these:
>
> static public Expr parse(Number form){
> if(form instanceof Integer
> || form instanceof Double
> || form instanceof Long)
> return new NumberExpr(form);
> else
> return new ConstantExpr(form);
> }
>
>
I mean mostly situations where old check is commented and substituted with 
something what's already known to be true or false. There is VCS history 
for that purpose, I think. Why to leave old code commented and introduce 
redundant if/then/elses?
 

> IDEA gave warnings that "form instanceOf Integer" is always false.  Maybe 
> I'm ignorant of the rules of Java, but Integer is a subclass of Number, so 
> that expression definitely looks like it can be true.  Several of the 
> warnings in that category I looked at seemed to be incorrect.  It made me 
> wonder whether this tool was worth the time to look through its warnings, 
> at least in that category.
>
> * unused parameters and local variables;
> * and so on.
>
> I also agree that this code does its job well, but why is it so negligent? 
> Doesn't being a good programmer also mean to be accurate when writing code 
> and avoid any warnings? Am I misunderstanding something?
>
> Regards, Alexander.
>
>
> Others more familiar with IntelliJ's warnings can speak more accurately on 
> the issue than I can, but I've definitely used tools before that did code 
> analysis and produced many spurious warnings, such that one learned to 
> avoid wasting one's time looking at certain categories of warnings from the 
> tool.
>
> Andy
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to