forked from rubberduck-vba/Rubberduck
-
Notifications
You must be signed in to change notification settings - Fork 12
ParameterCanBeByValInspection
Mathieu Guindon edited this page Feb 23, 2015
·
3 revisions
Description: Parameter can be passed by value
Type: CodeInspectionType.CodeQualityIssues
Default severity: CodeInspectionSeverity.Suggestion
This inspection finds procedure parameters that are passed by reference, but never assigned to.
###Example:
Parameter foo
is passed ByRef
, but is never assigned to - passing it ByVal
would be more appriopriate:
Public Sub DoSomething(ByRef foo As Integer)
DoSomethingElse foo
End Sub
A ByRef
parameter can technically be reassigned by the called procedure, and the modified value is visible to the caller; if a method doesn't assign such a parameter, that parameter can safely be passed by value instead.
###QuickFixes
QuickFix: Pass parameter by value
Public Sub DoSomething(ByVal foo As Integer)
DoSomethingElse foo
End Sub
This quickfix replaces ByRef
with ByVal
in the method's signature for the unassigned parameter.