1. Jhonnatan Cordova
  2. PowerBuilder
  3. Monday, 19 June 2023 17:42 PM UTC

I 'm looking for a code analysis tool that can be used with PB?. For example:

-check for objects without a library comment

- check naming convention for objects

- check for script header

- check naming convention for functions and variables

- check for unused local variables

 

 
John Fauss Accepted Answer Pending Moderation
  1. Monday, 19 June 2023 18:25 PM UTC
  2. PowerBuilder
  3. # 1

https://www.visual-expert.com/

It may or may not satisfy all of your criteria, but it's worth taking a look at.

Best regards, John

Comment
  1. John Fauss
  2. Thursday, 22 June 2023 13:45 PM UTC
Hi, Benjamin - I agree. I'm not suggesting anyone should make large-scale code changes in their applications just to conform to Hungarian notation... Jhonnatan's question was simply "Do you use variable convention?" and that's what I replied to. Every software developer, as a professional, should utilize the highest coding standards when writing NEW code that conforms to their employer's policies and conventions. Unless you are assigned the task of raising the coding standards in a working, production app, I think you should leave existing code untouched whenever possible.
  1. Helpful
  1. Benjamin Gaesslein
  2. Friday, 23 June 2023 06:46 AM UTC
I meant no disrespect and hope you didn't take it that way. Just making light of the fact that we all have to work with what we're given.
  1. Helpful
  1. John Fauss
  2. Monday, 26 June 2023 13:33 PM UTC
Thank you for clarifying, Benjamin - We're all good. I very much appreciate everything you add to the Community!
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Tuesday, 20 June 2023 16:58 PM UTC
  2. PowerBuilder
  3. # 2

Classdefinition is your friend, but you'll have to write your own tool to run through all of the objects of all of your libraries.

Comment
  1. Miguel Leeuwe
  2. Tuesday, 20 June 2023 20:00 PM UTC
  1. Helpful
  1. Miguel Leeuwe
  2. Tuesday, 20 June 2023 20:45 PM UTC
Using that code, I built myself an app to check on all text labels in our application and add them to some language tables that we manage. My code is very chaotic (bad) though, so I'd rather see you look at Arthur's code.
  1. Helpful
  1. Miguel Leeuwe
  2. Wednesday, 21 June 2023 04:15 AM UTC
Added a valid download link in the initial answer I gave.

https://www.dropbox.com/s/zw80ivhdv7vkm4v/Mob.zip?dl=1

  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Tuesday, 20 June 2023 20:42 PM UTC
  2. PowerBuilder
  3. # 3

A more helpful example is probably an app made by Arthur Hefti: https://community.appeon.com/index.php/articles-blogs/tutorials-articles/2-powerbuilder/130-the-class-definition-object-part-2

Regretfully, I don't know where part-1 is and the dropbox link doesn't work. There is a TXT file attached though, that might be helpful.

[EDIT] Thank you Chris! Part 1 is here:

https://community.appeon.com/index.php/articles-blogs/tutorials-articles/2-powerbuilder/129-the-classdefinition-object-part-1 

 

Here are the links for the download of the source code:

https://www.catsoft.ch/en/

https://www.dropbox.com/s/zw80ivhdv7vkm4v/Mob.zip?dl=1

 

 

I've sent an email asking if the code is still available and will post it here if so.

regards

Comment
  1. Miguel Leeuwe
  2. Tuesday, 20 June 2023 21:05 PM UTC
Great! Thanks for that.

I just also found this weird page on CodeXchange where the text is somewhere in the middle without any title.

https://community.appeon.com/index.php/articles/tutorials-articles/2-powerbuilder/129-the-classdefinition-object-part-1

  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Thursday, 22 June 2023 08:09 AM UTC
  2. PowerBuilder
  3. # 4

We have written our own code analysis tool and also use it in CI/CD.

It's not very difficult to write if you know how inheritance in PB works. There are some traps you have to work around.

Our tool is quite small. The main window with all of analysis code has 3000 lines in export.

 

How to start:

  • You need the library list (e.g. by reading PBT).
  • Get content of PBLs using LibraryDirectoryEx. If you have the object list(s) you can check for duplicate objects, for correct object naming and for objects comments.
  • Use FindClassDefinition function to get the classdefinition of an object (useable only for object types that have a classdefinition!).
  • With the classdefinition you can check scripts, variables, functions, events, controls, ...
  • There is no indicator for usage of local variables. You have to write it yourself. You have to parse the script (it is part of the scriptdefinition object).
  • To check for script header you have also to look into script.

 

One more tip: PB caches classdefinitions! Do not try to analyse different applications in one instance.

 

HTH,

René

Comment
  1. Jhonnatan Cordova
  2. Tuesday, 4 July 2023 22:24 PM UTC
How to use your code analysis tool in CI/DI? Invoke it through the command line and send it as an argument the folder where the libraries are?
  1. Helpful
  1. René Ullrich
  2. Wednesday, 5 July 2023 05:33 AM UTC
We can use our tool with command line parameters. One parameter is to specify the PBT file for the application to scan.

Other parameters are

- INI file with settings for the scan (e.g. DB connection if you want to check datawindow SQL or naming conventions)

- PDF file to export the scan result

Depending on scan result we close the application with an errorlevel.

  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.