Skip to content

Inspection for duplicated function calls in If..Then #4344

Open
@daFreeMan

Description

@daFreeMan

There is need for a new inspection for redundant function calls when guarding against divide-by-zero errors:

If Foo(Bar, Baz) > 0 then
  Result = Frob(Baz) / Foo(Bar, Baz)
Else
  Result = -1
End If

No big deal unless Foo() is long running, memory intensive, network hogging, or...

Quick Fix would be:

Dim fooResult as Long
fooResult = Foo(Bar, Baz) 
If fooResult > 0 then
  Result = Frob(Baz) / fooResult
Else
  Result = -1
End If

Giving the user the option to name fooResult to his hearts desire.

There are probably other guard clause type situations (not just Div/0) that this would apply to, but a more general inspection is more difficult than what I can dream up at the moment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    code-path-analysisInvolves simulating execution paths / interpreting the user code ..to an extent.difficulty-03-duckInvolves more challenging problems and/or developing within and revising the internals APIenhancementFeature 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-ducky

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions