Base: codex-main originale (prima del fork aKode)
This commit is contained in:
9
tools/argument-comment-lint/ui/allow_char_literals.rs
Normal file
9
tools/argument-comment-lint/ui/allow_char_literals.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
#![warn(uncommented_anonymous_literal_argument)]
|
||||
|
||||
fn split_top_level(body: &str, delimiter: char) {
|
||||
let _ = (body, delimiter);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
split_top_level("a|b|c", '|');
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#![warn(argument_comment_mismatch)]
|
||||
#![warn(uncommented_anonymous_literal_argument)]
|
||||
|
||||
struct Builder;
|
||||
|
||||
impl Builder {
|
||||
fn enabled(self, enabled: bool) -> Self {
|
||||
let _ = enabled;
|
||||
self
|
||||
}
|
||||
|
||||
fn retry_count(self, retry_count: usize) -> Self {
|
||||
let _ = retry_count;
|
||||
self
|
||||
}
|
||||
|
||||
fn base_url(self, base_url: Option<String>) -> Self {
|
||||
let _ = base_url;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _ = Builder.enabled(false).retry_count(3).base_url(None);
|
||||
}
|
||||
9
tools/argument-comment-lint/ui/allow_string_literals.rs
Normal file
9
tools/argument-comment-lint/ui/allow_string_literals.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
#![warn(uncommented_anonymous_literal_argument)]
|
||||
|
||||
fn describe(prefix: &str, suffix: &str) {
|
||||
let _ = (prefix, suffix);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
describe("openai", r"https://api.openai.com/v1");
|
||||
}
|
||||
12
tools/argument-comment-lint/ui/comment_matches.rs
Normal file
12
tools/argument-comment-lint/ui/comment_matches.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
#![warn(argument_comment_mismatch)]
|
||||
|
||||
fn create_openai_url(base_url: Option<String>, retry_count: usize) -> String {
|
||||
let _ = (base_url, retry_count);
|
||||
String::new()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let base_url = Some(String::from("https://api.openai.com"));
|
||||
create_openai_url(base_url, 3);
|
||||
create_openai_url(/*base_url*/ None, 3);
|
||||
}
|
||||
17
tools/argument-comment-lint/ui/comment_matches_multiline.rs
Normal file
17
tools/argument-comment-lint/ui/comment_matches_multiline.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
#![warn(argument_comment_mismatch)]
|
||||
#![warn(uncommented_anonymous_literal_argument)]
|
||||
|
||||
fn run_git_for_stdout(repo_root: &str, args: Vec<&str>, env: Option<&str>) -> String {
|
||||
let _ = (repo_root, args, env);
|
||||
String::new()
|
||||
}
|
||||
|
||||
// Keep the call split across lines so this fixture tests multiline arguments.
|
||||
#[rustfmt::skip]
|
||||
fn main() {
|
||||
let _ = run_git_for_stdout(
|
||||
"/tmp/repo",
|
||||
vec!["rev-parse", "HEAD"],
|
||||
/*env*/ None,
|
||||
);
|
||||
}
|
||||
20
tools/argument-comment-lint/ui/comment_mismatch.rs
Normal file
20
tools/argument-comment-lint/ui/comment_mismatch.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
#![warn(argument_comment_mismatch)]
|
||||
|
||||
fn create_openai_url(base_url: Option<String>) -> String {
|
||||
let _ = base_url;
|
||||
String::new()
|
||||
}
|
||||
|
||||
struct Options;
|
||||
|
||||
impl Options {
|
||||
fn enabled(self, enabled: bool) -> Self {
|
||||
let _ = enabled;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _ = create_openai_url(/*api_base*/ None);
|
||||
let _ = Options.enabled(/*value*/ false);
|
||||
}
|
||||
23
tools/argument-comment-lint/ui/comment_mismatch.stderr
Normal file
23
tools/argument-comment-lint/ui/comment_mismatch.stderr
Normal file
@@ -0,0 +1,23 @@
|
||||
warning: argument comment `/*api_base*/` does not match parameter `base_url`
|
||||
--> $DIR/comment_mismatch.rs:18:44
|
||||
|
|
||||
LL | let _ = create_openai_url(/*api_base*/ None);
|
||||
| ^^^^
|
||||
|
|
||||
= help: use `/*base_url*/`
|
||||
note: the lint level is defined here
|
||||
--> $DIR/comment_mismatch.rs:1:9
|
||||
|
|
||||
LL | #![warn(argument_comment_mismatch)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: argument comment `/*value*/` does not match parameter `enabled`
|
||||
--> $DIR/comment_mismatch.rs:19:39
|
||||
|
|
||||
LL | let _ = Options.enabled(/*value*/ false);
|
||||
| ^^^^^
|
||||
|
|
||||
= help: use `/*enabled*/`
|
||||
|
||||
warning: 2 warnings emitted
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#![warn(uncommented_anonymous_literal_argument)]
|
||||
|
||||
fn main() {
|
||||
let line = "{\"type\":\"response_item\"}";
|
||||
let _ = line.starts_with('{');
|
||||
let _ = line.find("type");
|
||||
let parts = ["type", "response_item"];
|
||||
let _ = parts.join("\n");
|
||||
}
|
||||
14
tools/argument-comment-lint/ui/multiple_method_arguments.rs
Normal file
14
tools/argument-comment-lint/ui/multiple_method_arguments.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
#![warn(uncommented_anonymous_literal_argument)]
|
||||
|
||||
struct Options;
|
||||
|
||||
impl Options {
|
||||
fn enabled(self, enabled: bool, retry_count: usize) -> Self {
|
||||
let _ = (enabled, retry_count);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _ = Options.enabled(false, /*retry_count*/ 3);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
warning: anonymous literal-like argument for parameter `enabled`
|
||||
--> $DIR/multiple_method_arguments.rs:13:29
|
||||
|
|
||||
LL | let _ = Options.enabled(false, /*retry_count*/ 3);
|
||||
| ^^^^^ help: prepend the parameter name comment: `/*enabled*/ false`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/multiple_method_arguments.rs:1:9
|
||||
|
|
||||
LL | #![warn(uncommented_anonymous_literal_argument)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
||||
21
tools/argument-comment-lint/ui/uncommented_literal.rs
Normal file
21
tools/argument-comment-lint/ui/uncommented_literal.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
#![warn(uncommented_anonymous_literal_argument)]
|
||||
|
||||
struct Client;
|
||||
|
||||
impl Client {
|
||||
fn set_flag(&self, enabled: bool) {}
|
||||
}
|
||||
|
||||
fn create_openai_url(base_url: Option<String>, retry_count: usize) -> String {
|
||||
let _ = (base_url, retry_count);
|
||||
String::new()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let client = Client;
|
||||
let _ = create_openai_url(None, 3);
|
||||
client.set_flag(true);
|
||||
|
||||
type OptionalString = Option<String>;
|
||||
let _ = create_openai_url(OptionalString::None, /*retry_count*/ 3);
|
||||
}
|
||||
32
tools/argument-comment-lint/ui/uncommented_literal.stderr
Normal file
32
tools/argument-comment-lint/ui/uncommented_literal.stderr
Normal file
@@ -0,0 +1,32 @@
|
||||
warning: anonymous literal-like argument for parameter `base_url`
|
||||
--> $DIR/uncommented_literal.rs:16:31
|
||||
|
|
||||
LL | let _ = create_openai_url(None, 3);
|
||||
| ^^^^ help: prepend the parameter name comment: `/*base_url*/ None`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/uncommented_literal.rs:1:9
|
||||
|
|
||||
LL | #![warn(uncommented_anonymous_literal_argument)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: anonymous literal-like argument for parameter `retry_count`
|
||||
--> $DIR/uncommented_literal.rs:16:37
|
||||
|
|
||||
LL | let _ = create_openai_url(None, 3);
|
||||
| ^ help: prepend the parameter name comment: `/*retry_count*/ 3`
|
||||
|
||||
warning: anonymous literal-like argument for parameter `enabled`
|
||||
--> $DIR/uncommented_literal.rs:17:21
|
||||
|
|
||||
LL | client.set_flag(true);
|
||||
| ^^^^ help: prepend the parameter name comment: `/*enabled*/ true`
|
||||
|
||||
warning: anonymous literal-like argument for parameter `base_url`
|
||||
--> $DIR/uncommented_literal.rs:20:31
|
||||
|
|
||||
LL | let _ = create_openai_url(OptionalString::None, /*retry_count*/ 3);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: prepend the parameter name comment: `/*base_url*/ OptionalString::None`
|
||||
|
||||
warning: 4 warnings emitted
|
||||
|
||||
Reference in New Issue
Block a user