Caprica icon indicating copy to clipboard operation
Caprica copied to clipboard

Request: Add warnings for unused properties

Open fireundubh opened this issue 8 years ago • 7 comments

NT

fireundubh avatar Mar 22 '16 23:03 fireundubh

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.

Orvid avatar Mar 23 '16 00:03 Orvid

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.

fireundubh avatar Mar 23 '16 00:03 fireundubh

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.

Orvid avatar Mar 27 '16 18:03 Orvid

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.

fireundubh avatar Mar 27 '16 20:03 fireundubh

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.

Orvid avatar Mar 28 '16 03:03 Orvid

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.

fireundubh avatar Mar 28 '16 06:03 fireundubh

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.

Orvid avatar Mar 28 '16 20:03 Orvid