Skip to content

Build: Ban Preconditions.checkState with %d placeholder#16407

Open
ebyhr wants to merge 1 commit into
apache:mainfrom
ebyhr:ebi/build-preconditions
Open

Build: Ban Preconditions.checkState with %d placeholder#16407
ebyhr wants to merge 1 commit into
apache:mainfrom
ebyhr:ebi/build-preconditions

Conversation

@ebyhr
Copy link
Copy Markdown
Member

@ebyhr ebyhr commented May 19, 2026

The guava Preconditions.checkState method only supports the %s placeholder.

This PR replaces invalid patterns and adds a new checkstyle rule similar to the existing checkArgument rule.

<module name="RegexpMultiline">
<property name="fileExtensions" value="java"/>
<property name="matchAcrossLines" value="true"/>
<property name="format" value="Preconditions\.checkArgument\([^;]+%d[^;]+\);"/>
<property name="message" value="Preconditions.checkArgument does not support %d. use %s instead"/>
</module>

@ebyhr ebyhr force-pushed the ebi/build-preconditions branch from 93c69f3 to 6c0060a Compare May 19, 2026 00:59
static Schema schema(Types.StructType unifiedPartitionType, int formatVersion) {
Preconditions.checkState(!unifiedPartitionType.fields().isEmpty(), "Table must be partitioned");
Preconditions.checkState(formatVersion > 0, "Invalid format version: %d", formatVersion);
Preconditions.checkState(formatVersion > 0, "Invalid format version: %s", formatVersion);
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.

how did the error msg look like before this fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants