RDC00314: Redundant ByRef modifier
Severity: Information · Family: RDC (Rubberduck Core analyzers) ·
Raised by: RedundantByRefModifierAnalyzer
A parameter states ByRef.
A parameter that states neither ByRef nor ByVal is passed by reference
(MS-VBAL §5.3.1.5 Parameter Lists), so ByRef changes nothing.
The diagnostic is reported only when the Diagnostics.ByRefModifier setting is Implicit. With the default, Explicit, ByRef is written, and a parameter
that states neither is RDC00104 instead. Both are legal VBA.
These parameters are not reported:
- a parameter of a
Declare, which states how each argument goes to the library; - a parameter of a procedure that implements an interface member or handles an event, which repeats the declaration it matches;
- the value parameter of a property
LetorSet, whoseByRefis RDC00205.
The finding is the parameter.
How it is raised
| Situation | Example | Resolution |
|---|---|---|
A parameter that states ByRef, under the Implicit convention. |
Public Sub DoSomething(ByRef foo As Long) |
Remove ByRef. |
Quick fix
The diagnostic comes with a quick fix, Remove ByRef from '…'. It removes ByRef and what is written between it and the name, and the parameter is still
passed by reference: Optional ByRef foo As Long becomes Optional foo As Long.
See also
ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca