Apply suggestions from code review

Co-authored-by: Harry Maclean <hmac@github.com>
This commit is contained in:
Arthur Baars
2023-02-01 09:47:39 +01:00
committed by GitHub
parent 57012714d6
commit fa81d9da18
3 changed files with 20 additions and 20 deletions

View File

@@ -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.plaintext_message = text.to_owned();
self self
} }
#[allow(unused)] #[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.markdown_message = text.to_owned();
self 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.severity = Some(severity);
self self
} }
#[allow(unused)] #[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.help_links.push(link.to_owned());
self self
} }
#[allow(unused)] #[allow(unused)]
pub fn internal<'a>(&'a mut self) -> &'a mut Self { pub fn internal(&mut self) -> &mut Self {
self.internal = true; self.internal = true;
self self
} }
#[allow(unused)] #[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.visibility.cli_summary_table = true;
self 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.visibility.status_page = true;
self self
} }
#[allow(unused)] #[allow(unused)]
pub fn telemetry<'a>(&'a mut self) -> &'a mut Self { pub fn telemetry(&mut self) -> &mut Self {
self.visibility.telemetry = true; self.visibility.telemetry = true;
self self
} }
pub fn location<'a>( pub fn location(
&'a mut self, &mut self,
path: &str, path: &str,
start_line: usize, start_line: usize,
start_column: usize, start_column: usize,
end_line: usize, end_line: usize,
end_column: usize, end_column: usize,
) -> &'a mut Self { ) -> &mut Self {
let loc = self.location.get_or_insert(Default::default()); let loc = self.location.get_or_insert(Default::default());
loc.file = Some(path.to_owned()); loc.file = Some(path.to_owned());
loc.start_line = Some(start_line); loc.start_line = Some(start_line);

View File

@@ -588,8 +588,8 @@ fn location_for(visitor: &mut Visitor, n: Node) -> (usize, usize, usize, usize)
if index > 0 && index <= source.len() { if index > 0 && index <= source.len() {
index -= 1; index -= 1;
if source[index] != b'\n' { if source[index] != b'\n' {
&visitor.diagnostics_writer.write( visitor.diagnostics_writer.write(
&visitor visitor
.diagnostics_writer .diagnostics_writer
.message("internal-error", "Internal error") .message("internal-error", "Internal error")
.text("expecting a line break symbol, but none found while correcting end column value") .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; end_col += 1;
} }
} else { } else {
&visitor.diagnostics_writer.write( visitor.diagnostics_writer.write(
&visitor visitor
.diagnostics_writer .diagnostics_writer
.message("internal-error", "Internal error") .message("internal-error", "Internal error")
.text(&format!( .text(&format!(

View File

@@ -67,12 +67,12 @@ fn main() -> std::io::Result<()> {
) )
.init(); .init();
let diagnostics = diagnostics::DiagnosticLoggers::new("ruby"); 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() { let num_threads = match num_codeql_threads() {
Ok(num) => num, Ok(num) => num,
Err(e) => { Err(e) => {
main_thread_logger.write( main_thread_logger.write(
&main_thread_logger main_thread_logger
.message("configuration-error", "Configuration error") .message("configuration-error", "Configuration error")
.text(&format!("{}; defaulting to 1 thread.", e)) .text(&format!("{}; defaulting to 1 thread.", e))
.status_page() .status_page()
@@ -94,7 +94,7 @@ fn main() -> std::io::Result<()> {
Ok(x) => x, Ok(x) => x,
Err(e) => { Err(e) => {
main_thread_logger.write( main_thread_logger.write(
&main_thread_logger main_thread_logger
.message("configuration-error", "Configuration error") .message("configuration-error", "Configuration error")
.text(&format!("{}; using gzip.", e)) .text(&format!("{}; using gzip.", e))
.status_page() .status_page()
@@ -198,7 +198,7 @@ fn main() -> std::io::Result<()> {
Err(msg) => { Err(msg) => {
needs_conversion = false; needs_conversion = false;
diagnostics_writer.write( diagnostics_writer.write(
&diagnostics_writer diagnostics_writer
.message( .message(
"character-encoding-error", "character-encoding-error",
"Character encoding error", "Character encoding error",
@@ -217,7 +217,7 @@ fn main() -> std::io::Result<()> {
} }
} else { } else {
diagnostics_writer.write( diagnostics_writer.write(
&diagnostics_writer diagnostics_writer
.message("character-encoding-error", "Character encoding error") .message("character-encoding-error", "Character encoding error")
.text(&format!( .text(&format!(
"{}: unknown character encoding: '{}'", "{}: unknown character encoding: '{}'",