Skip to content

Restore Track 2 Checkstyle line-length enforcement - #51520

Closed
Weidong Xu (weidongxu-microsoft) wants to merge 1 commit into
Azure:mainfrom
weidongxu-microsoft:fix/track2-checkstyle-line-length
Closed

Weidong Xu (weidongxu-microsoft) wants to merge 1 commit into
Azure:mainfrom
weidongxu-microsoft:fix/track2-checkstyle-line-length

Conversation

@weidongxu-microsoft

Copy link
Copy Markdown
Member

Fix the Track 2 Checkstyle LineLength ignore pattern. Its empty regex alternative matches every line, so the 120-character limit never runs. The corrected pattern preserves the code snippet, link, URL, and single-word comment exceptions.

Found while syncing the SDK rules in microsoft/typespec#12756. Verified with Java regex matching that overlong code is no longer ignored and the intended exceptions still match.

Rollout: Restoring enforcement may expose existing violations. A scan of azure-core alone found 292 candidate lines across 77 files before applying SDK suppressions. Assess the baseline before merging.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: caff69e4-5771-496b-b598-b533a2a45f30
Copilot AI balanced review requested due to automatic review settings December 5, 2026 04:18
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
32 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Restoring global Checkstyle enforcement without resolving existing unsuppressed violations causes the default azure-core check to fail and exposes unrelated SDK builds to inherited failures.

1 open issue
What changed in this PR

Restores the shared Track 2 Checkstyle configuration’s 120-character line-length enforcement.

Changes:

  • Removes the empty regex alternative that caused every line to be ignored.
  • Preserves exceptions for code snippets, links, URLs, and single-word comments.
File Description
eng/​lintingconfigs/​checkstyle/​track2/​checkstyle.xml Corrects and simplifies the LineLength ignore pattern.

Review effort: Balanced

<!-- Allow codeSnippet to override max line length -->
<!-- Allow comment with single word to override max line length -->
<property name="ignorePattern" value=".*(\{@codesnippet.*\}|&lt;a href)|^ *\* *[^ ]+$||http://|https://|^ *\* *[^ ]+$"/>
<property name="ignorePattern" value="\{@codesnippet.*\}|&lt;a href|^ *\* *[^ ]+$|https?://"/>
@weidongxu-microsoft

Copy link
Copy Markdown
Member Author

Closing without changing the rule. Removing the empty alternative from || exposed 38,023 distinct line-length violations in the SDK lint run. Many are reasonable to keep on one line, including generated HTTP routes, ARM resource ID templates, and Javadoc samples or schema enum lists. Narrow exceptions would help, but this isn't a safe one-line change to shared enforcement.

The extra | appeared when the URL exemptions were added in #18401. That PR didn't document disabling the check, so the original intent is unclear. The SDK has effectively operated without a 120-character limit since then. Any reintroduction should be an explicit policy decision with a baseline or phased rollout.

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