From fa81d9da180fa424252be0c6b0870b77074f6fa6 Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Wed, 1 Feb 2023 09:47:39 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Harry Maclean --- ruby/extractor/src/diagnostics.rs | 22 +++++++++++----------- ruby/extractor/src/extractor.rs | 8 ++++---- ruby/extractor/src/main.rs | 10 +++++----- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ruby/extractor/src/diagnostics.rs b/ruby/extractor/src/diagnostics.rs index 91cc03e466b..b426f0ddc41 100644 --- a/ruby/extractor/src/diagnostics.rs +++ b/ruby/extractor/src/diagnostics.rs @@ -215,52 +215,52 @@ impl DiagnosticMessage { } } - pub fn text<'a>(&'a mut self, text: &str) -> &'a mut Self { + pub fn text(&mut self, text: &str) -> &mut Self { self.plaintext_message = text.to_owned(); self } #[allow(unused)] - pub fn markdown<'a>(&'a mut self, text: &str) -> &'a mut Self { + pub fn markdown(&mut self, text: &str) -> &mut Self { self.markdown_message = text.to_owned(); self } - pub fn severity<'a>(&'a mut self, severity: Severity) -> &'a mut Self { + pub fn severity(&mut self, severity: Severity) -> &mut Self { self.severity = Some(severity); self } #[allow(unused)] - pub fn help_link<'a>(&'a mut self, link: &str) -> &'a mut Self { + pub fn help_link(&mut self, link: &str) -> &mut Self { self.help_links.push(link.to_owned()); self } #[allow(unused)] - pub fn internal<'a>(&'a mut self) -> &'a mut Self { + pub fn internal(&mut self) -> &mut Self { self.internal = true; self } #[allow(unused)] - pub fn cli_summary_table<'a>(&'a mut self) -> &'a mut Self { + pub fn cli_summary_table(&mut self) -> &mut Self { self.visibility.cli_summary_table = true; self } - pub fn status_page<'a>(&'a mut self) -> &'a mut Self { + pub fn status_page(&mut self) -> &mut Self { self.visibility.status_page = true; self } #[allow(unused)] - pub fn telemetry<'a>(&'a mut self) -> &'a mut Self { + pub fn telemetry(&mut self) -> &mut Self { self.visibility.telemetry = true; self } - pub fn location<'a>( - &'a mut self, + pub fn location( + &mut self, path: &str, start_line: usize, start_column: usize, end_line: usize, end_column: usize, - ) -> &'a mut Self { + ) -> &mut Self { let loc = self.location.get_or_insert(Default::default()); loc.file = Some(path.to_owned()); loc.start_line = Some(start_line); diff --git a/ruby/extractor/src/extractor.rs b/ruby/extractor/src/extractor.rs index ef965057b13..ca68c1bfa1d 100644 --- a/ruby/extractor/src/extractor.rs +++ b/ruby/extractor/src/extractor.rs @@ -588,8 +588,8 @@ fn location_for(visitor: &mut Visitor, n: Node) -> (usize, usize, usize, usize) if index > 0 && index <= source.len() { index -= 1; if source[index] != b'\n' { - &visitor.diagnostics_writer.write( - &visitor + visitor.diagnostics_writer.write( + visitor .diagnostics_writer .message("internal-error", "Internal error") .text("expecting a line break symbol, but none found while correcting end column value") @@ -604,8 +604,8 @@ fn location_for(visitor: &mut Visitor, n: Node) -> (usize, usize, usize, usize) end_col += 1; } } else { - &visitor.diagnostics_writer.write( - &visitor + visitor.diagnostics_writer.write( + visitor .diagnostics_writer .message("internal-error", "Internal error") .text(&format!( diff --git a/ruby/extractor/src/main.rs b/ruby/extractor/src/main.rs index 96fa90a2b6d..60f8e107312 100644 --- a/ruby/extractor/src/main.rs +++ b/ruby/extractor/src/main.rs @@ -67,12 +67,12 @@ fn main() -> std::io::Result<()> { ) .init(); let diagnostics = diagnostics::DiagnosticLoggers::new("ruby"); - let main_thread_logger = &mut diagnostics.logger(); + let mut main_thread_logger = diagnostics.logger(); let num_threads = match num_codeql_threads() { Ok(num) => num, Err(e) => { main_thread_logger.write( - &main_thread_logger + main_thread_logger .message("configuration-error", "Configuration error") .text(&format!("{}; defaulting to 1 thread.", e)) .status_page() @@ -94,7 +94,7 @@ fn main() -> std::io::Result<()> { Ok(x) => x, Err(e) => { main_thread_logger.write( - &main_thread_logger + main_thread_logger .message("configuration-error", "Configuration error") .text(&format!("{}; using gzip.", e)) .status_page() @@ -198,7 +198,7 @@ fn main() -> std::io::Result<()> { Err(msg) => { needs_conversion = false; diagnostics_writer.write( - &diagnostics_writer + diagnostics_writer .message( "character-encoding-error", "Character encoding error", @@ -217,7 +217,7 @@ fn main() -> std::io::Result<()> { } } else { diagnostics_writer.write( - &diagnostics_writer + diagnostics_writer .message("character-encoding-error", "Character encoding error") .text(&format!( "{}: unknown character encoding: '{}'",