Skip to content

CC0123: Rewrite a call using named arguments #786

@kwhitefoot

Description

@kwhitefoot

New analyzer:

For methods that that are overloaded with different signatures where many of the arguments are of the same type it can often be hard to be sure that you are calling the right one

Perhaps we could detect cases where there are several methods of the same name with long argument lists and offer to convert the calls so that named arguments are used

Before:

function a(q as double, w as double, e as double, r as double) as double
...
end function


function a(q as double, w as double, r as double) as double
...
end function

 dim b = a(1,2,3,4)
 dim c = a(1,2,4)

After:

function a(q as double, w as double, e as double, r as double) as double
...
end function


function a(q as double, w as double, r as double) as double
...
end function

 dim b = a(q:=1, w:=2, e:=3, r:=4)
 dim c = a(q:=1,w:=2, r:=4)

Exactly what counts as too long, too confusing etc., is of course an open question.

The reason for this request is a bug I introduced while refactoring and removing an unused argument.

Diagnostic Id: CC0123
Category: <Reliability>
Severity: Warning

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions