Skip to content

Commit 55c658d

Browse files
TNSelahleTebogo Selahle
andauthored
fix: use fully qualified fullname for NamespaceBlock (#5689)
Co-authored-by: Tebogo Selahle <[email protected]>
1 parent 6d70cdb commit 55c658d

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

joern-cli/frontends/rubysrc2cpg/src/main/scala/io/joern/rubysrc2cpg/astcreation/AstForTypesCreator.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ trait AstForTypesCreator(implicit withSchemaValidation: ValidationMode) { this:
6666
scope.pushNewScope(NamespaceScope(namespaceBlockFullName))
6767

6868
val namespaceBlock =
69-
NewNamespaceBlock().name(astParentFullName).fullName(astParentFullName).filename(relativeFileName)
69+
NewNamespaceBlock().name(astParentFullName).fullName(namespaceBlockFullName).filename(relativeFileName)
7070

7171
diffGraph.addNode(namespaceBlock)
7272

7373
fileNode.foreach(diffGraph.addEdge(_, namespaceBlock, EdgeTypes.AST))
7474

75-
typeDecl.astParentFullName(astParentFullName)
75+
typeDecl.astParentFullName(namespaceBlockFullName)
7676
typeDecl.astParentType(NodeTypes.NAMESPACE_BLOCK)
7777

7878
typeDecl.fullName(computeFullName(className))

joern-cli/frontends/rubysrc2cpg/src/test/scala/io/joern/rubysrc2cpg/querying/ClassTests.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ class ClassTests extends RubyCode2CpgFixture {
977977
|end
978978
|""".stripMargin)
979979

980-
inside(cpg.namespaceBlock.fullNameExact("Api.V1").typeDecl.l) {
980+
inside(cpg.namespaceBlock.fullNameExact("Test0.rb:<main>.Api.V1").typeDecl.l) {
981981
case mobileNamespace :: mobileClassNamespace :: Nil =>
982982
mobileNamespace.name shouldBe "MobileController"
983983
mobileNamespace.fullName shouldBe s"Test0.rb:$Main.Api.V1.MobileController"
@@ -991,7 +991,7 @@ class ClassTests extends RubyCode2CpgFixture {
991991
case mobileTypeDecl :: Nil =>
992992
mobileTypeDecl.name shouldBe "MobileController"
993993
mobileTypeDecl.fullName shouldBe s"Test0.rb:$Main.Api.V1.MobileController"
994-
mobileTypeDecl.astParentFullName shouldBe "Api.V1"
994+
mobileTypeDecl.astParentFullName shouldBe "Test0.rb:<main>.Api.V1"
995995
mobileTypeDecl.astParentType shouldBe NodeTypes.NAMESPACE_BLOCK
996996

997997
mobileTypeDecl.astParent.isNamespaceBlock shouldBe true

joern-cli/frontends/rubysrc2cpg/src/test/scala/io/joern/rubysrc2cpg/querying/ModuleTests.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class ModuleTests extends RubyCode2CpgFixture {
4747
|end
4848
|""".stripMargin)
4949

50-
inside(cpg.namespaceBlock.fullNameExact("Api.V1").typeDecl.l) {
50+
inside(cpg.namespaceBlock.fullNameExact("Test0.rb:<main>.Api.V1").typeDecl.l) {
5151
case mobileNamespace :: mobileClassNamespace :: Nil =>
5252
mobileNamespace.name shouldBe "MobileController"
5353
mobileNamespace.fullName shouldBe "Test0.rb:<main>.Api.V1.MobileController"
@@ -61,7 +61,7 @@ class ModuleTests extends RubyCode2CpgFixture {
6161
case mobileTypeDecl :: Nil =>
6262
mobileTypeDecl.name shouldBe "MobileController"
6363
mobileTypeDecl.fullName shouldBe "Test0.rb:<main>.Api.V1.MobileController"
64-
mobileTypeDecl.astParentFullName shouldBe "Api.V1"
64+
mobileTypeDecl.astParentFullName shouldBe "Test0.rb:<main>.Api.V1"
6565
mobileTypeDecl.astParentType shouldBe NodeTypes.NAMESPACE_BLOCK
6666

6767
mobileTypeDecl.astParent.isNamespaceBlock shouldBe true

0 commit comments

Comments
 (0)