Skip to content

Commit 911d6f0

Browse files
committed
Shared tree-sitter extractor: run clippy
1 parent 45c0c46 commit 911d6f0

File tree

9 files changed

+59
-59
lines changed

9 files changed

+59
-59
lines changed

shared/tree-sitter-extractor/src/autobuilder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,23 @@ impl Autobuilder {
5757
let verbosity = env::var("CODEQL_VERBOSITY");
5858

5959
if let Ok(verbosity) = verbosity {
60-
cmd.arg(format!("--verbosity={}", verbosity));
60+
cmd.arg(format!("--verbosity={verbosity}"));
6161
}
6262

6363
for ext in &self.include_extensions {
64-
cmd.arg(format!("--include-extension={}", ext));
64+
cmd.arg(format!("--include-extension={ext}"));
6565
}
6666

6767
for glob in &self.include_globs {
68-
cmd.arg(format!("--include={}", glob));
68+
cmd.arg(format!("--include={glob}"));
6969
}
7070

7171
for glob in &self.exclude_globs {
72-
cmd.arg(format!("--exclude={}", glob));
72+
cmd.arg(format!("--exclude={glob}"));
7373
}
7474

7575
if let Some(limit) = &self.size_limit {
76-
cmd.arg(format!("--size-limit={}", limit));
76+
cmd.arg(format!("--size-limit={limit}"));
7777
}
7878

7979
cmd.arg(format!("--language={}", &self.language));

shared/tree-sitter-extractor/src/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl DiagnosticLoggers {
194194
path: self
195195
.root
196196
.as_ref()
197-
.map(|root| root.to_owned().join(format!("extractor_{}.jsonl", n))),
197+
.map(|root| root.to_owned().join(format!("extractor_{n}.jsonl"))),
198198
})
199199
}
200200
}

shared/tree-sitter-extractor/src/extractor/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ pub fn extract(
230230
parser.set_language(language).unwrap();
231231
parser.set_included_ranges(ranges).unwrap();
232232
let tree = parser.parse(source, None).expect("Failed to parse file");
233-
trap_writer.comment(format!("Auto-generated TRAP file for {}", path_str));
233+
trap_writer.comment(format!("Auto-generated TRAP file for {path_str}"));
234234
let file_label = populate_file(trap_writer, path, transformer);
235235
let mut visitor = Visitor::new(
236236
source,
@@ -298,9 +298,9 @@ impl<'a> Visitor<'a> {
298298
source,
299299
diagnostics_writer,
300300
trap_writer,
301-
ast_node_location_table_name: format!("{}_ast_node_location", language_prefix),
302-
ast_node_parent_table_name: format!("{}_ast_node_parent", language_prefix),
303-
tokeninfo_table_name: format!("{}_tokeninfo", language_prefix),
301+
ast_node_location_table_name: format!("{language_prefix}_ast_node_location"),
302+
ast_node_parent_table_name: format!("{language_prefix}_ast_node_parent"),
303+
tokeninfo_table_name: format!("{language_prefix}_tokeninfo"),
304304
schema,
305305
stack: Vec::new(),
306306
}

shared/tree-sitter-extractor/src/extractor/simple.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl Extractor {
8080
.iter()
8181
.map(|file_list| {
8282
File::open(file_list)
83-
.unwrap_or_else(|_| panic!("Unable to open file list at {:?}", file_list))
83+
.unwrap_or_else(|_| panic!("Unable to open file list at {file_list:?}"))
8484
})
8585
.collect();
8686

shared/tree-sitter-extractor/src/generator/dbscheme.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl fmt::Display for Case<'_> {
5353
writeln!(f, "case @{}.{} of", &self.name, &self.column)?;
5454
let mut sep = " ";
5555
for (c, tp) in &self.branches {
56-
writeln!(f, "{} {} = @{}", sep, c, tp)?;
56+
writeln!(f, "{sep} {c} = @{tp}")?;
5757
sep = "|";
5858
}
5959
writeln!(f, ";")
@@ -68,7 +68,7 @@ impl fmt::Display for Table<'_> {
6868
if key_index > 0 {
6969
write!(f, ", ")?;
7070
}
71-
write!(f, "{}", key)?;
71+
write!(f, "{key}")?;
7272
}
7373
writeln!(f, "]")?;
7474
}
@@ -112,7 +112,7 @@ impl fmt::Display for Union<'_> {
112112
} else {
113113
write!(f, " | ")?;
114114
}
115-
write!(f, "@{}", member)?;
115+
write!(f, "@{member}")?;
116116
}
117117
Ok(())
118118
}
@@ -122,9 +122,9 @@ impl fmt::Display for Union<'_> {
122122
pub fn write(file: &mut dyn std::io::Write, entries: &[Entry]) -> std::io::Result<()> {
123123
for entry in entries {
124124
match entry {
125-
Entry::Case(case) => write!(file, "{}\n\n", case)?,
126-
Entry::Table(table) => write!(file, "{}\n\n", table)?,
127-
Entry::Union(union) => write!(file, "{}\n\n", union)?,
125+
Entry::Case(case) => write!(file, "{case}\n\n")?,
126+
Entry::Table(table) => write!(file, "{table}\n\n")?,
127+
Entry::Union(union) => write!(file, "{union}\n\n")?,
128128
}
129129
}
130130

shared/tree-sitter-extractor/src/generator/ql.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ pub enum TopLevel<'a> {
1212
impl fmt::Display for TopLevel<'_> {
1313
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1414
match self {
15-
TopLevel::Import(imp) => write!(f, "{}", imp),
16-
TopLevel::Class(cls) => write!(f, "{}", cls),
17-
TopLevel::Module(m) => write!(f, "{}", m),
18-
TopLevel::Predicate(pred) => write!(f, "{}", pred),
15+
TopLevel::Import(imp) => write!(f, "{imp}"),
16+
TopLevel::Class(cls) => write!(f, "{cls}"),
17+
TopLevel::Module(m) => write!(f, "{m}"),
18+
TopLevel::Predicate(pred) => write!(f, "{pred}"),
1919
}
2020
}
2121
}
@@ -30,7 +30,7 @@ impl fmt::Display for Import<'_> {
3030
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3131
write!(f, "import {}", &self.module)?;
3232
if let Some(name) = &self.alias {
33-
write!(f, " as {}", name)?;
33+
write!(f, " as {name}")?;
3434
}
3535
Ok(())
3636
}
@@ -48,7 +48,7 @@ pub struct Class<'a> {
4848
impl fmt::Display for Class<'_> {
4949
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
5050
if let Some(qldoc) = &self.qldoc {
51-
write!(f, "/** {} */", qldoc)?;
51+
write!(f, "/** {qldoc} */")?;
5252
}
5353
if self.is_abstract {
5454
write!(f, "abstract ")?;
@@ -58,7 +58,7 @@ impl fmt::Display for Class<'_> {
5858
if index > 0 {
5959
write!(f, ", ")?;
6060
}
61-
write!(f, "{}", supertype)?;
61+
write!(f, "{supertype}")?;
6262
}
6363
writeln!(f, " {{ ")?;
6464

@@ -81,7 +81,7 @@ impl fmt::Display for Class<'_> {
8181
}
8282

8383
for predicate in &self.predicates {
84-
writeln!(f, " {}", predicate)?;
84+
writeln!(f, " {predicate}")?;
8585
}
8686

8787
write!(f, "}}")?;
@@ -101,7 +101,7 @@ pub struct Module<'a> {
101101
impl fmt::Display for Module<'_> {
102102
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
103103
if let Some(qldoc) = &self.qldoc {
104-
write!(f, "/** {} */", qldoc)?;
104+
write!(f, "/** {qldoc} */")?;
105105
}
106106
if let Some(overlay_annotation) = &self.overlay {
107107
write!(f, "overlay[")?;
@@ -113,7 +113,7 @@ impl fmt::Display for Module<'_> {
113113
}
114114
writeln!(f, "module {} {{ ", self.name)?;
115115
for decl in &self.body {
116-
writeln!(f, " {}", decl)?;
116+
writeln!(f, " {decl}")?;
117117
}
118118
write!(f, "}}")?;
119119
Ok(())
@@ -140,8 +140,8 @@ impl fmt::Display for Type<'_> {
140140
match self {
141141
Type::Int => write!(f, "int"),
142142
Type::String => write!(f, "string"),
143-
Type::Normal(name) => write!(f, "{}", name),
144-
Type::At(name) => write!(f, "@{}", name),
143+
Type::Normal(name) => write!(f, "{name}"),
144+
Type::At(name) => write!(f, "@{name}"),
145145
}
146146
}
147147
}
@@ -169,16 +169,16 @@ pub enum Expression<'a> {
169169
impl fmt::Display for Expression<'_> {
170170
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
171171
match self {
172-
Expression::Var(x) => write!(f, "{}", x),
173-
Expression::String(s) => write!(f, "\"{}\"", s),
174-
Expression::Integer(n) => write!(f, "{}", n),
172+
Expression::Var(x) => write!(f, "{x}"),
173+
Expression::String(s) => write!(f, "\"{s}\""),
174+
Expression::Integer(n) => write!(f, "{n}"),
175175
Expression::Pred(n, args) => {
176-
write!(f, "{}(", n)?;
176+
write!(f, "{n}(")?;
177177
for (index, arg) in args.iter().enumerate() {
178178
if index > 0 {
179179
write!(f, ", ")?;
180180
}
181-
write!(f, "{}", arg)?;
181+
write!(f, "{arg}")?;
182182
}
183183
write!(f, ")")
184184
}
@@ -190,7 +190,7 @@ impl fmt::Display for Expression<'_> {
190190
if index > 0 {
191191
write!(f, " and ")?;
192192
}
193-
write!(f, "({})", conjunct)?;
193+
write!(f, "({conjunct})")?;
194194
}
195195
Ok(())
196196
}
@@ -203,19 +203,19 @@ impl fmt::Display for Expression<'_> {
203203
if index > 0 {
204204
write!(f, " or ")?;
205205
}
206-
write!(f, "({})", disjunct)?;
206+
write!(f, "({disjunct})")?;
207207
}
208208
Ok(())
209209
}
210210
}
211-
Expression::Equals(a, b) => write!(f, "{} = {}", a, b),
211+
Expression::Equals(a, b) => write!(f, "{a} = {b}"),
212212
Expression::Dot(x, member_pred, args) => {
213-
write!(f, "{}.{}(", x, member_pred)?;
213+
write!(f, "{x}.{member_pred}(")?;
214214
for (index, arg) in args.iter().enumerate() {
215215
if index > 0 {
216216
write!(f, ", ")?;
217217
}
218-
write!(f, "{}", arg)?;
218+
write!(f, "{arg}")?;
219219
}
220220
write!(f, ")")
221221
}
@@ -226,26 +226,26 @@ impl fmt::Display for Expression<'_> {
226226
expr,
227227
second_expr,
228228
} => {
229-
write!(f, "{}(", name)?;
229+
write!(f, "{name}(")?;
230230
if !vars.is_empty() {
231231
for (index, var) in vars.iter().enumerate() {
232232
if index > 0 {
233233
write!(f, ", ")?;
234234
}
235-
write!(f, "{}", var)?;
235+
write!(f, "{var}")?;
236236
}
237237
write!(f, " | ")?;
238238
}
239239
if let Some(range) = range {
240-
write!(f, "{} | ", range)?;
240+
write!(f, "{range} | ")?;
241241
}
242-
write!(f, "{}", expr)?;
242+
write!(f, "{expr}")?;
243243
if let Some(second_expr) = second_expr {
244-
write!(f, ", {}", second_expr)?;
244+
write!(f, ", {second_expr}")?;
245245
}
246246
write!(f, ")")
247247
}
248-
Expression::Negation(e) => write!(f, "not ({})", e),
248+
Expression::Negation(e) => write!(f, "not ({e})"),
249249
}
250250
}
251251
}
@@ -272,7 +272,7 @@ pub struct Predicate<'a> {
272272
impl fmt::Display for Predicate<'_> {
273273
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
274274
if let Some(qldoc) = &self.qldoc {
275-
write!(f, "/** {} */", qldoc)?;
275+
write!(f, "/** {qldoc} */")?;
276276
}
277277
if let Some(overlay_annotation) = &self.overlay {
278278
write!(f, "overlay[")?;
@@ -293,14 +293,14 @@ impl fmt::Display for Predicate<'_> {
293293
}
294294
match &self.return_type {
295295
None => write!(f, "predicate ")?,
296-
Some(return_type) => write!(f, "{} ", return_type)?,
296+
Some(return_type) => write!(f, "{return_type} ")?,
297297
}
298298
write!(f, "{}(", self.name)?;
299299
for (index, param) in self.formal_parameters.iter().enumerate() {
300300
if index > 0 {
301301
write!(f, ", ")?;
302302
}
303-
write!(f, "{}", param)?;
303+
write!(f, "{param}")?;
304304
}
305305
write!(f, ") {{ {} }}", self.body)?;
306306

shared/tree-sitter-extractor/src/generator/ql_gen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ fn create_field_getters<'a>(
666666
}
667667
};
668668
let qldoc = match &field.name {
669-
Some(name) => format!("Gets the node corresponding to the field `{}`.", name),
669+
Some(name) => format!("Gets the node corresponding to the field `{name}`."),
670670
None => {
671671
if formal_parameters.is_empty() {
672672
"Gets the child of this node.".to_owned()

shared/tree-sitter-extractor/src/node_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ fn node_type_name(kind: &str, named: bool) -> String {
326326
if named {
327327
kind.to_string()
328328
} else {
329-
format!("{}_unnamed", kind)
329+
format!("{kind}_unnamed")
330330
}
331331
}
332332

shared/tree-sitter-extractor/src/trap.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl Writer {
112112

113113
fn write_trap_entries<W: Write>(&self, file: &mut W) -> std::io::Result<()> {
114114
for trap_entry in &self.trap_output {
115-
writeln!(file, "{}", trap_entry)?;
115+
writeln!(file, "{trap_entry}")?;
116116
}
117117
Ok(())
118118
}
@@ -131,21 +131,21 @@ pub enum Entry {
131131
impl fmt::Display for Entry {
132132
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
133133
match self {
134-
Entry::FreshId(label) => write!(f, "{}=*", label),
134+
Entry::FreshId(label) => write!(f, "{label}=*"),
135135
Entry::MapLabelToKey(label, key) => {
136136
write!(f, "{}=@\"{}\"", label, key.replace('"', "\"\""))
137137
}
138138
Entry::GenericTuple(name, args) => {
139-
write!(f, "{}(", name)?;
139+
write!(f, "{name}(")?;
140140
for (index, arg) in args.iter().enumerate() {
141141
if index > 0 {
142142
write!(f, ",")?;
143143
}
144-
write!(f, "{}", arg)?;
144+
write!(f, "{arg}")?;
145145
}
146146
write!(f, ")")
147147
}
148-
Entry::Comment(line) => write!(f, "// {}", line),
148+
Entry::Comment(line) => write!(f, "// {line}"),
149149
}
150150
}
151151
}
@@ -179,8 +179,8 @@ const MAX_STRLEN: usize = 1048576;
179179
impl fmt::Display for Arg {
180180
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
181181
match self {
182-
Arg::Label(x) => write!(f, "{}", x),
183-
Arg::Int(x) => write!(f, "{}", x),
182+
Arg::Label(x) => write!(f, "{x}"),
183+
Arg::Int(x) => write!(f, "{x}"),
184184
Arg::String(x) => write!(
185185
f,
186186
"\"{}\"",
@@ -220,9 +220,9 @@ impl fmt::Display for Program {
220220
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
221221
let mut text = String::new();
222222
for trap_entry in &self.0 {
223-
text.push_str(&format!("{}\n", trap_entry));
223+
text.push_str(&format!("{trap_entry}\n"));
224224
}
225-
write!(f, "{}", text)
225+
write!(f, "{text}")
226226
}
227227
}
228228

0 commit comments

Comments
 (0)