rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
https://rubberduckvba.com
GNU General Public License v3.0
1.91k stars 299 forks source link

Implicitly accessing hidden global class inspection #5318

Open IvenBach opened 4 years ago

IvenBach commented 4 years ago

What Bring to the users attention that they're implicitly accessing a member. Inspection: CodeQuality.

Why Using WorksheetFunction.FooBar or anything else that's on the hidden Global member deprives users of knowing where they're accessing the member from. Them knowing that a hidden member is providing this member educates them.

Example This code should trigger the inspection:

Public Sub Foo()
    Debug.Print WorksheetFunction.Text(2 / 16, "# ??/??")
End Sub

QuickFixes If static analysis enables Application to be determined.

  1. QualifyHiddenGlobalMemberAccessQuickFix

    Example code, after quickfix is applied:

    Public Sub Foo()
        Debug.Print Application.WorksheetFunction.Text(2 / 16, "# ??/??")
    End Sub

Resources Each inspection needs a number of resource strings - please provide a suggestion here:

retailcoder commented 4 years ago

I'd call that ImplicitlyQualifiedMemberCallInspection I think