Need Way More Warnings

Showing 1-13 of 13 messages
Need Way More Warnings phkoester 9/10/12 11:55 AM
The Scala compiler never warns me about unused methods, parameters, local variables, and such.

If you want to use a language in a production environment with large teams---and that is where I eventually want to go---, such warnings are vital. Are there really no plans to incorporate those, or have they always been deemed as yet-to-do?

I mean, now would definitely be the time to implement them. Basically, I want all the warnings the Java compiler can issue and are configurable in Eclipse in the "Unnecessary code" section.

Please. :)
Re: [scala-user] Need Way More Warnings Alec Zorab 9/10/12 11:58 AM

My ide tells me about unused local variables, but it's important to remember that scala defaults to public accessibility, so those "unused" methods are actually part of your public api.

Re: [scala-user] Need Way More Warnings HamsterofDeath 9/10/12 12:00 PM
Am 10.09.2012 20:55, schrieb phkoester:
that's what ides are for. intellij idea has some inspections. don't know
about eclipse.
the compiler is not the right place for this, since a) it would slow
down the process b) you want this to be configurable, so you need to set
it up in your ide anyway (or fiddle with XML)
Re: [scala-user] Need Way More Warnings phkoester 9/10/12 1:15 PM
No, that's not what IDEs are for. Warnings are to be issued by the compiler, dude.

I'm an Eclipse die-hard, don't know much about IntelliJ. But on the console I use Maven, and that's where I want to see the warnings. Ideally both in the IDE and on the console, but it's the console that matters in the end.

Re: [scala-user] Need Way More Warnings som-snytt 9/10/12 1:48 PM
I was hoping something had got put behind -Xlint, but this is a case where Xlint wouldn't have told you that.

I forgot to shift my magic number by my very private lucky factor, but got no unused warning under -Xlint -Ywarn-all.

Maybe -Ywarn-all means, "why warn at all?"

If it's any consolation, under -optimise, it won't optimise anything away, either.

object Foo {
  // not a compile-time constant, because it used to be 8 every other Tuesday, but I took that out
  // because I wasn't sure it was helping.
  private [this] final val futz: Int = 7
Re: [scala-user] Need Way More Warnings Clint Gilbert 9/10/12 1:57 PM
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Is it possible to make the stock Oracle javac emit unused
method/variable errors?  I didn't see anything about that here:

http://docs.oracle.com/javase/6/docs/technotes/tools/solaris/javac.html#nonstandard

though I am by no means an expert.

Where I work, in addition to our IDEs, we've always used Sonar (which
runs CheckStyle and FindBugs) for warning on things like unused
variables and methods in Java sources.  That's not yet a great option
for Scala though.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlBOVEgACgkQ5IyIbnMUeTspNgCcD+YwSMp924v6EDvFaB8aKywa
hmwAn1yehAT3gsZXUC9qCPA/CppR3LZT
=zZHC
-----END PGP SIGNATURE-----
Re: [scala-user] Need Way More Warnings HamsterofDeath 9/10/12 2:09 PM
Am 10.09.2012 22:15, schrieb phkoester:
i disagree: yes, it is what they are for. intellij has a ton (literally)
of inspections. for all kinds of stuff, not just possible bugs. then
there's PMD, findbugs and some more tools i might not have heard of. i
don't want to see a log with 5k warnings, i want to see them on the fly
while looking at code, being offered quickfixes, having a way to let a
scan run on the complete source if i want to and the result should be
nicely readable.
lettings all inspections i use run on a 10k classes project can take
hours. compiling it takes a minute. no, i do not want the compiler to
spam warnings into the console and take hours. a compiler should warn
about what is *obivously* wrong or very dangerous or maybe even refuse
to compile it, but it's not a code inspector.
Re: [scala-user] Need Way More Warnings √iktor Klang 9/10/12 2:15 PM


On Mon, Sep 10, 2012 at 10:48 PM, Som Snytt <som....@gmail.com> wrote:
I was hoping something had got put behind -Xlint, but this is a case where Xlint wouldn't have told you that.

I forgot to shift my magic number by my very private lucky factor, but got no unused warning under -Xlint -Ywarn-all.

Maybe -Ywarn-all means, "why warn at all?"

If it's any consolation, under -optimise, it won't optimise anything away, either.

object Foo {
  // not a compile-time constant, because it used to be 8 every other Tuesday, but I took that out
  // because I wasn't sure it was helping.
  private [this] final val futz: Int = 7

}

Leave out the type ascription and it will be a constant.

Cheers,
 


On Mon, Sep 10, 2012 at 1:15 PM, phkoester <beebl...@googlemail.com> wrote:
No, that's not what IDEs are for. Warnings are to be issued by the compiler, dude.

I'm an Eclipse die-hard, don't know much about IntelliJ. But on the console I use Maven, and that's where I want to see the warnings. Ideally both in the IDE and on the console, but it's the console that matters in the end.





--
Viktor Klang

Akka Tech Lead
Typesafe - The software stack for applications that scale

Twitter: @viktorklang

Re: [scala-user] Need Way More Warnings Philip Köster 9/10/12 2:20 PM
> i disagree: yes, it is what they are for. intellij has a ton
(literally) of inspections.

That may be so. So you use IntelliJ, I use Eclipse, so who is wrong or
right? In the end it's the Odersky compiler. Not everybody in your team
may be using IntelliJ. Neither may be Jenkins or Bamboo. Not having
warnings for unused private fields or warnings is ridiculous, regardless
of the IDE.
Re: [scala-user] Need Way More Warnings phkoester 9/10/12 2:24 PM
Sorry for the obvious typo.
Re: [scala-user] Need Way More Warnings HamsterofDeath 9/10/12 2:40 PM
Am 10.09.2012 23:20, schrieb Philip Köster:
there are always exceptions. for example, if you use reflection for
whatever reason, you might have private fields which are never set, and
a smart compiler might warn you about them. but that would be wrong. you
need more information to make the warnings useful. in my ide, i can say
"in this package, i know that unused parameters are ok because these are
default values which can be used in subclasses". how to tell that to a
compiler? it cannot handle every possible case, let alone offer a
convenient way to configure all of this.
intellij has a lot of knowledge about many frameworks. it understands
springs autowired annotation. if i forget the annotation: warning. if
it's there: no warning. it understands GWTs native javascript methods.
if i call a java method from javascript: no warning. if i don't call it:
warning. a compiler simply cannot keep up with all this.
a compiler should stick to compiling, and be good at it. it may warn
about totally obvious things like unused parameters in private methods,
conditions which are guaranteed to be constant - the basic stuff.
Re: [scala-user] Need Way More Warnings Clint Gilbert 9/10/12 3:00 PM
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This isn't either/or.  There's a need for both visually-indicated
warnings and an IDE and textual warnings in some scriptable,
command-line tool.

The reference compiler is not the place to implement the latter.  For
that, I'd love to see better support for Scala in Sonar, FindBugs,
CheckStyle and their ilk, or new, similarly capable tools.

I've found these:

http://docs.codehaus.org/display/SONAR/Scala+Plugin
https://github.com/scalastyle/scalastyle
https://github.com/foursquare/linter

But they're all a bit limited.  Is there anything else out there in the
Scala static-analysis space?  Something that gives comparable output to
what Sonar provides for Java would be very, very nice.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlBOYw0ACgkQ5IyIbnMUeTvIsACfZnHAzHGafw80QaMYh6EGLm3r
5uYAn25dwWYkzNNU5FFGcfR3BhwoNv6U
=CU/h
-----END PGP SIGNATURE-----
Re: [scala-user] Need Way More Warnings som-snytt 9/10/12 5:10 PM
On Mon, Sep 10, 2012 at 2:15 PM, √iktor Ҡlang <viktor...@gmail.com> wrote:


On Mon, Sep 10, 2012 at 10:48 PM, Som Snytt <som....@gmail.com> wrote:


object Foo {
  // not a compile-time constant, because it used to be 8 every other Tuesday, but I took that out
  // because I wasn't sure it was helping.
  private [this] final val futz: Int = 7

}

Leave out the type ascription and it will be a constant.


Thanks.  But you see, I didn't want a constant because I needed to switch from Tuesdays to Thursdays without recompiling the many clients of my magic8ball.jar. 

But here is an indicator that this is non-obvious or obscure for SO users with more than three significant digits of rep:

http://stackoverflow.com/questions/12309114/why-is-a-val-inside-an-object-not-automatically-final/12313911

The phrase I appreciate is: "Update: Actually this is more curious than I expected." 

I'm not religious about what in the tool chain does it, but eventually I would like an option

scalac -Xcuriouser -Y-and-curiouser