-
Notifications
You must be signed in to change notification settings - Fork 315
Open
Labels
enhancementFeature requests, or enhancements to existing features. Ideas. Anything within the project's scope.Feature requests, or enhancements to existing features. Ideas. Anything within the project's scope.feature-inspectionsup-for-grabsUse this label in conjunction with a difficulty level label, e.g. difficulty-02-duckyUse this label in conjunction with a difficulty level label, e.g. difficulty-02-ducky
Milestone
Description
What
Inspection for using logical operator Or in a Select Case.
Why
The user may not realise that the Select Case may not follow the path they expect.
Example
This code should trigger the inspection:
Public Function IsOdd(ByVal Number as Long) As Boolean
Select Case Number
Case 1 Or 3: 'here
IsOdd = True
End Select
End FunctionDebug.Print IsOdd(1) 'FalseQuickFixes
-
Replace Or operator with Comma separator
Example code, after quickfix is applied:
Public Function IsOdd(ByVal Number as Long) As Boolean
Select Case Number
Case 1, 3: 'here
IsOdd = True
End Select
End FunctionDebug.Print IsOdd(1) 'TrueResources
I don't know enough about the workings of the Select Case to suggest the right terminology for the resource strings.
Metadata
Metadata
Assignees
Labels
enhancementFeature requests, or enhancements to existing features. Ideas. Anything within the project's scope.Feature requests, or enhancements to existing features. Ideas. Anything within the project's scope.feature-inspectionsup-for-grabsUse this label in conjunction with a difficulty level label, e.g. difficulty-02-duckyUse this label in conjunction with a difficulty level label, e.g. difficulty-02-ducky