Skip to content

Commit f920000

Browse files
bors[bot]chitoyuu
andauthored
Merge #998
998: Random chores r=chitoyuu a=chitoyuu Performed a number of miscellaneous chores around the codebase. This PR contains a number of unrelated changes: please check the commit log for details. A list of all issues created in the process can be found in #377. Close #377. Co-authored-by: Chitose Yuuzaki <chitoyuu@potatoes.gay>
2 parents 7eafdd7 + 2cde642 commit f920000

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+297
-332
lines changed

.github/workflows/minimal-ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ env:
1212
# Don't use more features like "gdnative_bindings_generator/debug" to keep CI truly minimal
1313
GDRUST_FEATURES: "gdnative/async,gdnative/serde"
1414

15+
RIPGREP_VERSION: "13.0.0"
16+
1517
on:
1618
pull_request:
1719
branches:
@@ -52,6 +54,19 @@ jobs:
5254
- name: "Check clippy"
5355
run: cargo clippy --workspace --features ${GDRUST_FEATURES} -- -D clippy::style -D clippy::complexity -D clippy::perf -D clippy::dbg_macro -D clippy::todo -D clippy::unimplemented
5456

57+
check-todo:
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v3
61+
- name: "Install ripgrep"
62+
run: |
63+
cd /tmp
64+
wget --no-verbose https://github.com/BurntSushi/ripgrep/releases/download/${RIPGREP_VERSION}/ripgrep-${RIPGREP_VERSION}-x86_64-unknown-linux-musl.tar.gz -O ripgrep.tar.gz
65+
tar -zxvf ripgrep.tar.gz
66+
sudo mv ripgrep-${RIPGREP_VERSION}-x86_64-unknown-linux-musl/rg /usr/bin
67+
- name: "Look for TODO comments without issue numbers attached to them"
68+
run: bash tools/detect-todo.sh
69+
5570
unit-test:
5671
runs-on: ubuntu-latest
5772
steps:

bindings-generator/src/api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ mod tests {
785785
];
786786
tests.iter().for_each(|(class_name, expected)| {
787787
let actual = module_name_from_class_name(class_name);
788-
assert_eq!(*expected, actual, "Input: {}", class_name);
788+
assert_eq!(*expected, actual, "Input: {class_name}");
789789
});
790790
}
791791
}

bindings-generator/src/class_docs.rs

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,10 @@ impl GodotXmlDocs {
6767
if let Some(property_name) = node.attribute("name") {
6868
if !property_name.contains('/') {
6969
if node.has_attribute("setter") {
70-
self.add_fn(
71-
class,
72-
&format!("set_{}", property_name),
73-
desc,
74-
&[],
75-
);
70+
self.add_fn(class, &format!("set_{property_name}"), desc, &[]);
7671
}
7772
if node.has_attribute("getter") {
78-
self.add_fn(
79-
class,
80-
&format!("get_{}", property_name),
81-
desc,
82-
&[],
83-
);
73+
self.add_fn(class, &format!("get_{property_name}"), desc, &[]);
8474
}
8575
}
8676
}
@@ -187,10 +177,7 @@ impl GodotXmlDocs {
187177

188178
// Info for GDScript blocks
189179
let godot_doc = if godot_doc.contains("[codeblock]") {
190-
format!(
191-
"_Sample code is GDScript unless otherwise noted._\n\n{}",
192-
godot_doc
193-
)
180+
format!("_Sample code is GDScript unless otherwise noted._\n\n{godot_doc}")
194181
} else {
195182
godot_doc
196183
};
@@ -213,9 +200,9 @@ impl GodotXmlDocs {
213200
let text = &c[2];
214201

215202
if text.is_empty() {
216-
format!("<{url}>", url = url)
203+
format!("<{url}>")
217204
} else {
218-
format!("[{text}]({url})", text = text, url = url)
205+
format!("[{text}]({url})")
219206
}
220207
});
221208

@@ -247,11 +234,7 @@ impl GodotXmlDocs {
247234
let godot_ty = &c[2];
248235
let rust_ty = Self::translate_type(godot_ty);
249236

250-
format!(
251-
"[`{godot_ty}`][{rust_ty}]",
252-
godot_ty = godot_ty,
253-
rust_ty = rust_ty
254-
)
237+
format!("[`{godot_ty}`][{rust_ty}]")
255238
});
256239

257240
godot_doc.to_string()

bindings-generator/src/classes.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ pub(crate) fn generate_class_constants(class: &GodotClass) -> TokenStream {
9696
}
9797

9898
pub(crate) fn generate_enums(class: &GodotClass) -> TokenStream {
99-
// TODO: check whether the start of the variant name is equal to the end of the enum name and if so, don't repeat it.
100-
// For example ImageFormat::Rgb8 instead of ImageFormat::FormatRgb8.
101-
10299
let mut enums: Vec<&Enum> = class.enums.iter().collect();
103100
enums.sort();
104101
let enums = enums.iter().map(|e| {

bindings-generator/src/documentation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ fn list_base_classes(output: &mut impl Write, api: &Api, parent_name: &str) -> G
149149
if let Some(parent) = api.find_class(parent_name) {
150150
let class_link = class_doc_link(parent);
151151

152-
writeln!(output, " - {}", class_link)?;
152+
writeln!(output, " - {class_link}")?;
153153

154154
if !parent.base_class.is_empty() {
155155
list_base_classes(output, api, &parent.base_class)?;

bindings-generator/src/godot_version.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@ pub fn parse_godot_version(version_str: &str) -> Result<GodotVersion, Box<dyn Er
1515

1616
let caps = regex.captures(version_str).ok_or("Regex capture failed")?;
1717

18-
let fail = || {
19-
format!(
20-
"Version substring could not be matched in '{}'",
21-
version_str
22-
)
23-
};
18+
let fail = || format!("Version substring could not be matched in '{version_str}'");
2419

2520
Ok(GodotVersion {
2621
major: caps.get(1).ok_or_else(fail)?.as_str().parse::<u8>()?,

bindings-generator/src/methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ pub fn generate_method_table(api: &Api, class: &GodotClass) -> TokenStream {
200200
} = m.get_name();
201201

202202
let rust_ident = format_ident!("{}", rust_name);
203-
let original_name = format!("{}\0", original_name);
203+
let original_name = format!("{original_name}\0");
204204

205205
if !skip_method(m, rust_name) {
206206
assert!(original_name.ends_with('\0'), "original_name must be null terminated");

bindings-generator/src/special_methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pub fn generate_singleton_getter(class: &GodotClass) -> TokenStream {
113113
class.name.as_ref()
114114
};
115115

116-
let singleton_name = format!("{}\0", s_name);
116+
let singleton_name = format!("{s_name}\0");
117117

118118
assert!(
119119
singleton_name.ends_with('\0'),

examples/dodge-the-creeps/src/player.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ impl Player {
8282
let change = velocity * delta;
8383
let position = owner.global_position() + change;
8484
let position = Vector2::new(
85-
position.x.max(0.0).min(self.screen_size.x),
86-
position.y.max(0.0).min(self.screen_size.y),
85+
position.x.clamp(0.0, self.screen_size.x),
86+
position.y.clamp(0.0, self.screen_size.y),
8787
);
8888
owner.set_global_position(position);
8989
}

examples/scene-create/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl SceneCreate {
5959
Ok(spatial) => {
6060
// Here is how you rename the child...
6161
let key_str = format!("child_{}", self.children_spawned);
62-
spatial.set_name(&key_str);
62+
spatial.set_name(key_str);
6363

6464
let x = (self.children_spawned % 10) as f32;
6565
let z = (self.children_spawned / 10) as f32;

0 commit comments

Comments
 (0)