Does scalastyle:ignore work on lines with magic numbers?

70 views
Skip to first unread message

lee tibbert

unread,
May 2, 2015, 3:13:57 PM5/2/15
to scalasty...@googlegroups.com
First & most importantly, thank you for the excellent
scalaStyle.

A number of tails of who start with "I have inherited
this code...".

Well, I have inherited the (slightly obfuscated) code
below and am trying to get it to pass ScalaStyle.

 val a = new b.c(1234)

ScalaStyle, rightly, complains about the magic number.

The ScalaStyle documentation states/implies that
adding // scalastyle:ignore should defeat all checking
of that one line only.
 
 val a = new b.c(1234) // scalastyle:ignore

After I add // scalastyle:ignore (and write all
dirty buffers, etc.), ScalaStyle _still_ complains
about the magic number.

Is this supposed to work, or have I missed something
in either my reading of the documentation or editing
of the file?

I am able to work around this by, as documented,
turning scalastyle magic.number off and on on the
lines before and after the call. 

For my own understanding & education, I would like
to figure out the 'ignore' format.  Changing one line
in inherited code rather than two makes it more
likely that I will make the change. Besides, the
inline form shows up better in diff. I am probably
preaching to the choir, These are probably the reasons
that some kind soul took the time to implement in the
first place ;-)

Thank you,

Lee

Matthew Farwell

unread,
May 2, 2015, 3:51:00 PM5/2/15
to scalasty...@googlegroups.com
Hi,

This is supposed to work. Could you raise an issue please in https://github.com/scalastyle/scalastyle/issues

There is definitely something amiss here. There is something strange going on here. If I activate the Magic Number with the following file:

package foo
 
object Foo {
f(77) // scalastyle:ignore
f(88) 
f(99)
}

then I only get one warning, for line 6: f(99), whereas I should get one for line 5: f(88) as well. I don't know if it really is linked, but it seems suspiciously close.

Thanks.

Matthew


--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "Scalastyle users".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse scalastyle-use...@googlegroups.com.
Pour envoyer un message à ce groupe, envoyez un e-mail à l'adresse scalasty...@googlegroups.com.
Visitez ce groupe à l'adresse http://groups.google.com/group/scalastyle-users.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.

lee tibbert

unread,
May 2, 2015, 6:58:26 PM5/2/15
to scalasty...@googlegroups.com

Matthew,

Thank you for checking this out & the sanity check.

Guess I now have  reason enough to be contemporary
and get a github account.

I can not create the issue today, but I will get to it
as soon as I can.

Lee


lee tibbert

unread,
May 3, 2015, 10:34:02 AM5/3/15
to scalasty...@googlegroups.com

GitHub scalastyle/scalastyle Issue #144 created.
Reply all
Reply to author
Forward
0 new messages