Skip to content

Code inspection should warn if variable is declared at module and method level #3276

@Stevefb

Description

@Stevefb

I'm not so confident with coding best (or worst practices) but can't help but feel there should be some sort of warning about declaring a variable at module level and also within subs / functions. There are no warnings or suggestions for the following:

Option Explicit
Private foo As String      ' <<<
    
Public Sub bar()
    Dim foo As String      ' <<<
    foo = "bar"
    Debug.Print foo
End Sub
    
Public Sub foobar()
    foo = "bar"
    Debug.Print foo
End Sub

Public Sub foobarfoo()
    foo = "bar"
    Debug.Print foo
End Sub

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionenhancementFeature requests, or enhancements to existing features. Ideas. Anything within the project's scope.feature-inspections

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions