4

scalax -Xlint help provides the following info:

$ scalac -Xlint:help
Enable or disable specific warnings
  adapted-args               Warn if an argument list is modified to match the receiver.
  nullary-unit               Warn when nullary methods return Unit.
  inaccessible               Warn about inaccessible types in method signatures.
  nullary-override           Warn when non-nullary `def f()' overrides nullary `def f'.
  infer-any                  Warn when a type argument is inferred to be `Any`.
  missing-interpolator       A string literal appears to be missing an interpolator id.
  doc-detached               A Scaladoc comment appears to be detached from its element.
  private-shadow             A private field (or class parameter) shadows a superclass field.
  type-parameter-shadow      A local type parameter shadows a type already in scope.
  poly-implicit-overload     Parameterized overloaded implicit methods are not visible as view bounds.
  option-implicit            Option.apply used implicit view.
  delayedinit-select         Selecting member of DelayedInit.
  by-name-right-associative  By-name parameter of right associative operator.
  package-object-classes     Class or object defined in package object.
  unsound-match              Pattern match may not be typesafe.
  stars-align                Pattern sequence wildcard must align with sequence component.

Is there a way to enable all checks? What's the semantic of scalac -Xlint ? will it enable all? A default set (which) ? Won't do anything?

Note: Scala 2.11.8 and sbt 0.13.9

If newer versions provide different behaviour/features let me know, as updating them is not a problem

Community
  • 1
  • 1
pedrorijo91
  • 7,635
  • 9
  • 44
  • 82
  • 3
    Yes, `-Xlint` enables them all. You can check it yourself with `scala -e` and see the warning messages, for example: `scala -Xlint -e 'print("foo${1}")'` – 4e6 Jun 25 '16 at 13:07

1 Answers1

9

-Xlint currently means -Xlint:_, but that needs to be made explicit.

Historically, there have always been warnings that are too noisy or unreliable to enable by default, so there have always been warnings excluded from -Xlint.

Currently, there's one such lintable, but it's not hooked up to the command line option.

There used to be a -Ywarn-all that meant -Xlint plus those other warnings. It's not obvious why that option went away.

At one point, -Xlint:_ was going to mean -Ywarn-all, with -Xlint to mean a recommended subset, but it turns out that people like to disable one or two lint rules with -Xlint:-annoying,_, which is harder to do if that enables arbitrarily many other noisy lint rules.

Normally, scalac -X shows defaults; but probably scalac -Xlint:help will be improved to show its default behavior. That default is nontrivial for something like -Yopt.

$ scalac -help
Usage: scalac <options> <source files>
where possible standard options include:
  -X                              Print a synopsis of advanced options.


$ scalac -X
Usage: scalac <options> <source files>

-- Notes on option parsing --
Boolean settings are always false unless set.
Where multiple values are accepted, they should be comma-separated.
  example: -Xplugin:option1,option2
<phases> means one or a comma-separated list of:
  (partial) phase names, phase ids, phase id ranges, or the string "all".
  example: -Xprint:all prints all phases.
  example: -Xprint:expl,24-26 prints phases explicitouter, closelim, dce, jvm.
  example: -Xprint:-4 prints only the phases up to typer.

Possible advanced options include:
  -Xlint:<_,warning,-warning>    Enable or disable specific warnings: `_' for all, `-Xlint:help' to list
som-snytt
  • 39,429
  • 2
  • 47
  • 129
  • Could '-Xdev' replace '-Ywarn-all' and friends? I'm trying to enable *all* warnings and linters so that we can generate output to be ingested into reports for the Jenkins "Warnings Next Generation" plugin. – Jesse Adelman May 31 '19 at 21:27
  • @JesseAdelman people make jokes about how terrible warn-all is. They say they wouldn't wish it on their worst enemy, but I bet if the compiler could detect their worst enemy, they'd say OK then go ahead and enable all the nagging. – som-snytt Jun 05 '19 at 23:05
  • Where can I find documentation for 2.11 `scalac`? – Brad Solomon May 12 '20 at 10:50
  • 1
    @BradSolomon you can download a previous binary distro, and inside is `doc/tools/scalac.html` https://www.scala-lang.org/download/2.11.12.html I don't think that is kept online; also I don't think it is updated recently. – som-snytt May 12 '20 at 17:53