bazel-contrib / bazel-contrib/buildtools

integer-division buildifier warning triggers on floating point division

Open
#1,023 2 comments 0 reactions 0 assignees View on GitHub
bug P2
Dominant language
Go
Stars
1.2k
Forks
471
Avg merge
2d 22h
Merged PRs (30d)
13

Description

The buildifier warning for integer division seems to trigger when it finds [any binary expression that uses the `/` operator](https://github.com/bazelbuild/buildtools/blob/f2aed9ee205d62d45c55cfabbfd26342f8526862/warn/warn_operation.go#L104-L107), regardless of its operands' types. Ideally, it shouldn't do that when one of the operands is known to be a float, such as a floating point literal or something wrapped with a call to `float`.

A great reproducer for this is to run buildifier linting on a file containing the expression `x = 1.0 / 1.0`.

Contributor guide

Open the contributing guide

Research direction

Start in warn/warn_operation.go at the linked integer-division warning logic, then reproduce the report by running buildifier linting on a file containing x = 1.0 / 1.0. Done means division with a known floating-point operand, including a floating-point literal or a value wrapped with float, no longer triggers the warning while integer division behavior remains covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.