首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何将`sbt`配置为不显示警告"Warning private default argument in object * is never used“

如何将`sbt`配置为不显示警告"Warning private default argument in object * is never used“
EN

Stack Overflow用户
提问于 2020-11-30 19:06:47
回答 1查看 260关注 0票数 0

我有一个scala编译器2.12.11,编译器会打印一些警告,比如:

在使用时使用private default argument in class SomeClass is never used

我见过一个Scala 2.12.2 emits a ton of useless "Warning: parameter value ... in method ... is never used" warnings. How to get rid of them?,但是它对我没有帮助,因为它不可能否定params

你能帮我抑制这个警告,但是保存另一个unused警告吗?目前,我有-Xlint选项。

EN

回答 1

Stack Overflow用户

发布于 2020-12-18 18:16:10

您可以手动打开特定的选项,而不是使用批处理的-Xlint。对于2.13中的instant,我可以像这样打印可用的选项:

代码语言:javascript
运行
复制
scalac -Xlint:help
Enable recommended warnings
  adapted-args            An argument list was modified to match the receiver.
  nullary-unit            `def f: Unit` looks like an accessor; add parens to look side-effecting.
  inaccessible            Warn about inaccessible types in method signatures.
  infer-any               A type argument was inferred as Any.
  missing-interpolator    A string literal appears to be missing an interpolator id.
  doc-detached            When running scaladoc, warn if a doc comment is discarded.
  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 an implicit view.
  delayedinit-select      Selecting member of DelayedInit.
  package-object-classes  Class or object defined in package object.
  stars-align             In a pattern, a sequence wildcard `_*` should match all of a repeated parameter.
  strict-unsealed-patmat  Pattern match on an unsealed class without a catch-all.
  constant                Evaluation of a constant arithmetic expression resulted in an error.
  unused                  Enable -Wunused:imports,privates,locals,implicits,nowarn.
  nonlocal-return         A return statement used an exception for flow control.
  implicit-not-found      Check @implicitNotFound and @implicitAmbiguous messages.
  serial                  @SerialVersionUID on traits and non-serializable classes.
  valpattern              Enable pattern checks in val definitions.
  eta-zero                Usage `f` of parameterless `def f()` resulted in eta-expansion, not empty application `f()`.
  eta-sam                 The Java-defined target interface for eta-expansion was not annotated @FunctionalInterface.
  deprecation             Enable -deprecation and also check @deprecated annotations.
  byname-implicit         Block adapted by implicit with by-name parameter.
  recurse-with-default    Recursive call used default argument.
  unit-special            Warn for specialization of Unit in parameter position.
  multiarg-infix          Infix operator was defined or used with multiarg operand.
  implicit-recursion      Implicit resolves to an enclosing definition.
Default: All choices are enabled by default.

因此,例如,我可以启用-Xlint:inaccessible -Xlint:adapted-args -Wunused:privates,locales或任何我想要的东西,而不是一切。对于2.12版本,这个列表将有所不同。(您也可以查看scalac -Xscalac -Yscalac -W)。

另一种方法是启用警告,并在您有意识地“破坏”某些内容时抑制它们。对于未使用的,你有@scala.annotation.unused,对于2.12中的其他警告,在有silencer插件之前,从2.13开始有@scala.annotation.nowarn注释。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65072381

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档