mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Merge pull request #12442 from aibaars/diagnostics-tests
Ruby: add some integration tests for diagnostic messages
This commit is contained in:
@@ -214,9 +214,9 @@ fn longest_backtick_sequence_length(text: &str) -> usize {
|
||||
}
|
||||
result
|
||||
}
|
||||
/**
|
||||
* An argument of a diagnostic message format string. A message argument is either a "code" snippet or a link.
|
||||
*/
|
||||
|
||||
/// An argument of a diagnostic message format string.
|
||||
/// A message argument is either a "code" snippet or a link.
|
||||
pub enum MessageArg<'a> {
|
||||
Code(&'a str),
|
||||
Link(&'a str, &'a str),
|
||||
|
||||
@@ -294,7 +294,7 @@ impl<'a> Visitor<'a> {
|
||||
.diagnostics_writer
|
||||
.new_entry("parse-error", "Parse error");
|
||||
&mesg
|
||||
.severity(diagnostics::Severity::Error)
|
||||
.severity(diagnostics::Severity::Warning)
|
||||
.location(self.path, start_line, start_column, end_line, end_column)
|
||||
.message(message, args);
|
||||
if status_page {
|
||||
@@ -405,7 +405,7 @@ impl<'a> Visitor<'a> {
|
||||
loc,
|
||||
self.diagnostics_writer
|
||||
.new_entry("parse-error", "Parse error")
|
||||
.severity(diagnostics::Severity::Error)
|
||||
.severity(diagnostics::Severity::Warning)
|
||||
.location(self.path, start_line, start_column, end_line, end_column)
|
||||
.message(
|
||||
"Unknown table type: {}",
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
4 %%% 5
|
||||
|
||||
if 1; 2
|
||||
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"helpLinks": [
|
||||
"https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning"
|
||||
],
|
||||
"location": {
|
||||
"endColumn": 5,
|
||||
"endLine": 1,
|
||||
"file": "<test-root-directory>/bad.rb",
|
||||
"startColumn": 4,
|
||||
"startLine": 1
|
||||
},
|
||||
"markdownMessage": "A parse error occurred. Check the syntax of the file. If the file is invalid, correct the error or [exclude](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning) the file from analysis.",
|
||||
"plaintextMessage": "A parse error occurred. Check the syntax of the file. If the file is invalid, correct the error or exclude the file from analysis.",
|
||||
"severity": "Warning",
|
||||
"source": {
|
||||
"extractorName": "ruby",
|
||||
"id": "ruby/parse-error",
|
||||
"name": "Parse error"
|
||||
},
|
||||
"visibility": {
|
||||
"statusPage": true
|
||||
}
|
||||
}
|
||||
{
|
||||
"helpLinks": [
|
||||
"https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning"
|
||||
],
|
||||
"location": {
|
||||
"endColumn": 7,
|
||||
"endLine": 3,
|
||||
"file": "<test-root-directory>/bad.rb",
|
||||
"startColumn": 8,
|
||||
"startLine": 3
|
||||
},
|
||||
"markdownMessage": "A parse error occurred (expected `end` symbol). Check the syntax of the file. If the file is invalid, correct the error or [exclude](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning) the file from analysis.",
|
||||
"plaintextMessage": "A parse error occurred (expected end symbol). Check the syntax of the file. If the file is invalid, correct the error or exclude the file from analysis.",
|
||||
"severity": "Warning",
|
||||
"source": {
|
||||
"extractorName": "ruby",
|
||||
"id": "ruby/parse-error",
|
||||
"name": "Parse error"
|
||||
},
|
||||
"visibility": {
|
||||
"statusPage": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import os
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
|
||||
run_codeql_database_create([], lang="ruby", runFunction = runSuccessfully, db = None)
|
||||
|
||||
check_diagnostics()
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"helpLinks": [
|
||||
"https://docs.ruby-lang.org/en/master/syntax/comments_rdoc.html#label-encoding+Directive"
|
||||
],
|
||||
"location": {
|
||||
"file": "<test-root-directory>/encoding.rb"
|
||||
},
|
||||
"markdownMessage": "Unknown character encoding `silly` in `#encoding:` [directive](https://docs.ruby-lang.org/en/master/syntax/comments_rdoc.html#label-encoding+Directive).",
|
||||
"plaintextMessage": "Unknown character encoding silly in #encoding: directive.",
|
||||
"severity": "Warning",
|
||||
"source": {
|
||||
"extractorName": "ruby",
|
||||
"id": "ruby/unknown-character-encoding",
|
||||
"name": "Unknown character encoding"
|
||||
},
|
||||
"visibility": {
|
||||
"statusPage": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# encoding: silly
|
||||
|
||||
def f
|
||||
puts "hello"
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
import os
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
|
||||
run_codeql_database_create([], lang="ruby", runFunction = runSuccessfully, db = None)
|
||||
|
||||
check_diagnostics()
|
||||
3
ruby/ql/integration-tests/all-platforms/qlpack.yml
Normal file
3
ruby/ql/integration-tests/all-platforms/qlpack.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
dependencies:
|
||||
codeql/ruby-all: '*'
|
||||
codeql/ruby-queries: '*'
|
||||
4
ruby/ql/lib/change-notes/2023-03-09-parse-error.md
Normal file
4
ruby/ql/lib/change-notes/2023-03-09-parse-error.md
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* The severity of parse errors was reduced to warning (previously error).
|
||||
@@ -47,6 +47,6 @@ class Diagnostic extends @diagnostic {
|
||||
}
|
||||
|
||||
/** A diagnostic relating to a particular error in extracting a file. */
|
||||
class ExtractionError extends Diagnostic, @diagnostic_error {
|
||||
class ExtractionError extends Diagnostic {
|
||||
ExtractionError() { this.getTag() = "parse_error" }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user