Skip to content

Commit f146ab9

Browse files
authored
Merge pull request github#13032 from kaspersv/kaspersv/ruby-enable-implicit-this-warnings
Ruby: Enable implicit this warnings
2 parents edeffd8 + e6ca3fe commit f146ab9

File tree

6 files changed

+20
-13
lines changed

6 files changed

+20
-13
lines changed

ruby/ql/lib/codeql/ruby/frameworks/core/Gem.qll

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,36 +57,40 @@ module Gem {
5757
}
5858

5959
/** Gets the name of the gem */
60-
string getName() { result = getSpecProperty("name").getConstantValue().getString() }
60+
string getName() { result = this.getSpecProperty("name").getConstantValue().getString() }
6161

6262
/** Gets a path that is loaded when the gem is required */
6363
private string getARequirePath() {
64-
result = getSpecProperty(["require_paths", "require_path"]).getConstantValue().getString()
64+
result =
65+
this.getSpecProperty(["require_paths", "require_path"]).getConstantValue().getString()
6566
or
66-
not exists(getSpecProperty(["require_paths", "require_path"]).getConstantValue().getString()) and
67+
not exists(
68+
this.getSpecProperty(["require_paths", "require_path"]).getConstantValue().getString()
69+
) and
6770
result = "lib" // the default is "lib"
6871
}
6972

7073
/** Gets a file that could be loaded when the gem is required. */
7174
private File getAPossiblyRequiredFile() {
72-
result = File.super.getParentContainer().getFolder(getARequirePath()).getAChildContainer*()
75+
result =
76+
File.super.getParentContainer().getFolder(this.getARequirePath()).getAChildContainer*()
7377
}
7478

7579
/** Gets a class/module that is exported by this gem. */
7680
private ModuleBase getAPublicModule() {
77-
result.(Toplevel).getLocation().getFile() = getAPossiblyRequiredFile()
81+
result.(Toplevel).getLocation().getFile() = this.getAPossiblyRequiredFile()
7882
or
79-
result = getAPublicModule().getAModule()
83+
result = this.getAPublicModule().getAModule()
8084
or
81-
result = getAPublicModule().getAClass()
85+
result = this.getAPublicModule().getAClass()
8286
or
83-
result = getAPublicModule().getStmt(_).(SingletonClass)
87+
result = this.getAPublicModule().getStmt(_).(SingletonClass)
8488
}
8589

8690
/** Gets a parameter from an exported method, which is an input to this gem. */
8791
DataFlow::ParameterNode getAnInputParameter() {
8892
exists(MethodBase method |
89-
method = getAPublicModule().getAMethod() and
93+
method = this.getAPublicModule().getAMethod() and
9094
result.getParameter() = method.getAParameter()
9195
|
9296
method.isPublic()

ruby/ql/lib/qlpack.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ dependencies:
1212
codeql/util: ${workspace}
1313
dataExtensions:
1414
- codeql/ruby/frameworks/**/model.yml
15+
warnOnImplicitThis: true

ruby/ql/src/qlpack.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ dependencies:
99
codeql/ruby-all: ${workspace}
1010
codeql/suite-helpers: ${workspace}
1111
codeql/util: ${workspace}
12+
warnOnImplicitThis: true

ruby/ql/src/queries/meta/internal/TaintMetrics.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ private import codeql.ruby.security.UrlRedirectCustomizations
1111
private import codeql.ruby.security.SqlInjectionCustomizations
1212

1313
class RelevantFile extends File {
14-
RelevantFile() { not getRelativePath().regexpMatch(".*/test(case)?s?/.*") }
14+
RelevantFile() { not this.getRelativePath().regexpMatch(".*/test(case)?s?/.*") }
1515
}
1616

1717
RemoteFlowSource relevantTaintSource(string kind) {

ruby/ql/test/library-tests/dataflow/api-graphs/use.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ class ApiUseTest extends InlineExpectationsTest {
3838

3939
override predicate hasActualResult(Location location, string element, string tag, string value) {
4040
tag = "use" and // def tags are always optional
41-
exists(DataFlow::Node n | relevantNode(_, n, location, tag) |
41+
exists(DataFlow::Node n | this.relevantNode(_, n, location, tag) |
4242
// Only report the longest path on this line:
4343
value =
4444
max(API::Node a2, Location l2, DataFlow::Node n2 |
45-
relevantNode(a2, n2, l2, tag) and
45+
this.relevantNode(a2, n2, l2, tag) and
4646
l2.getFile() = location.getFile() and
4747
l2.getEndLine() = location.getEndLine()
4848
|
@@ -57,7 +57,7 @@ class ApiUseTest extends InlineExpectationsTest {
5757
// We also permit optional annotations for any other path on the line.
5858
// This is used to test subclass paths, which typically have a shorter canonical path.
5959
override predicate hasOptionalResult(Location location, string element, string tag, string value) {
60-
exists(API::Node a, DataFlow::Node n | relevantNode(a, n, location, tag) |
60+
exists(API::Node a, DataFlow::Node n | this.relevantNode(a, n, location, tag) |
6161
element = n.toString() and
6262
value = getAPath(a, _)
6363
)

ruby/ql/test/qlpack.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ dependencies:
66
codeql/ruby-all: ${workspace}
77
extractor: ruby
88
tests: .
9+
warnOnImplicitThis: true

0 commit comments

Comments
 (0)