Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Static Code Analysis

aconley
2024-02-15
2024-03-20
  • aconley - 2024-02-15

    I'm using CODESYS 3.5 SP16 Patch 6. I would like to incorporate static code analysis as part of our CI/CD pipeline.
    1. Is there a way to execute the static code check from the command line or python script?
    2. If you can't do it from the command line, is there a way to export the results from the application?

     
  • k4zz - 2024-03-15

    I've already experimented with two methods, but unfortunately, they only function with projects of type *.project. Consequently, when executing:

    system.commands["staticanalysis", "run"].execute()
    

    For the 2nd Option: You'll need to ensure that in the Static Analysis Settings, the option "Perform static analysis automatically after compilation" is checked.

    # get Project values
    myProject = projects.primary
    
    # Creates an active application
    app = myProject.active_application
    
    # build Application and run static code analysis 
    app.generate_code()
    
     
  • k4zz - 2024-03-20

    The Solution.

    For Projects:

        #check all pool objects
        system.commands["project", "buildactiveapp"]
    
        #run static analysis
        system.commands["staticanalysis", "run"].execute()
    

    For Libraries:

        #check all pool objects
        system.commands["project", "buildactiveapp"]
    
        #run static analysis
        system.commands["staticanalysis", "runforlibrary"].execute()
    
     
  • k4zz - 2024-03-20
     

    Last edit: k4zz 2024-03-20

Log in to post a comment.