Skip to content

Commit 8949f71

Browse files
committed
C#: Fixup CSV validation refactor.
1 parent ad671f7 commit 8949f71

1 file changed

Lines changed: 16 additions & 18 deletions

File tree

csharp/ql/lib/semmle/code/csharp/dataflow/CsvValidation.qll

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ private string getInvalidModelColumnCount() {
9494
)
9595
}
9696

97-
/** Holds if some row in a CSV-based flow model appears to contain typos. */
98-
query predicate invalidModelRow(string msg) {
97+
private string getInvalidModelSignature() {
9998
exists(
10099
string pred, string namespace, string type, string name, string signature, string ext,
101100
string provenance
@@ -112,31 +111,30 @@ query predicate invalidModelRow(string msg) {
112111
pred = "negative summary"
113112
|
114113
not namespace.regexpMatch("[a-zA-Z0-9_\\.]+") and
115-
msg = "Dubious namespace \"" + namespace + "\" in " + pred + " model."
114+
result = "Dubious namespace \"" + namespace + "\" in " + pred + " model."
116115
or
117116
not type.regexpMatch("[a-zA-Z0-9_<>,\\+]+") and
118-
msg = "Dubious type \"" + type + "\" in " + pred + " model."
117+
result = "Dubious type \"" + type + "\" in " + pred + " model."
119118
or
120119
not name.regexpMatch("[a-zA-Z0-9_<>,]*") and
121-
msg = "Dubious member name \"" + name + "\" in " + pred + " model."
120+
result = "Dubious member name \"" + name + "\" in " + pred + " model."
122121
or
123122
not signature.regexpMatch("|\\([a-zA-Z0-9_<>\\.\\+\\*,\\[\\]]*\\)") and
124-
msg = "Dubious signature \"" + signature + "\" in " + pred + " model."
123+
result = "Dubious signature \"" + signature + "\" in " + pred + " model."
125124
or
126125
not ext.regexpMatch("|Attribute") and
127-
msg = "Unrecognized extra API graph element \"" + ext + "\" in " + pred + " model."
126+
result = "Unrecognized extra API graph element \"" + ext + "\" in " + pred + " model."
128127
or
129128
not provenance = ["manual", "generated"] and
130-
msg = "Unrecognized provenance description \"" + provenance + "\" in " + pred + " model."
129+
result = "Unrecognized provenance description \"" + provenance + "\" in " + pred + " model."
131130
)
132-
or
133-
msg = getInvalidModelInput()
134-
or
135-
msg = getInvalidModelOutput()
136-
or
137-
msg = getInvalidModelSubtype()
138-
or
139-
msg = getInvalidModelColumnCount()
140-
or
141-
msg = getInvalidModelKind()
131+
}
132+
133+
/** Holds if some row in a CSV-based flow model appears to contain typos. */
134+
query predicate invalidModelRow(string msg) {
135+
msg =
136+
[
137+
getInvalidModelSignature(), getInvalidModelInput(), getInvalidModelOutput(),
138+
getInvalidModelSubtype(), getInvalidModelColumnCount(), getInvalidModelKind()
139+
]
142140
}

0 commit comments

Comments
 (0)