ShiftLeftSecurity / ShiftLeftSecurity/codepropertygraph
usage of call.argument without any parameter leads to compiler error
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 597
- Forks
- 84
- Avg merge
- 18h 29m
- Merged PRs (30d)
- 1
Description
cpg.call.codeExact("...").head match {
case (call : nodes.Call) :: Nil =>
println(call.argument.l.length)
}
leads to compiler error:
missing argument list for method argument in class CallMethods
[error] Unapplied methods are only converted to functions when a function type is expected.
[error] You can make this conversion explicit by writing `argument _` or `argument(_)` instead of `argument`.
When applying the suggested fix:
cpg.call.codeExact("...").head match {
case (call : nodes.Call) :: Nil =>
println(call.argument(_).l.length)
}
I get the compiler error:
missing parameter type for expanded function ((<x$1: error>) => call.argument(x$1).l.length.shouldBe(1))
[error] println(call.argument(_).l.length)
[error]
I was expecting to simply print the amount of arguments connected to that call node.
Current work-around:
cpg.call.codeExact("...").head match {
case (call : nodes.Call) :: Nil =>
println(call.out(EdgeTypes.ARGUMENT).asScala.toList.length)
}
I am using cpg version: 1.2.25
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the compiler error with the Scala snippet and inspect the CallMethods.argument API together with the shown EdgeTypes.ARGUMENT workaround. Confirm that the intended argument-count expression compiles and returns the same count without requiring an explicit parameter.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100