Comments (2)
These bugs should be fairly easy to fix.
Pull requests are always welcome! 😊
These are actually two rather tricky edge cases: ByRef assignment (where an unassigned variable is passed ByRef to a procedure that assigns it) is not being tracked at all, mostly for performance reasons; we err on the side of caution and warn anyway, because there's no way to tell whether passing the parameter ByRef was intended or just an omission, given the language default.
If I recall correctly, the Mid
/Mid$
statement is syntactically a special case that must be parsed as a keyword rather than a function call, so the arguments don't (and shouldn't either) resolve to Mid
function parameters; I'd have to double-check but IIRC we are treating this argument as we would a ByRef assignment. This one could be a case of misunderstanding exactly how the statement operates, since it's a rather rare occurrence; I agree there should be a relatively easy way for the inspection to ignore them, if indeed it's guaranteed that the given argument is assigned after the statement is executed.
ByRef assignments are not likely to be addressed in v2.x, however the plan for v3 diagnostics is to massively expand the customization and allow each individual inspection to have its own SettingsGroup, which would make it possible to configure the inspection to either pursue ByRef assignments, or to ignore them specifically, without needing to sprinkle @Ignore
annotations. Many inspections have such default behaviors that would ideally be configurable, but the 2.x settings would be painful to implement.
I think the case of the Mid
statement could be fixed in 2.x, but I think it's probably best to let ByRef assignments slip for now, until diagnostics can be individually configured in v3.
from rubberduck.
Actually I misread the first case, it's about a member call and it's the object variable being flagged, not the argument (correct?). In that case then the outcome depends on where the object variable is assigned. If it's global and assigned in another scope that just so happens to be invoked at some point before, then there is indeed no statically guaranteed way that the containing procedure will always be invoked in the correct global state and the warning is warranted.
If it's set relatively near its usage, there's no reason for it to be flagged. The provided code example does not show how the object variable is set though.
from rubberduck.
Related Issues (20)
- Rubberduck->Tools->Import Saved Project (restore all backup source code modules/forms/classes) HOT 1
- Timestamp annotation OR Just insert/paste Timestamp HOT 1
- Indenter Trim/Remove Trailing Spaces HOT 2
- Refactor Extract Method Will Not Extract Apparently Complete Code Block If Trailing Line End Is Included in Selection HOT 2
- code Inspection does not see anything in the project. HOT 2
- Error when starting VBA in Access 365 HOT 2
- Microsoft .NET Framework error when loading Rubberduck. HOT 1
- Recent Resolver Error on VBE-compilable code HOT 5
- Line Number ?
- Resolver Error when resolving existing VBA project for the first time HOT 3
- Code Inspection - "Assignment is not used" incorrectly identified HOT 3
- Indentation failed on simple code HOT 2
- Office Program crashing when refreshing in ofiice file contains forms HOT 2
- Parse error on Private Type definition HOT 6
- Questionable behavior in "Code inspections" HOT 1
- Excel shutdown when opening a class node in Code Explorer HOT 3
- UnassignedVariableUsage Doesn't support variable being assigned as an "out" parameter from a property/sub/function HOT 4
- Rubberduck wants me to assign Object() array with 'Set' keyword HOT 1
- Add a comment to selected lines of code HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rubberduck.