Skip to content

Commit ada0115

Browse files
committed
C#: Remove getUrl() predicates
As described on https://lgtm.com/help/ql/locations#providing-location-information, there is no need to provide a `getUrl()` predicate, when there is a `getLocation()` predicate. Not only is it redundant, but it can also be slow because of string construction.
1 parent 56b80ae commit ada0115

File tree

17 files changed

+25
-45
lines changed

17 files changed

+25
-45
lines changed

csharp/ql/src/semmle/code/cil/Type.qll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class Namespace extends DotNet::Namespace, TypeContainer, @namespace {
2323
override Namespace getParent() { result = this.getParentNamespace() }
2424
override Namespace getParentNamespace() { parent_namespace(this, result) }
2525
override string getName() { namespaces(this,result) }
26-
string getUrl() { result="" }
2726
override Location getLocation() { none() }
2827
}
2928

csharp/ql/src/semmle/code/csharp/Location.qll

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,16 @@ class Location extends @location
3737
string toString() { none() }
3838

3939
/** Gets the start line of this location. */
40-
int getStartLine() {
41-
locations_default(this,_,result,_,_,_)
42-
}
40+
final int getStartLine() { this.hasLocationInfo(_, result, _, _, _) }
4341

4442
/** Gets the end line of this location. */
45-
int getEndLine() {
46-
locations_default(this,_,_,_,result,_)
47-
}
43+
final int getEndLine() { this.hasLocationInfo(_, _, _, result, _) }
4844

4945
/** Gets the start column of this location. */
50-
int getStartColumn() {
51-
locations_default(this,_,_,result,_,_)
52-
}
46+
final int getStartColumn() { this.hasLocationInfo(_, _, result, _, _) }
5347

5448
/** Gets the end column of this location. */
55-
int getEndColumn() {
56-
locations_default(this,_,_,_,_,result)
57-
}
49+
final int getEndColumn() { this.hasLocationInfo(_, _, _, _, result) }
5850
}
5951

6052
/**

csharp/ql/src/semmle/code/csharp/Member.qll

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,6 @@ class Declaration extends DotNet::Declaration, Element, @declaration {
3636
result = this.getDeclaringType().getQualifiedName() + "." + this.toStringWithTypes()
3737
}
3838

39-
/** Define URL for declarations with no location. */
40-
string getURL() {
41-
if exists(this.getLocation()) then
42-
exists(string path, int a, int b, int c, int d |
43-
this.getLocation().hasLocationInfo(path, a, b, c, d) |
44-
toUrl(path, a, b, c, d, result)
45-
)
46-
else
47-
result = ""
48-
}
49-
5039
/**
5140
* Holds if this declaration has been generated by the compiler, for example
5241
* implicit constructors or accessors.

csharp/ql/src/semmle/code/csharp/Type.qll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,6 @@ class Class extends RefType, @class_type {
751751
* ```
752752
*/
753753
class AnonymousClass extends Class {
754-
755754
AnonymousClass() { this.getName().matches("<%") }
756755
}
757756

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
| expressions.cs:417:9:420:9 | object creation of type <>__AnonType0<String,String[]> | | String[] |
2-
| expressions.cs:421:9:424:9 | object creation of type <>__AnonType0<String,String[]> | | String[] |
1+
| expressions.cs:417:9:420:9 | object creation of type <>__AnonType0<String,String[]> | file://:0:0:0:0 | String[] |
2+
| expressions.cs:421:9:424:9 | object creation of type <>__AnonType0<String,String[]> | file://:0:0:0:0 | String[] |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| | N1.N2 |
1+
| namespaces.cs:5:11:5:15 | N1.N2 |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| | R1 | namespaces.cs:73:11:73:14 | A<> | namespaces.cs:80:11:80:11 | A |
1+
| namespaces.cs:70:11:70:12 | R1 | namespaces.cs:73:11:73:14 | A<> | namespaces.cs:80:11:80:11 | A |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| | M1.M2 |
1+
| namespaces.cs:16:15:16:16 | M1.M2 |
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
| | P1.P2 |
1+
| namespaces.cs:26:11:26:15 | P1.P2 |
2+
| namespaces.cs:33:11:33:15 | P1.P2 |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| | M1.M2 |
1+
| namespaces.cs:16:15:16:16 | M1.M2 |

0 commit comments

Comments
 (0)