是否可以在 scalac 中只关闭一种特定类型的警告?
Is it possible to turn of only a specific kind of warning in scalac?
说我固执,但他们可以让我的 /:
和 :\
脱离我冰冷、僵硬的手指。我等不及 scala 2.14 应该消失了,这样我就可以实现我自己的并完全摆脱弃用警告,但在此期间我能做些什么吗 - 在 scalac、sbt 或至少 IntelliJ 中过滤掉那些警告?我对 sbt 绝对是菜鸟,但这似乎应该很容易完成。
Scala 2.13.2 几天前刚刚发布,其中包括用于可配置警告的新 -Wconf
标志。参见 https://github.com/scala/scala/pull/8373
Configure compiler warnings.
Syntax: -Wconf:<filters>:<action>,<filters>:<action>,...
multiple <filters> are combined with &, i.e., <filter>&...&<filter>
Note: Run with `-Wconf:any:warning-verbose` to print warnings with their category, site,
and (for deprecations) origin and since-version.
<filter>
- Any message: any
- Message categories: cat=deprecation, cat=lint, cat=lint-infer-any
The full list of warning categories is shown at the end of this help text.
- Message content: msg=regex
The regex need only match some part of the message, not all of it.
- Site where the warning is triggered: site=my\.package\..*
The regex must match the full name (`package.Class.method`) of the warning position.
- Source file name: src=src_managed/.*
If `-rootdir` is specified, the regex must match the canonical path relative to the
root directory. Otherwise, the regex must match the canonical path relative to any
path segment (`b/.*Test.scala` matches `/a/b/XTest.scala` but not `/ab/Test.scala`).
Use unix-style paths, separated by `/`.
- Origin of deprecation: origin=external\.package\..*
The regex must match the full name (`package.Class.method`) of the deprecated entity.
- Since of deprecation: since<1.24
Valid operators: <, =, >, valid versions: N, N.M, N.M.P. Compares against the first
version of the form N, N.M or N.M.P found in the `since` parameter of the deprecation,
for example `1.2.3` in `@deprecated("", "some lib 1.2.3-foo")`.
<action>
- error / e
- warning / w
- warning-summary / ws (summary with the number of warnings, like for deprecations)
- warning-verbose / wv (show warning category and site)
- info / i (infos are not counted as warnings and don't affect `-Werror`)
- info-summary / is
- info-verbose / iv
- silent / s
The default configuration is:
-Wconf:cat=deprecation:ws,cat=feature:ws,cat=optimizer:ws
User-defined configurations are added to the left. The leftmost rule matching
a warning message defines the action.
Examples:
- change every warning into an error: -Wconf:any:error
- silence certain deprecations: -Wconf:origin=some\.lib\..*&since>2.2:s
Full list of message categories:
- deprecation
- feature, feature-dynamics, feature-existentials, feature-higher-kinds, feature-implicit-conversions, feature-macros, feature-postfix-ops, feature-reflective-calls
- java-source
- lint, lint-adapted-args, lint-byname-implicit, lint-constant, lint-delayedinit-select, lint-deprecation, lint-doc-detached, lint-eta-sam, lint-eta-zero, lint-implicit-not-found, lint-inaccessible, lint-infer-any, lint-missing-interpolator, lint-nonlocal-return, lint-nullary-override, lint-nullary-unit, lint-option-implicit, lint-package-object-classes, lint-poly-implicit-overload, lint-private-shadow, lint-recurse-with-default, lint-serial, lint-stars-align, lint-type-parameter-shadow, lint-unit-specialization
- optimizer
- other, other-debug, other-match-analysis, other-migration, other-pure-statement, other-shadowing
- scaladoc
- unchecked
- unused, unused-imports, unused-locals, unused-nowarn, unused-params, unused-pat-vars, unused-privates
- w-flag, w-flag-dead-code, w-flag-extra-implicit, w-flag-numeric-widen, w-flag-self-implicit, w-flag-value-discard
To suppress warnings locally, use the `scala.annotation.nowarn` annotation.
Note: on the command-line you might need to quote configurations containing `*` or `&`
to prevent the shell from expanding patterns.
对于仍然坚持早期 Scala 版本的其他人,可以使用消音器 scalac 插件:https://github.com/ghik/silencer
说我固执,但他们可以让我的 /:
和 :\
脱离我冰冷、僵硬的手指。我等不及 scala 2.14 应该消失了,这样我就可以实现我自己的并完全摆脱弃用警告,但在此期间我能做些什么吗 - 在 scalac、sbt 或至少 IntelliJ 中过滤掉那些警告?我对 sbt 绝对是菜鸟,但这似乎应该很容易完成。
Scala 2.13.2 几天前刚刚发布,其中包括用于可配置警告的新 -Wconf
标志。参见 https://github.com/scala/scala/pull/8373
Configure compiler warnings.
Syntax: -Wconf:<filters>:<action>,<filters>:<action>,...
multiple <filters> are combined with &, i.e., <filter>&...&<filter>
Note: Run with `-Wconf:any:warning-verbose` to print warnings with their category, site,
and (for deprecations) origin and since-version.
<filter>
- Any message: any
- Message categories: cat=deprecation, cat=lint, cat=lint-infer-any
The full list of warning categories is shown at the end of this help text.
- Message content: msg=regex
The regex need only match some part of the message, not all of it.
- Site where the warning is triggered: site=my\.package\..*
The regex must match the full name (`package.Class.method`) of the warning position.
- Source file name: src=src_managed/.*
If `-rootdir` is specified, the regex must match the canonical path relative to the
root directory. Otherwise, the regex must match the canonical path relative to any
path segment (`b/.*Test.scala` matches `/a/b/XTest.scala` but not `/ab/Test.scala`).
Use unix-style paths, separated by `/`.
- Origin of deprecation: origin=external\.package\..*
The regex must match the full name (`package.Class.method`) of the deprecated entity.
- Since of deprecation: since<1.24
Valid operators: <, =, >, valid versions: N, N.M, N.M.P. Compares against the first
version of the form N, N.M or N.M.P found in the `since` parameter of the deprecation,
for example `1.2.3` in `@deprecated("", "some lib 1.2.3-foo")`.
<action>
- error / e
- warning / w
- warning-summary / ws (summary with the number of warnings, like for deprecations)
- warning-verbose / wv (show warning category and site)
- info / i (infos are not counted as warnings and don't affect `-Werror`)
- info-summary / is
- info-verbose / iv
- silent / s
The default configuration is:
-Wconf:cat=deprecation:ws,cat=feature:ws,cat=optimizer:ws
User-defined configurations are added to the left. The leftmost rule matching
a warning message defines the action.
Examples:
- change every warning into an error: -Wconf:any:error
- silence certain deprecations: -Wconf:origin=some\.lib\..*&since>2.2:s
Full list of message categories:
- deprecation
- feature, feature-dynamics, feature-existentials, feature-higher-kinds, feature-implicit-conversions, feature-macros, feature-postfix-ops, feature-reflective-calls
- java-source
- lint, lint-adapted-args, lint-byname-implicit, lint-constant, lint-delayedinit-select, lint-deprecation, lint-doc-detached, lint-eta-sam, lint-eta-zero, lint-implicit-not-found, lint-inaccessible, lint-infer-any, lint-missing-interpolator, lint-nonlocal-return, lint-nullary-override, lint-nullary-unit, lint-option-implicit, lint-package-object-classes, lint-poly-implicit-overload, lint-private-shadow, lint-recurse-with-default, lint-serial, lint-stars-align, lint-type-parameter-shadow, lint-unit-specialization
- optimizer
- other, other-debug, other-match-analysis, other-migration, other-pure-statement, other-shadowing
- scaladoc
- unchecked
- unused, unused-imports, unused-locals, unused-nowarn, unused-params, unused-pat-vars, unused-privates
- w-flag, w-flag-dead-code, w-flag-extra-implicit, w-flag-numeric-widen, w-flag-self-implicit, w-flag-value-discard
To suppress warnings locally, use the `scala.annotation.nowarn` annotation.
Note: on the command-line you might need to quote configurations containing `*` or `&`
to prevent the shell from expanding patterns.
对于仍然坚持早期 Scala 版本的其他人,可以使用消音器 scalac 插件:https://github.com/ghik/silencer