Address review comments

This commit is contained in:
Arthur Baars
2023-02-28 13:27:56 +01:00
parent 6c57823232
commit 2c611d3fef
3 changed files with 15 additions and 14 deletions

View File

@@ -306,7 +306,7 @@ impl<'a> Visitor<'a> {
fn enter_node(&mut self, node: Node) -> bool { fn enter_node(&mut self, node: Node) -> bool {
if node.is_missing() { if node.is_missing() {
self.record_parse_error_for_node( self.record_parse_error_for_node(
"A parse error occurred, expecting {} symbol. Check the syntax of the file using the {} command. If the file is indeed invalid, please correct the error or exclude the file from analysis.", "A parse error occurred (expected {} symbol). Check the syntax of the file using the {} command. If the file is invalid, correct the error or exclude the file from analysis.",
&[node.kind(), "ruby -c"], &[node.kind(), "ruby -c"],
node, node,
true, true,
@@ -315,7 +315,7 @@ impl<'a> Visitor<'a> {
} }
if node.is_error() { if node.is_error() {
self.record_parse_error_for_node( self.record_parse_error_for_node(
"A parse error occurred. Check the syntax of the file using the {} command. If the file is indeed invalid, please correct the error or exclude the file from analysis.", "A parse error occurred. Check the syntax of the file using the {} command. If the file is invalid, correct the error or exclude the file from analysis.",
&["ruby -c"], &["ruby -c"],
node, node,
true, true,
@@ -407,7 +407,7 @@ impl<'a> Visitor<'a> {
.new_entry("parse-error", "Parse error") .new_entry("parse-error", "Parse error")
.severity(diagnostics::Severity::Error) .severity(diagnostics::Severity::Error)
.location(self.path, start_line, start_column, end_line, end_column) .location(self.path, start_line, start_column, end_line, end_column)
.message("unknown table type: {}", &[node.kind()]), .message("Unknown table type: {}", &[node.kind()]),
); );
valid = false; valid = false;
@@ -456,7 +456,7 @@ impl<'a> Visitor<'a> {
} }
} else if field.name.is_some() { } else if field.name.is_some() {
self.record_parse_error_for_node( self.record_parse_error_for_node(
"type mismatch for field {}::{} with type {} != {}", "Type mismatch for field {}::{} with type {} != {}",
&[ &[
node.kind(), node.kind(),
child_node.field_name.unwrap_or("child"), child_node.field_name.unwrap_or("child"),
@@ -469,7 +469,7 @@ impl<'a> Visitor<'a> {
} }
} else if child_node.field_name.is_some() || child_node.type_name.named { } else if child_node.field_name.is_some() || child_node.type_name.named {
self.record_parse_error_for_node( self.record_parse_error_for_node(
"value for unknown field: {}::{} and type {}", "Value for unknown field: {}::{} and type {}",
&[ &[
node.kind(), node.kind(),
&child_node.field_name.unwrap_or("child"), &child_node.field_name.unwrap_or("child"),
@@ -493,9 +493,9 @@ impl<'a> Visitor<'a> {
let error_message = format!( let error_message = format!(
"{} for field: {}::{}", "{} for field: {}::{}",
if child_values.is_empty() { if child_values.is_empty() {
"missing value" "Missing value"
} else { } else {
"too many values" "Too many values"
}, },
node.kind(), node.kind(),
column_name column_name
@@ -511,7 +511,7 @@ impl<'a> Visitor<'a> {
for (index, child_value) in child_values.iter().enumerate() { for (index, child_value) in child_values.iter().enumerate() {
if !*has_index && index > 0 { if !*has_index && index > 0 {
self.record_parse_error_for_node( self.record_parse_error_for_node(
"too many values for field: {}::{}", "Too many values for field: {}::{}",
&[node.kind(), table_name], &[node.kind(), table_name],
*node, *node,
false, false,
@@ -613,7 +613,7 @@ fn location_for(visitor: &mut Visitor, n: Node) -> (usize, usize, usize, usize)
visitor visitor
.diagnostics_writer .diagnostics_writer
.new_entry("internal-error", "Internal error") .new_entry("internal-error", "Internal error")
.message("expecting a line break symbol, but none found while correcting end column value", &[]) .message("Expecting a line break symbol, but none found while correcting end column value", &[])
.severity(diagnostics::Severity::Error), .severity(diagnostics::Severity::Error),
); );
} }
@@ -629,7 +629,7 @@ fn location_for(visitor: &mut Visitor, n: Node) -> (usize, usize, usize, usize)
.diagnostics_writer .diagnostics_writer
.new_entry("internal-error", "Internal error") .new_entry("internal-error", "Internal error")
.message( .message(
"cannot correct end column value: end_byte index {} is not in range [1,{}]", "Cannot correct end column value: end_byte index {} is not in range [1,{}]",
&[&index.to_string(), &source.len().to_string()], &[&index.to_string(), &source.len().to_string()],
) )
.severity(diagnostics::Severity::Error), .severity(diagnostics::Severity::Error),

View File

@@ -203,10 +203,11 @@ fn main() -> std::io::Result<()> {
) )
.file(&path.to_string_lossy()) .file(&path.to_string_lossy())
.message( .message(
"Could not decode the file contents as {}: {}. Validate that the contents of the file matches the character encoding specified in the {} directive at the top of the file.", "Could not decode the file contents as {}: {}. The contents of the file must match the character encoding specified in the {} directive.",
&[&encoding_name, &msg, "encoding:"], &[&encoding_name, &msg, "encoding:"],
) )
.status_page() .status_page()
.help_link("https://docs.ruby-lang.org/en/master/syntax/comments_rdoc.html#label-encoding+Directive")
.severity(diagnostics::Severity::Warning), .severity(diagnostics::Severity::Warning),
); );
} }
@@ -218,11 +219,11 @@ fn main() -> std::io::Result<()> {
.new_entry("unknown-character-encoding", "Unknown character encoding") .new_entry("unknown-character-encoding", "Unknown character encoding")
.file(&path.to_string_lossy()) .file(&path.to_string_lossy())
.message( .message(
"Unknown character encoding {} in {} directive. Validate that the specified name is a supported character set.", "Unknown character encoding {} in {} directive.",
&[&encoding_name, "#encoding:"], &[&encoding_name, "#encoding:"],
) )
.status_page() .status_page()
.help_link("https://docs.ruby-lang.org/en/3.2/syntax/comments_rdoc.html#label-encoding+Directive") .help_link("https://docs.ruby-lang.org/en/master/syntax/comments_rdoc.html#label-encoding+Directive")
.severity(diagnostics::Severity::Warning), .severity(diagnostics::Severity::Warning),
); );
} }

View File

@@ -1 +1 @@
| src/not_ruby.rb:5:25:5:26 | A parse error occurred. Check the syntax of the file using the ruby -c command. If the file is indeed invalid, please correct the error or exclude the file from analysis. | Extraction failed in src/not_ruby.rb with error A parse error occurred. Check the syntax of the file using the ruby -c command. If the file is indeed invalid, please correct the error or exclude the file from analysis. | 2 | | src/not_ruby.rb:5:25:5:26 | A parse error occurred. Check the syntax of the file using the ruby -c command. If the file is invalid, correct the error or exclude the file from analysis. | Extraction failed in src/not_ruby.rb with error A parse error occurred. Check the syntax of the file using the ruby -c command. If the file is invalid, correct the error or exclude the file from analysis. | 2 |