Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Add warnings for unused properties #5

Open
fireundubh opened this issue Mar 22, 2016 · 7 comments
Open

Request: Add warnings for unused properties #5

fireundubh opened this issue Mar 22, 2016 · 7 comments

Comments

@fireundubh
Copy link

NT

@Orvid
Copy link
Owner

Orvid commented Mar 23, 2016

In what context? I can certainly add a warning for unused variables on scripts, as well as unused locals in functions, but unused properties would require checking to see if any script that references the current script uses them, which is not something that's viable for me to do at compile time.

@fireundubh
Copy link
Author

but unused properties would require checking to see if any script that references the current script uses them, which is not something that's viable for me to do at compile time.

Hmm. Unused properties is one of the most common warnings output to the Papyrus log. If you can figure it out...

I can certainly add a warning for unused variables on scripts, as well as unused locals in functions

But these would be useful, too.

@Orvid
Copy link
Owner

Orvid commented Mar 27, 2016

Assuming the unused properties warning you're referring to is the same one described here, there's nothing I can do about that. That warning is triggered when there are properties set in the .esp or .esm that aren't present on the actual scripts themselves. This typically happens when a property is removed from the actual script.

@fireundubh
Copy link
Author

There are errors when a script has a property that is filled but which is otherwise unused.

error: Property BoSM01DanseStage150CMPFinalReport0 on script Fragments:Quests:QF_BoSM01_000B1D79 attached to BoSM01 (000B1D79) cannot be bound because (000BA3D9) is not the right type

This property isn't used in any script, except for its declaration. It is filled, but with the wrong object, so you see this error.

A warning for possible orphaned properties would be useful. For compiling Bethesda's scripts, it would help with cleaning up these unused properties, and for compiling our own scripts, it would let us know when we've possibly forgotten something.

This is the JavaScript equivalent in UltraEdit.

@Orvid
Copy link
Owner

Orvid commented Mar 28, 2016

Even if I remove that property, you'll still get a Warning because the actual binding data in the .esm is still present.

With some significant re-structuring it would be possible for me to implement a global analysis to see which properties are used, but that would only be viable when compiling the entire source tree, and wouldn't work for any of the fragments.

Although Champollion does decompile fragments into Papyrus script, and Caprica is able to compile those into .pex files, the original source for the fragments is not (as far as I know) Papyrus script, it is .xml files used by the Creation Kit.

@fireundubh
Copy link
Author

Even if I remove that property, you'll still get a Warning because the actual binding data in the .esm is still present.

I know, but in my opinion, it's better to see warnings than none.

With some significant re-structuring it would be possible for me to implement a global analysis to see which properties are used, but that would only be viable when compiling the entire source tree, and wouldn't work for any of the fragments.

While that system would be more useful, it's a bit much for what would ultimately just help clean up the Papyrus log and messy scripts. I was only requesting a "is this property used in the script being compiled?" check, which should run much faster in C++ than JS.

@Orvid
Copy link
Owner

Orvid commented Mar 28, 2016

I can certainly do that, but I'd be putting it behind a --lint flag, that would be disabled by default because I'd like to keep the warnings limited to things that it can be certain about. Variables aren't accessible outside of the current script, so I can make those warnings.

I've been needing to add a --lint flag anyways so handle some consistency checks, primarily regarding the choice of parameter names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants