Skip to content

Commit 6089a75

Browse files
author
Paolo Tranquilli
committed
Rust/Ruby/Python: format code
1 parent e8799e3 commit 6089a75

File tree

11 files changed

+24
-28
lines changed

11 files changed

+24
-28
lines changed

python/extractor/tsg-python/src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77

88
use std::path::Path;
99

10-
use anyhow::anyhow;
1110
use anyhow::Context as _;
1211
use anyhow::Result;
13-
use clap::{Command, Arg, ArgAction};
12+
use anyhow::anyhow;
13+
use clap::{Arg, ArgAction, Command};
1414
use tree_sitter::Parser;
15-
use tree_sitter_graph::ast::File;
16-
use tree_sitter_graph::functions::Functions;
1715
use tree_sitter_graph::ExecutionConfig;
1816
use tree_sitter_graph::Identifier;
1917
use tree_sitter_graph::NoCancellation;
2018
use tree_sitter_graph::Variables;
19+
use tree_sitter_graph::ast::File;
20+
use tree_sitter_graph::functions::Functions;
2121

2222
const BUILD_VERSION: &'static str = env!("CARGO_PKG_VERSION");
2323

@@ -332,7 +332,7 @@ pub mod extra_functions {
332332
return Err(ExecutionError::FunctionFailed(
333333
"unnamed-child-index".into(),
334334
format!("Cannot call child-index on the root node"),
335-
))
335+
));
336336
}
337337
};
338338
let mut tree_cursor = parent.walk();
@@ -490,7 +490,7 @@ fn main() -> Result<()> {
490490
.short('t')
491491
.long("tsg")
492492
.action(ArgAction::Set)
493-
.required(false)
493+
.required(false),
494494
)
495495
.arg(Arg::new("source").index(1).required(true))
496496
.get_matches();

rust/extractor/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use anyhow::Context;
44
use clap::Parser;
55
use codeql_extractor::trap;
66
use figment::{
7+
Figment,
78
providers::{Env, Format, Serialized, Yaml},
89
value::Value,
9-
Figment,
1010
};
1111
use itertools::Itertools;
1212
use ra_ap_cfg::{CfgAtom, CfgDiff};

rust/extractor/src/config/deserialize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use serde::de::{Error, Unexpected, Visitor};
21
use serde::Deserializer;
2+
use serde::de::{Error, Unexpected, Visitor};
33
use std::collections::HashMap;
44
use std::fmt::Formatter;
55
use std::hash::BuildHasher;

rust/extractor/src/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use crate::config::Config;
22
use anyhow::Context;
33
use chrono::{DateTime, Utc};
44
use ra_ap_project_model::ProjectManifest;
5-
use serde::ser::SerializeMap;
65
use serde::Serialize;
6+
use serde::ser::SerializeMap;
77
use std::collections::HashMap;
88
use std::fmt::Display;
99
use std::fs::File;

rust/extractor/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
use crate::diagnostics::{emit_extraction_diagnostics, ExtractionStep};
1+
use crate::diagnostics::{ExtractionStep, emit_extraction_diagnostics};
22
use crate::rust_analyzer::path_to_file_id;
33
use crate::trap::TrapId;
44
use anyhow::Context;
55
use archive::Archiver;
66
use ra_ap_hir::Semantics;
7-
use ra_ap_ide_db::line_index::{LineCol, LineIndex};
87
use ra_ap_ide_db::RootDatabase;
8+
use ra_ap_ide_db::line_index::{LineCol, LineIndex};
99
use ra_ap_load_cargo::LoadCargoConfig;
1010
use ra_ap_paths::{AbsPathBuf, Utf8PathBuf};
1111
use ra_ap_project_model::{CargoConfig, ProjectManifest};

rust/extractor/src/rust_analyzer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use itertools::Itertools;
22
use ra_ap_base_db::SourceDatabase;
33
use ra_ap_hir::Semantics;
44
use ra_ap_ide_db::RootDatabase;
5-
use ra_ap_load_cargo::{load_workspace_at, LoadCargoConfig};
5+
use ra_ap_load_cargo::{LoadCargoConfig, load_workspace_at};
66
use ra_ap_paths::{AbsPath, Utf8PathBuf};
77
use ra_ap_project_model::ProjectManifest;
88
use ra_ap_project_model::{CargoConfig, ManifestPath};

rust/extractor/src/translate/base.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ use crate::rust_analyzer::FileSemanticInformation;
44
use crate::trap::{DiagnosticSeverity, TrapFile, TrapId};
55
use crate::trap::{Label, TrapClass};
66
use itertools::Either;
7-
use ra_ap_base_db::ra_salsa::InternKey;
87
use ra_ap_base_db::CrateOrigin;
8+
use ra_ap_base_db::ra_salsa::InternKey;
99
use ra_ap_hir::db::ExpandDatabase;
1010
use ra_ap_hir::{
1111
Adt, Crate, ItemContainer, Module, ModuleDef, PathResolution, Semantics, Type, Variant,
1212
};
13-
use ra_ap_hir_def::type_ref::Mutability;
1413
use ra_ap_hir_def::ModuleId;
14+
use ra_ap_hir_def::type_ref::Mutability;
1515
use ra_ap_hir_expand::ExpandTo;
16-
use ra_ap_ide_db::line_index::{LineCol, LineIndex};
1716
use ra_ap_ide_db::RootDatabase;
17+
use ra_ap_ide_db::line_index::{LineCol, LineIndex};
1818
use ra_ap_parser::SyntaxKind;
1919
use ra_ap_span::{EditionedFileId, TextSize};
2020
use ra_ap_syntax::ast::HasName;
2121
use ra_ap_syntax::{
22-
ast, AstNode, NodeOrToken, SyntaxElementChildren, SyntaxError, SyntaxNode, SyntaxToken,
23-
TextRange,
22+
AstNode, NodeOrToken, SyntaxElementChildren, SyntaxError, SyntaxNode, SyntaxToken, TextRange,
23+
ast,
2424
};
2525

2626
#[macro_export]

rust/extractor/src/translate/mappings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use ra_ap_hir::{Enum, Function, HasContainer, Module, Semantics, Struct, Trait, Union};
22
use ra_ap_ide_db::RootDatabase;
3-
use ra_ap_syntax::{ast, ast::RangeItem, AstNode};
3+
use ra_ap_syntax::{AstNode, ast, ast::RangeItem};
44

55
pub(crate) trait TextValue {
66
fn try_get_text(&self) -> Option<String>;

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ use std::collections::BTreeSet as Set;
77
use std::env;
88
use std::path::Path;
99

10+
use tracing_subscriber::EnvFilter;
11+
use tracing_subscriber::Layer;
1012
use tracing_subscriber::filter::Filtered;
1113
use tracing_subscriber::fmt::format::DefaultFields;
1214
use tracing_subscriber::fmt::format::Format;
1315
use tracing_subscriber::layer::SubscriberExt;
1416
use tracing_subscriber::util::SubscriberInitExt;
15-
use tracing_subscriber::EnvFilter;
16-
use tracing_subscriber::Layer;
1717
use tree_sitter::{Language, Node, Parser, Range, Tree};
1818

1919
pub mod simple;
@@ -591,11 +591,7 @@ impl<'a> Visitor<'a> {
591591
}
592592
}
593593
}
594-
if is_valid {
595-
Some(args)
596-
} else {
597-
None
598-
}
594+
if is_valid { Some(args) } else { None }
599595
}
600596

601597
fn type_matches(&self, tp: &TypeName, type_info: &node_types::FieldTypeInfo) -> bool {
@@ -615,7 +611,7 @@ impl<'a> Visitor<'a> {
615611
}
616612

617613
node_types::FieldTypeInfo::ReservedWordInt(int_mapping) => {
618-
return !tp.named && int_mapping.contains_key(&tp.kind)
614+
return !tp.named && int_mapping.contains_key(&tp.kind);
619615
}
620616
}
621617
false

shared/tree-sitter-extractor/tests/integration_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use codeql_extractor::trap;
44
use tree_sitter_ql;
55

66
mod common;
7-
use common::{create_source_dir, expect_trap_file, SourceArchive};
7+
use common::{SourceArchive, create_source_dir, expect_trap_file};
88

99
/// A very simple happy-path test.
1010
/// We run the extractor using the tree-sitter-ql grammar and a single source file,

0 commit comments

Comments
 (0)