Skip to content

[SPARK-59752][INFRA] dev/scalastyle: annotate style violations that report a column - #59003

Open
vrjdev wants to merge 1 commit into
apache:masterfrom
vrjdev:SPARK-59752
Open

vrjdev wants to merge 1 commit into
apache:masterfrom
vrjdev:SPARK-59752

Conversation

@vrjdev

@vrjdev vrjdev commented Sep 23, 2026 •

Copy link
Copy Markdown

What changes were proposed in this pull request?

dev/scalastyle emits inline GitHub ::error annotations for scalastyle violations reported through sbt's logger, matching lines of shape [error] <path>:<line>: <message>. The regex required whitespace immediately after :<line>:, on the assumption that the absence of a :<col>: distinguishes it from a genuine Scala compiler error of shape [error] <path>:<line>:<col>: <msg>. That assumption doesn't hold for every scalastyle checker -- the nonascii checker's sbt-logger output includes a column, e.g. [error] .../StringExpressionsSuite.scala:1065:17: nonascii.message, which matched neither regex branch and so silently got no annotation.

This PR makes the column optional in both regex branches (the native-console-writer branch already captured an optional column but discarded it) and threads it through to GitHub's ::error ...,col=<n> annotation parameter when present.

A genuine Scala compiler error can't reach this code path: project/SparkBuild.scala's enableScalaStyle/cachedScalaStyle deliberately does not attach style checking to (Compile / compile), precisely so a broken compile elsewhere can't cascade into the style job (and vice versa) -- see the comment above enableScalaStyle.

Why are the changes needed?

Without this, a scalastyle violation from a checker that reports a column (e.g. nonascii) still correctly fails the build, but gets no inline "Files changed" annotation -- exactly the problem this script's annotation logic exists to prevent (per its own comment: "Without this, a violation cascades into ~7 red CI checks... forcing the user to download a full job log to find the actual violation"). A contributor hitting this checker has to download the full job log to find the violation.

Does this PR introduce any user-facing change?

No. This only affects GitHub Actions CI annotations for dev/scalastyle, a contributor-facing tooling script; it doesn't change Spark's behavior, build output, or the pass/fail result of any check.

How was this patch tested?

  • Verified the regex against four synthetic cases (both formats, with and without a column), confirming the fix and no behavior change for the two cases that already worked.
  • End-to-end: temporarily introduced a real non-ASCII character outside an existing scalastyle:off block in StringExpressionsSuite.scala, ran dev/scalastyle with GITHUB_ACTIONS=true, confirmed the violation is now annotated with file/line/column (::error file=...,line=60,col=3,title=Scalastyle::nonascii.message) instead of being silently dropped, then reverted the temporary change.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code claude-sonnet-5

Created as I saw some lint errors across multiple PRs related to this, my PR that was affected : #58946 , it seems transient. Filing a fix anyways.

…eport a column

dev/scalastyle emits inline GitHub `::error` annotations for scalastyle
violations by matching two sbt output shapes. The sbt-logger shape,
`[error] <path>:<line>: <message>`, was matched by a regex requiring
whitespace immediately after `:<line>:`, on the assumption that the absence
of a `:<col>:` is what distinguishes it from a Scala compiler error of shape
`[error] <path>:<line>:<col>: <msg>`.

That assumption doesn't hold for every checker: the nonascii checker's
sbt-logger output includes a column, e.g.
`[error] .../StringExpressionsSuite.scala:1065:17: nonascii.message`. That
line matched neither regex, so no annotation was emitted for it -- the
violation still failed the build correctly, but a contributor had to
download the full job log to find it, the exact problem this script exists
to avoid.

Make the column optional in both regex branches (the native-console-writer
shape already had an optional column that was captured but silently
discarded) and thread it through to the new `::error ...,col=<n>` parameter
GitHub's annotation command supports when present. A genuine Scala compiler
error can't reach this code path in the first place: SparkBuild.scala's
`enableScalaStyle`/`cachedScalaStyle` deliberately does not attach style
checking to `(Compile / compile)`, precisely so a broken compile elsewhere
can't cascade into the style job (and vice versa).

Verified with a synthetic regex test covering both formats with and without
a column, and end-to-end by temporarily introducing a real non-ASCII
violation outside an existing `scalastyle:off` block and confirming
`dev/scalastyle` now annotates it with file/line/column instead of
dropping it silently (reverted before this commit).
@vrjdev

vrjdev commented Sep 24, 2026

Copy link
Copy Markdown
Author

cc: @uros-b

This branch has not been deployed

No deployments
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.

1 participant