Static Code Analysis

aconley
2024-02-15
2024-08-06
  • 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()
    
     
    πŸ‘
    1
  • k4zz - 2024-03-20
     

    Last edit: k4zz 2024-03-20
    • gauravthelkar - 2024-08-06

      Can you please help on my query below?

       

      Last edit: gauravthelkar 2024-08-06
    • gauravthelkar - 2024-08-06
       

      Last edit: gauravthelkar 2024-08-06
    • gauravthelkar - 2024-08-06
       

      Last edit: gauravthelkar 2024-08-06
    • gauravthelkar - 2024-08-06
       

      Last edit: gauravthelkar 2024-08-06
    • gauravthelkar - 2024-08-06
       

      Last edit: gauravthelkar 2024-08-06
    • gauravthelkar - 2024-08-06
       

      Last edit: gauravthelkar 2024-08-06
    • gauravthelkar - 2024-08-06
       

      Last edit: gauravthelkar 2024-08-06
    • gauravthelkar - 2024-08-06
       

      Last edit: gauravthelkar 2024-08-06
    • gauravthelkar - 2024-08-06
       

      Last edit: gauravthelkar 2024-08-06
  • gauravthelkar - 2024-08-05

    I am using the codesys V3.5 patch 7 64 bit. I have to write the python script for running the static analysis with loading standard rule .CSA file.
    how can we load the .csa rules file before running the static analysis command.

     

    Last edit: gauravthelkar 2024-08-05

Log in to post a comment.