C#: Autoformat QL files

This commit is contained in:
Tom Hvitved
2019-01-11 09:28:31 +01:00
parent 28261d6787
commit 390ebc96ae
37 changed files with 143 additions and 181 deletions

View File

@@ -28,11 +28,9 @@ where
itemText = "here"
)
or
(
item = c.getAnOperator().(EQOperator) and
message = "but it implements $@" and
itemText = "operator =="
)
item = c.getAnOperator().(EQOperator) and
message = "but it implements $@" and
itemText = "operator =="
or
exists(IEquatableEqualsMethod eq |
item = eq and

View File

@@ -18,17 +18,13 @@ from Class c, Method present, string missing
where
c.isSourceDeclaration() and
(
(
present = c.getAMethod().(EqualsMethod) and
not c.getAMethod() instanceof GetHashCodeMethod and
missing = "GetHashCode()"
)
present = c.getAMethod().(EqualsMethod) and
not c.getAMethod() instanceof GetHashCodeMethod and
missing = "GetHashCode()"
or
(
present = c.getAMethod().(GetHashCodeMethod) and
not implementsEquals(c) and
missing = "Equals(object)"
)
present = c.getAMethod().(GetHashCodeMethod) and
not implementsEquals(c) and
missing = "Equals(object)"
)
select c, "Class '" + c.getName() + "' overrides $@, but not " + missing + ".", present,
present.getName()

View File

@@ -20,10 +20,8 @@ predicate implementsIComparable(ValueOrRefType t, Type paramType) {
or
t instanceof SystemIComparableTInterface
or
(
t.getABaseType*() instanceof SystemIComparableInterface and
paramType instanceof ObjectType
)
t.getABaseType*() instanceof SystemIComparableInterface and
paramType instanceof ObjectType
}
predicate compareToMethod(Method m, Type paramType) {

View File

@@ -99,7 +99,7 @@ class DiscardedMethodCall extends MethodCall {
// to deliberately ignore the returned value
not getEnclosingCallable().getStatementBody().getNumberOfStmts() = 1
|
(important(m) and result = "should always be checked")
important(m) and result = "should always be checked"
or
exists(int percentage | dubious(m, percentage) |
result = percentage.toString() + "% of calls to this method have their result used"