JS: classify generated data files#108
Conversation
xiemaisi
left a comment
There was a problem hiding this comment.
Approach seems plausible; how many projects have you tried this out on?
| e.getFile() = f and | ||
| e.isImpure() and | ||
| // ... except for variable initializers | ||
| not e instanceof VariableDeclarator |
There was a problem hiding this comment.
Does this mean we consider VariableDeclarators to be impure? That seems undesirable.
There was a problem hiding this comment.
Yes, but that seems right to me.
They do modify the scope object after all.
There was a problem hiding this comment.
That's true, but modelling it seems overkill, particularly since we don't even model the scope object. Also, that modification isn't observable in any way, is it?
There was a problem hiding this comment.
Hmm. I could go either way on this. On the one hand, shadowing variables in enclosing scopes and creation of properties on the global object are easily observable side effects, but on the other hand, I see what you mean regarding the expressive power of our analysis.
Do you want a change in this PR?
There was a problem hiding this comment.
You are right, of course, there are observable side effects, but I would still hesitate to ascribe them to the declarator, so on the whole I'd be in favour of changing this. It seems like a fairly minor and harmless change that would make this predicate look a bit less confusing.
There was a problem hiding this comment.
Done.
Do we skip the full dist-compare for this change?
|
This has been tested on 203 projects with 38 results, which are all true positives. |
|
Amended with updated expected output for |
|
Apologies, I only just realised I misremembered what a In that case of course it doesn't make sense to treat it as pure. Could you remove the second commit, please? (Sorry about that.) |
|
Done. |
Allow associating comments with fields
PS: Fix compile errors and warnings.
Fixes ODASA-7301 by identifying data files as side effect free files that are full of primitive literals.
Example results: