Skip to content

Commit

Permalink
fixed clippy reports
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianHi committed Nov 29, 2024
1 parent fdfc9e8 commit 5fedbd7
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions monitor/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ fn main() {
);
// Overwrite folders
println!("{}", config.dest_path_generation);
fs::create_dir_all(&format!("{}/", config.dest_path_generation)).unwrap();
fs::create_dir_all(&format!("{}/input/", config.dest_path_generation)).unwrap();
fs::create_dir_all(&format!("{}/output/", config.dest_path_generation)).unwrap();
fs::create_dir_all(format!("{}/", config.dest_path_generation)).unwrap();
fs::create_dir_all(format!("{}/input/", config.dest_path_generation)).unwrap();
fs::create_dir_all(format!("{}/output/", config.dest_path_generation)).unwrap();

// Inputs
let subscribable_topics: Vec<(String, String)> = ros2_reader.get_subscribable_topics();
Expand Down
4 changes: 2 additions & 2 deletions monitor/build_src/fn_generator/generate_inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl RustFileGenerator {
let (name_datatype, name_package, members_type_and_name) =
Ros2Reader::read_interface_msg(
&self.ros2_reader.get_location_setup_script().to_string(),
&msg_name,
msg_name,
);
// Fills vector of topics that is also used in other file generation calls
self.generated_topics.push((
Expand Down Expand Up @@ -57,7 +57,7 @@ impl RustFileGenerator {
let name = if name == "type" { "type_" } else { name };
let ty_transformed = RustFileGenerator::transform_type_ros2rust(ty);
let access: String = if *i < 0 {
format!("{name}")
name.to_string()
} else {
let r = Regex::new(r"__\d").unwrap();
let m = r.find(name).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion monitor/build_src/fn_generator/generate_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl RustFileGenerator {
// Create file content
let mut pub_mods_content = String::new();
for (topic_name, _) in topics {
let parts: Vec<&str> = topic_name.split("/").collect();
let parts: Vec<&str> = topic_name.split('/').collect();
let topic_name = parts.last().unwrap().to_lowercase();
pub_mods_content.push_str(&format!("\t\tpub mod {topic_name};\n"));
}
Expand Down
2 changes: 1 addition & 1 deletion monitor/build_src/fn_generator/generate_outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl RustFileGenerator {
) {
match rtlolaout_topic {
Some((rtlola_package, members_type_and_name)) => {
let rtlola_package = rtlola_package.replace("/", "::");
let rtlola_package = rtlola_package.replace('/', "::");
// File that is generated
let file_location = format!("{}/output/rtlolaout_publisher.rs", self.dest_path);
let file = File::create(&file_location).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion monitor/build_src/fn_generator/generate_ros2_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl RustFileGenerator {
let mut select_statement = String::new();
// Build statements
for (topic, _) in topics {
let parts: Vec<&str> = topic.split("/").collect();
let parts: Vec<&str> = topic.split('/').collect();
let topic_name = parts.last().unwrap();
rtlola_enum.push_str(&format!(
"{}::RTLola{topic_name},",
Expand Down
4 changes: 2 additions & 2 deletions monitor/build_src/fn_generator/generate_rtloladata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl RustFileGenerator {
let mut includes = String::new();
// Build statements
for (topic, _) in topics {
let parts: Vec<&str> = topic.split("/").collect();
let parts: Vec<&str> = topic.split('/').collect();
let topic_name = parts.last().unwrap();
members.push_str(&format!("{topic_name} (RTLola{topic_name}),"));
includes.push_str(&format!(
Expand All @@ -41,6 +41,6 @@ impl RustFileGenerator {
// Write input source codeto file
writeln!(&file, "{}", file_content).unwrap();
// Format generated file
RustFileGenerator::cargo_fmt_file(&file_location.to_str().unwrap());
RustFileGenerator::cargo_fmt_file(file_location.to_str().unwrap());
}
}
2 changes: 1 addition & 1 deletion monitor/build_src/ros2_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl Ros2Reader {
pub fn get_subscribable_topics(&self) -> Vec<(String, String)> {
// Receive a list of topcs
let res = Command::new("ros2")
.args(&["topic", "list", "-t"])
.args(["topic", "list", "-t"])
.output()
.expect("Failed to execute process");
let tmp = String::from_utf8_lossy(&res.stdout).to_string();
Expand Down
4 changes: 2 additions & 2 deletions monitor/build_src/rust_file_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ impl RustFileGenerator {
pub fn new(ros2_reader: Ros2Reader, dest_path: String) -> Self {
Self {
ros2_reader,
dest_path: dest_path,
dest_path,
generated_topics: Vec::<(String, String, String)>::new(),
}
}

pub fn cargo_fmt_file(file_path: &str) {
Command::new("rustfmt")
.args(&[file_path])
.args([file_path])
.output()
.expect("Failed to execute process");
}
Expand Down

0 comments on commit 5fedbd7

Please sign in to comment.