Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wconf flag for configurable warnings [ci: last-only #8372

Closed
wants to merge 31 commits into from

Conversation

lrytz
Copy link
Member

@lrytz lrytz commented Aug 26, 2019

(This PR includes the commits of #8338, I'll rebase once that is merged).

Warnings are assigned a category.

Warnings can be filtered by category, by site where they are issued, and by source path (TODO). Deprecations can additionally be filtered by origin (deprecated definition) and since version (TODO).

Filtered can be reported as error, warning, info, summary (like deprecations) or silent.

scalac -Wconf:help
Configure compiler warnings.
Syntax: -Wconf:<filter>&...&<filter>:<action>,<filter>:<action>,...

<filter>
  - any message: any
  - message categories: cat=deprecation, cat=lint, cat=lint-infer-any
  - message content: msg=regex
  - site where the warning is triggered: site=my.package.*
  - source file name: src=src_managed/*
  - origin of deprecation: origin=external.package.*
  - since of deprecation: since<*1.24

<action>
  - error / e
  - warning / w
  - warning-summary / ws
  - warning-verbose / wv (show warning category and site)
  - info / i
  - 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.

With `-Wconf:any:warning-verbose`, the compiler prints category, site, origin and since
of every warning to help writing filters.

Examples:
  - change every warning into an error: -Wconf any:error
  - ignore certain deprecations: -Wconf:cat=deprecation&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-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-serial, lint-stars-align, lint-type-parameter-shadow
 - optimizer
 - other, other-debug, other-match-analysis, other-migration, other-pure-statement, other-shadowing
 - scaladoc
 - unchecked
 - unused, unused-imports, unused-locals, unused-params, unused-pat-vars, unused-privates
 - w-flag, w-flag-dead-code, w-flag-extra-implicit, w-flag-numeric-widen, w-flag-octal-literal, w-flag-value-discard

Note: on the command-line you might need to quote configurations containing `*` or `&`
to prevent the shell from expanding it to a list of files in the current directory.

This can be handy for retaining source compatibility. Or for when you
just know better.

Fixes scala/bug#8908
ContextReporter no longer extends Reporter. The ContextReporter is
only used in the context, and it reports through Global.reporter. But
it's never assigned to Global.reporter. So better keep the two
separate. This also saves the inherited fields (ContextReporters are
allocated manies, type checking every Apply uses silent).

Remove most reporter mixins to get to a linear inheritance structure,
no more delegating reporters.

Ignore the `force` parameter of `info0`.

Some quirks to remain source compatible with the sbt compiler interface.
`nsc.reporters.Reporter` only exists for sbt compatibility, Global
has a `FilteringReporter`. `-Xreporter` must be a FilteringReporter.
Only works for deprecations, feature, optimizer and unchecked warnings
so far.

Other warningse are still issued through `reporter.warning`. Need to
rewire to use `reporting.issueWarning` and provide the necessary
metadata (warning category, warning site).

Rework summarized warnings to use these categories.

The `-deprecation` / `-feature` / `-unchecked` settings now change
`-Wconf` (e.g., add `cat=deprecation:w`).
@scala-jenkins scala-jenkins added this to the 2.13.2 milestone Aug 26, 2019
@lrytz
Copy link
Member Author

lrytz commented Aug 26, 2019

argh messed up the last only again :-(

@lrytz lrytz closed this Aug 26, 2019
@ashawley ashawley modified the milestones: 2.13.2, 2.13.1 Aug 26, 2019
@SethTisue SethTisue removed this from the 2.13.1 milestone Aug 27, 2019
@SethTisue
Copy link
Member

replaced by #8373

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants