google / google/error-prone

FormatMethod: about the position of the argument: [FormatStringAnnotation] extra format arguments: used 0, provided 1

Open
#4,278 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
7.2k
Forks
820
Avg merge
5h 9m
Merged PRs (30d)
50

Description

Hi, I'm using `@FormatMethod` to format my code. Should the argument be behind the format string?

If I write as below, I will get an error.
```
@FormatMethod
public GravitinoRuntimeException(@FormatString String message, Object... args) {
super(String.format(message, args));
}

@FormatMethod
public GravitinoRuntimeException(@FormatString String message, Throwable cause, Object... args) {
super(String.format(message, args), cause);
}

new GravitinoRuntimeException("Error creating datasource", exception)
```
The error like:
```
[FormatStringAnnotation] extra format arguments: used 0, provided 1
```
Thanks.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.