Skip to content

build: enable -Xfatal-warnings for Scala 2 and -Werror for Scala 3#1109

Merged
He-Pin merged 6 commits into
apache:mainfrom
He-Pin:build/enable-fatal-warnings
Jun 29, 2026
Merged

build: enable -Xfatal-warnings for Scala 2 and -Werror for Scala 3#1109
He-Pin merged 6 commits into
apache:mainfrom
He-Pin:build/enable-fatal-warnings

Conversation

@He-Pin

@He-Pin He-Pin commented Jun 28, 2026

Copy link
Copy Markdown
Member

Motivation

Treating warnings as errors ensures that deprecated API usage and other code quality issues are caught at compile time rather than accumulating silently.

Modification

  • Add -Xfatal-warnings to Scala 2 scalacOptions in Common.scala
  • Add -Werror to Scala 3 scalacOptions
  • Remove -Wconf:cat=deprecation:s for Scala 3 so deprecation warnings are no longer silenced
  • Exclude -Xfatal-warnings from Compile / doc scope to avoid doc generation failures

Result

All compiler warnings are now treated as errors, enforcing higher code quality and catching deprecated API usage at compile time.

Tests

  • CI will verify compilation

References

None — build configuration improvement

He-Pin added 2 commits June 29, 2026 06:15
Motivation:
Treating warnings as errors ensures that deprecated API usage and other
code quality issues are caught at compile time rather than accumulating.

Modification:
Add -Xfatal-warnings to Scala 2 scalacOptions and -Werror to Scala 3
scalacOptions in Common.scala. Remove -Wconf:cat=deprecation:s for
Scala 3 so deprecation warnings are not silenced. Exclude
-Xfatal-warnings from Compile / doc scope to avoid doc generation
failures.

Result:
All compiler warnings are now treated as errors, enforcing higher code
quality.

Tests:
- CI will verify compilation

References:
None - build configuration improvement
Remove unused classTag import in HttpMessage.scala.
Add -Wconf suppressions for structural type warning (Scala 2),
synchronized warning and override-deprecated warning (Scala 3).
@He-Pin He-Pin force-pushed the build/enable-fatal-warnings branch from 73cde27 to dfc8a09 Compare June 28, 2026 22:21
He-Pin added 4 commits June 29, 2026 07:09
- Remove unused imports (classTag, postfixOps, implicitConversions, Failure/Success/Try)
- Add -language:implicitConversions as compiler option
- Remove unused expectError method from ConnectionPoolSettingsSpec
- Add -Wconf suppressions for: structural types, shadowed names,
  parameterless method confusion, Unit-valued patterns, infer-Any,
  overloaded implicit conversions, getClass selection, deprecation,
  refutable extractors, type specialization, type erasure,
  unreachable cases, exhaustivity, and suspicious top-level calls
…essions

Move -Xfatal-warnings in docs module to Scala 2 only to avoid duplicate
-Werror flag in Scala 3. Add suppressions for unused import and dead-code
warnings in test modules.
The scala.meta compiler plugin used by scalafix generates warnings
(InlineInfoAttribute) that cannot be suppressed via -Wconf. Exclude
-Xfatal-warnings and -Werror from this module's scalacOptions.

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@He-Pin He-Pin merged commit 82a03b1 into apache:main Jun 29, 2026
5 checks passed
@He-Pin He-Pin deleted the build/enable-fatal-warnings branch June 29, 2026 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants