Configuration | Rules 4.2.1.6.13 SA0150: Violations of lower or upper limits of the metrics | SA0150: Violations of lower or upper limits of the metrics Sample: The metric "Number of calls" is enabled and configured in the metrics configuration enabled (PLC Project Properties > category "Static Analysis" > "Metrics" tab). Lower limit: 0 Upper limit: 3 Function block Prog1 is called 5 times When performing the static analysis, a violation of SA0150 is reported as an error or warning in the error list. // => SA0150: Metric violation for 'Prog1'. Result for metric 'Calls' (5) > 3" 4.2.1.6.14 SA0160: Recursive calls | SA0160:
Recursive calls This rule can only be checked using the Command 'Run static analysis' [ } 110] command, not using the “Check all objects” option. Example 1: Method FB_Sample.SampleMethod1: METHOD SampleMethod1 VAR_INPUT END_VAR SampleMethod1(); (* => SA0160: Recursive call: 'MAIN -> FB_Sample.SampleMethod1 -> FB_Sample.SampleMethod1' *) Method FB_Sample.SampleMethod2: METHOD SampleMethod2 : BOOL VAR_INPUT END_VAR SampleMethod2 := THIS^.SampleMethod2();(* => SA0160: Recursive call: 'MAIN -> FB_Sample.SampleMethod2 -> FB_Sample.SampleMethod2' *) MAIN program: PROGRAM MAIN VAR fbSample : FB_Sample; bReturn : BOOL; END_VAR fbSample.SampleMethod1(); bReturn := fbSample.SampleMethod2(); Example 2:
Please note regarding properties: TE1200 71 Version: 2.11.1 Function Determines function blocks that violate the enabled metrics at the lower or upper limit. Reason Code that adheres to certain metrics is easier to read, easier to maintain and easier to test. Importance High PLCopen rule CP9 Function Determines recursive calls of programs, actions, methods and properties. Determines possible recursions through virtual function calls and interface calls. Reason Recursions lead to non-deterministic behavior and are therefore a source of errors. Importance Medium PLCopen rule CP13