Yet another checker prototype

15 views
Skip to first unread message

Edward K. Ream

unread,
May 4, 2022, 10:19:40 AM5/4/22
to leo-editor
Rev d53898 fixes a buglet caught by Félix.

Me: >> Good catch in contractNodeOrGoToParent. Did typescript help?

Félix: > Not even! (my typescript linting settings are not tight enough to flag that comparison it seems) 

> I guess i have a good eye when scrutinizing/staring at code, the trick is to shut down your inner dialog and let your instincts alert you on something looking fishy. (easier said than done)"

Amazing! Yesterday I wrote @button find-non-calls,  a script to find such mistakes. A flattened version is attached. The first pass (scan) finds defs in leo/core and leo/commands. The second pass (check) looks for the function names not followed by a parenthesis.

Alas, there are too many overlaps between function names and variables. These overlaps create too many false positives. I first created a (long!) list of exceptions. Then I had the not-too-bright idea to suppress hits in various contexts. But Doh, function calls are valid in those contexts, so check will discard almost all warnings about possible errors.

Summary

The script was always intended as a quick prototype. Alas, finding errors such as Félix found requires more sophisticated analysis of context.

At best, this script was a warmup for future work on pylint.

Edward
find-non-calls.txt

Edward K. Ream

unread,
May 4, 2022, 10:24:22 AM5/4/22
to leo-editor
On Wednesday, May 4, 2022 at 9:19:40 AM UTC-5 Edward K. Ream wrote:

Yesterday I wrote @button find-non-calls,  a script to find such mistakes. A flattened version is attached.

Rev 9358ea adds `script: find-non-calls` to LeoPyRef.leo.  I plan no further work on this script.

Edward

tbp1...@gmail.com

unread,
May 4, 2022, 10:45:31 AM5/4/22
to leo-editor
Tricky problem!  There are just enough cases where the intent really is to write the bare function without the parens that the code would have to be a mind reader.  or else the code would need to be running so one could flag the type as being a function or method, where it would hardly ever be used that way.

maybe a dose of machine learning, if only enough samples could be collected.

Edward K. Ream

unread,
May 4, 2022, 1:44:32 PM5/4/22
to leo-editor
On Wed, May 4, 2022 at 9:45 AM tbp1...@gmail.com <tbp1...@gmail.com> wrote:
Tricky problem!  There are just enough cases where the intent really is to write the bare function without the parens that the code would have to be a mind reader.  or else the code would need to be running so one could flag the type as being a function or method, where it would hardly ever be used that way.

maybe a dose of machine learning, if only enough samples could be collected.

Heh. That's a new idea. For now, I think pylint provides the proper infrastructure. Perhaps I should report this as a pylint failure, and suggest a new checker.

Edward
Reply all
Reply to author
Forward
0 new messages