Identifying Un-used functions and commands

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Identifying Un-used functions and commands

Mark Wieder via use-livecode
Hi All,

I’m wondering if anyone has a way or code to identify any un-used functions and commands in a set of stacks?

Best,
Steve MacLean

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Identifying Un-used functions and commands

Mark Wieder via use-livecode
Hi.
"unused functions and commands"?
Do you mean handlers that exist in a script somewhere but are never called from anywhere?
I suppose you can search all scripts, and if a certain handler name does not appear without being prepended by either "on" & space(s) or "function" & space(s) then you can say that handler is never called.
Craig


-----Original Message-----
From: Stephen MacLean via use-livecode <[hidden email]>
To: How to use LiveCode <[hidden email]>
Cc: Stephen MacLean <[hidden email]>
Sent: Tue, Nov 12, 2019 12:14 pm
Subject: Identifying Un-used functions and commands

Hi All,

I’m wondering if anyone has a way or code to identify any un-used functions and commands in a set of stacks?

Best,
Steve MacLean

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

RE: Identifying Un-used functions and commands

Mark Wieder via use-livecode
"DO"s make this tricky. EX: Say you have some code that is mobile platform specific. do "myHandlerBaseName&the platform param1, param2". This example may not be good practice but "DO"s can trip you up looking for orphan handlers.

Ralph DiMola
IT Director
Evergreen Information Services
[hidden email]

-----Original Message-----
From: use-livecode [mailto:[hidden email]] On Behalf Of dunbarx--- via use-livecode
Sent: Tuesday, November 12, 2019 12:43 PM
To: [hidden email]
Cc: [hidden email]
Subject: Re: Identifying Un-used functions and commands

Hi.
"unused functions and commands"?
Do you mean handlers that exist in a script somewhere but are never called from anywhere?
I suppose you can search all scripts, and if a certain handler name does not appear without being prepended by either "on" & space(s) or "function" & space(s) then you can say that handler is never called.
Craig


-----Original Message-----
From: Stephen MacLean via use-livecode <[hidden email]>
To: How to use LiveCode <[hidden email]>
Cc: Stephen MacLean <[hidden email]>
Sent: Tue, Nov 12, 2019 12:14 pm
Subject: Identifying Un-used functions and commands

Hi All,

I’m wondering if anyone has a way or code to identify any un-used functions and commands in a set of stacks?

Best,
Steve MacLean

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Identifying Un-used functions and commands

Mark Wieder via use-livecode
In reply to this post by Mark Wieder via use-livecode
Since there is code in the script editor that knows the location of any command or function you right click on, if you found out how they do that, you would be well on your way to developing a way to grok it. Also, GLX2 has a "clairvoyance" (Auto-Complete) function that is handler aware. I suspect Mark Wieder developed a method for getting a list of all handlers in a stack that is opened. That would probably help too.

Bob S


> On Nov 12, 2019, at 09:12 , Stephen MacLean via use-livecode <[hidden email]> wrote:
>
> Hi All,
>
> I’m wondering if anyone has a way or code to identify any un-used functions and commands in a set of stacks?
>
> Best,
> Steve MacLean
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Identifying Un-used functions and commands

Mark Wieder via use-livecode
Hi.
This was posted a couple of weeks ago, no?
I suggested then that you could write a short handler that loops through all the scripts in all the controls on all the cards, and isolate words that are not preceded by either "command", "on" or "function". In this way you might see, for example, that "myGadget3" may be present in scripts here and there, but there is no "on myGadget3" anywhere. Then you will have found an unused handler call.
This may require tweaking. For example, LC will compile, say:
"on         myGadget3"  -- spaces galore

Craig

-----Original Message-----
From: Bob Sneidar via use-livecode <[hidden email]>
To: How to use LiveCode <[hidden email]>
Cc: Bob Sneidar <[hidden email]>
Sent: Mon, Nov 25, 2019 12:29 pm
Subject: Re: Identifying Un-used functions and commands

Since there is code in the script editor that knows the location of any command or function you right click on, if you found out how they do that, you would be well on your way to developing a way to grok it. Also, GLX2 has a "clairvoyance" (Auto-Complete) function that is handler aware. I suspect Mark Wieder developed a method for getting a list of all handlers in a stack that is opened. That would probably help too.

Bob S


> On Nov 12, 2019, at 09:12 , Stephen MacLean via use-livecode <[hidden email]> wrote:
>
> Hi All,
>
> I’m wondering if anyone has a way or code to identify any un-used functions and commands in a set of stacks?
>
> Best,
> Steve MacLean
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Identifying Un-used functions and commands

Mark Wieder via use-livecode
I think he wants it the other way around, identifying handlers and
functions that aren't called by any other handler. I've done this, but only
one at a time, by searching for the handler name across all open stacks. If
the only occurrence is the handler itself ("on/function whatever", ) then
it's unused.

The method here would probably be to get a list of all handlers and
functions and then do a global search for instances of each. If there's one
or more that isn't the handler declaration, it's used.
--
Jacqueline Landman Gay | [hidden email]
HyperActive Software | http://www.hyperactivesw.com
On November 25, 2019 11:51:14 AM dunbarx--- via use-livecode
<[hidden email]> wrote:

> Hi.
> This was posted a couple of weeks ago, no?
> I suggested then that you could write a short handler that loops through
> all the scripts in all the controls on all the cards, and isolate words
> that are not preceded by either "command", "on" or "function". In this way
> you might see, for example, that "myGadget3" may be present in scripts here
> and there, but there is no "on myGadget3" anywhere. Then you will have
> found an unused handler call.
> This may require tweaking. For example, LC will compile, say:
> "on         myGadget3"  -- spaces galore
>
> Craig
>
> -----Original Message-----
> From: Bob Sneidar via use-livecode <[hidden email]>
> To: How to use LiveCode <[hidden email]>
> Cc: Bob Sneidar <[hidden email]>
> Sent: Mon, Nov 25, 2019 12:29 pm
> Subject: Re: Identifying Un-used functions and commands
>
> Since there is code in the script editor that knows the location of any
> command or function you right click on, if you found out how they do that,
> you would be well on your way to developing a way to grok it. Also, GLX2
> has a "clairvoyance" (Auto-Complete) function that is handler aware. I
> suspect Mark Wieder developed a method for getting a list of all handlers
> in a stack that is opened. That would probably help too.
>
> Bob S
>
>
>> On Nov 12, 2019, at 09:12 , Stephen MacLean via use-livecode
>> <[hidden email]> wrote:
>>
>>
>> Hi All,
>>
>>
>> I’m wondering if anyone has a way or code to identify any un-used functions
>> and commands in a set of stacks?
>>
>>
>> Best,
>> Steve MacLean
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Identifying Un-used functions and commands

Mark Wieder via use-livecode
revRefactor has a very nice "orphan Code..." feature

https://github.com/mwieder/revRefactor/tree/master/Plugin


On 11/25/2019 1:08 PM, J. Landman Gay via use-livecode wrote:

> I think he wants it the other way around, identifying handlers and
> functions that aren't called by any other handler. I've done this, but
> only one at a time, by searching for the handler name across all open
> stacks. If the only occurrence is the handler itself ("on/function
> whatever", ) then it's unused.
>
> The method here would probably be to get a list of all handlers and
> functions and then do a global search for instances of each. If
> there's one or more that isn't the handler declaration, it's used.
> --
> Jacqueline Landman Gay | [hidden email]
> HyperActive Software | http://www.hyperactivesw.com
> On November 25, 2019 11:51:14 AM dunbarx--- via use-livecode
> <[hidden email]> wrote:
>
>> Hi.
>> This was posted a couple of weeks ago, no?
>> I suggested then that you could write a short handler that loops
>> through all the scripts in all the controls on all the cards, and
>> isolate words that are not preceded by either "command", "on" or
>> "function". In this way you might see, for example, that "myGadget3"
>> may be present in scripts here and there, but there is no "on
>> myGadget3" anywhere. Then you will have found an unused handler call.
>> This may require tweaking. For example, LC will compile, say:
>> "on         myGadget3"  -- spaces galore
>>
>> Craig
>>
>> -----Original Message-----
>> From: Bob Sneidar via use-livecode <[hidden email]>
>> To: How to use LiveCode <[hidden email]>
>> Cc: Bob Sneidar <[hidden email]>
>> Sent: Mon, Nov 25, 2019 12:29 pm
>> Subject: Re: Identifying Un-used functions and commands
>>
>> Since there is code in the script editor that knows the location of
>> any command or function you right click on, if you found out how they
>> do that, you would be well on your way to developing a way to grok
>> it. Also, GLX2 has a "clairvoyance" (Auto-Complete) function that is
>> handler aware. I suspect Mark Wieder developed a method for getting a
>> list of all handlers in a stack that is opened. That would probably
>> help too.
>>
>> Bob S
>>
>>
>>> On Nov 12, 2019, at 09:12 , Stephen MacLean via use-livecode
>>> <[hidden email]> wrote:
>>>
>>>
>>> Hi All,
>>>
>>>
>>> I’m wondering if anyone has a way or code to identify any un-used
>>> functions and commands in a set of stacks?
>>>
>>>
>>> Best,
>>> Steve MacLean
>>>
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> [hidden email]
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Identifying Un-used functions and commands

Mark Wieder via use-livecode
In reply to this post by Mark Wieder via use-livecode
Jacque,
Ah. You may be right.
So, Steve, which way, or do you need both? The methodology is basically the same.
Craig


-----Original Message-----
From: J. Landman Gay via use-livecode <[hidden email]>
To: How to use LiveCode <[hidden email]>
Cc: J. Landman Gay <[hidden email]>
Sent: Mon, Nov 25, 2019 1:09 pm
Subject: Re: Identifying Un-used functions and commands

I think he wants it the other way around, identifying handlers and
functions that aren't called by any other handler. I've done this, but only
one at a time, by searching for the handler name across all open stacks. If
the only occurrence is the handler itself ("on/function whatever", ) then
it's unused.

The method here would probably be to get a list of all handlers and
functions and then do a global search for instances of each. If there's one
or more that isn't the handler declaration, it's used.
--
Jacqueline Landman Gay | [hidden email]
HyperActive Software | http://www.hyperactivesw.com
On November 25, 2019 11:51:14 AM dunbarx--- via use-livecode
<[hidden email]> wrote:

> Hi.
> This was posted a couple of weeks ago, no?
> I suggested then that you could write a short handler that loops through
> all the scripts in all the controls on all the cards, and isolate words
> that are not preceded by either "command", "on" or "function". In this way
> you might see, for example, that "myGadget3" may be present in scripts here
> and there, but there is no "on myGadget3" anywhere. Then you will have
> found an unused handler call.
> This may require tweaking. For example, LC will compile, say:
> "on        myGadget3"  -- spaces galore
>
> Craig
>
> -----Original Message-----
> From: Bob Sneidar via use-livecode <[hidden email]>
> To: How to use LiveCode <[hidden email]>
> Cc: Bob Sneidar <[hidden email]>
> Sent: Mon, Nov 25, 2019 12:29 pm
> Subject: Re: Identifying Un-used functions and commands
>
> Since there is code in the script editor that knows the location of any
> command or function you right click on, if you found out how they do that,
> you would be well on your way to developing a way to grok it. Also, GLX2
> has a "clairvoyance" (Auto-Complete) function that is handler aware. I
> suspect Mark Wieder developed a method for getting a list of all handlers
> in a stack that is opened. That would probably help too.
>
> Bob S
>
>
>> On Nov 12, 2019, at 09:12 , Stephen MacLean via use-livecode
>> <[hidden email]> wrote:
>>
>>
>> Hi All,
>>
>>
>> I’m wondering if anyone has a way or code to identify any un-used functions
>> and commands in a set of stacks?
>>
>>
>> Best,
>> Steve MacLean
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Identifying Un-used functions and commands

Mark Wieder via use-livecode
In reply to this post by Mark Wieder via use-livecode
> Date: Tue, 12 Nov 2019 12:12:47 -0500
> From: Stephen MacLean <[hidden email]>
> To: How to use LiveCode <[hidden email]>
> Subject: Identifying Un-used functions and commands
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=utf-8

> Hi All,

> I?m wondering if anyone has a way or code to identify any un-used functions and commands in a set of stacks?

Finding explicit function/command calls seems like it should be a fairly straightforward task. However, the "do" keyword can also be a source of function/command calls, which complicates matters a wee bit. You'll also need to evaluate all the non-cleartext components that can go into "do" statements—
do (VariableName)
do (the WhateverProp of ThisObject)
do (line 4 of fld "ThisField")
—etc etc etc.
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Identifying Un-used functions and commands

Mark Wieder via use-livecode
Quentin Long wrote:

 > Finding explicit function/command calls seems like it should be a
 > fairly straightforward task. However, the "do" keyword can also be
 > a source of function/command calls, which complicates matters a
 > wee bit. You'll also need to evaluate all the non-cleartext components
 > that can go into "do" statements—
 > do (VariableName)
 > do (the WhateverProp of ThisObject)
 > do (line 4 of fld "ThisField")
 > —etc etc etc.

There are many reasons to resort to "do" only after all other more
with-the-grain approaches cannot be made to work.

That it eludes static code analysis is just one more.

If I get around to tidying up my old orphan-finder and adding it to
other code base management tools in devolution, I wouldn't bother
attempting to handle "do" cases.  Low ROI, and not handling them helps
draw attention to the technical debt many uses of "do" accrue.

--
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  [hidden email]                http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Identifying Un-used functions and commands

Mark Wieder via use-livecode
On 11/28/19 8:25 AM, Richard Gaskin via use-livecode wrote:

> Quentin Long wrote:
>
>  > Finding explicit function/command calls seems like it should be a
>  > fairly straightforward task. However, the "do" keyword can also be
>  > a source of function/command calls, which complicates matters a
>  > wee bit. You'll also need to evaluate all the non-cleartext components
>  > that can go into "do" statements—
>  > do (VariableName)
>  > do (the WhateverProp of ThisObject)
>  > do (line 4 of fld "ThisField")
>  > —etc etc etc.
>
> There are many reasons to resort to "do" only after all other more
> with-the-grain approaches cannot be made to work.
>
> That it eludes static code analysis is just one more.
>
> If I get around to tidying up my old orphan-finder and adding it to
> other code base management tools in devolution, I wouldn't bother
> attempting to handle "do" cases.  Low ROI, and not handling them helps
> draw attention to the technical debt many uses of "do" accrue.
>

Somewhat similar problem with "send" and "dispatch" commands as well.
You can alleviate this a bit during parsing by seeing if what follows
the "do" or "send" or "dispatch [function]" command is a quoted string.

--
  Mark Wieder
  [hidden email]

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Identifying Un-used functions and commands

Mark Wieder via use-livecode
We should verify whether we're looking for orphaned handlers or orphaned
calls. If it's handlers I'd do something like:

Scan all scripts for "end" & space to get a list of handlers
Remove duplicates
Scan all scripts for each handler name and keep a count

If there's only two instances of the handler name, it's an orphan.

--
Jacqueline Landman Gay | [hidden email]
HyperActive Software | http://www.hyperactivesw.com
On November 28, 2019 11:05:56 AM Mark Wieder via use-livecode
<[hidden email]> wrote:

> On 11/28/19 8:25 AM, Richard Gaskin via use-livecode wrote:
>> Quentin Long wrote:
>>
>>  > Finding explicit function/command calls seems like it should be a
>>  > fairly straightforward task. However, the "do" keyword can also be
>>  > a source of function/command calls, which complicates matters a
>>  > wee bit. You'll also need to evaluate all the non-cleartext components
>>  > that can go into "do" statements—
>>  > do (VariableName)
>>  > do (the WhateverProp of ThisObject)
>>  > do (line 4 of fld "ThisField")
>>  > —etc etc etc.
>>
>> There are many reasons to resort to "do" only after all other more
>> with-the-grain approaches cannot be made to work.
>>
>> That it eludes static code analysis is just one more.
>>
>> If I get around to tidying up my old orphan-finder and adding it to
>> other code base management tools in devolution, I wouldn't bother
>> attempting to handle "do" cases.  Low ROI, and not handling them helps
>> draw attention to the technical debt many uses of "do" accrue.
>>
>
> Somewhat similar problem with "send" and "dispatch" commands as well.
> You can alleviate this a bit during parsing by seeing if what follows
> the "do" or "send" or "dispatch [function]" command is a quoted string.
>
> --
>  Mark Wieder
>  [hidden email]
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Identifying Un-used functions and commands

Mark Wieder via use-livecode
On 11/28/19 9:52 AM, J. Landman Gay via use-livecode wrote:
> We should verify whether we're looking for orphaned handlers or orphaned
> calls. If it's handlers I'd do something like:
>
> Scan all scripts for "end" & space to get a list of handlers
> Remove duplicates
> Scan all scripts for each handler name and keep a count
>
> If there's only two instances of the handler name, it's an orphan.

Um. No. It's a bit more complicated.
Removing duplicates without keeping track of the object script wouldn't
catch handlers of the same name in different scripts. And you'd want to
eliminate system messages from the list so that a closeStack handler,
for instance, wouldn't show up as an orphan.

--
  Mark Wieder
  [hidden email]

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode