class
IScriptMetrics.
IScriptMetrics
Bases: object
Scripting API to build metrics table results.
get_all_metrics
Returns the available and valid metrics names.
The available metric queries.
IList
full_metrics_table
contextNodeUri=None
Starts the Code Analysis and returns the full metrics table.
contextNodeUri (string) -- The context node uri of a folder in application tree, if only a specific part of the application should be analyzed. If not set, the whole application or POU area (in case of a library) is analyzed.
The metrics result table.
metrics_table
ruleset_object
contextNodeUri=None
Starts the Code Analysis and returns the metrics table for requested ruleset object
ruleset_object (IScriptRuleSet) -- The ruleset object to analyze.
contextNodeUri (string) -- The context node uri of a folder in application tree, if only a specific part of the application should be analyzed. If not set, the whole application or POU area (in case of a library) is analyzed.
The metrics result table.
metrics_table_from_query_chain_names
query_chain_names
contextNodeUri=None
Starts the Code Analysis and returns the metrics table for requested query chains.
query_chain_names (IEnumerable<string>) -- The names of the query chains to execute.
contextNodeUri (string) -- The context node uri of a folder in application tree, if only a specific part of the application should be analyzed. If not set, the whole application or POU area (in case of a library) is analyzed.
The metrics result table.
The example shows how a metrics table for Commented Variables metrics can be created.
active_app = projects.primary.active_application
# Get a list of the available metrics query chains
all_metrics = projects.primary.active_application.code_analysis.metrics.get_all_metrics()
# Filter for the Commented Variables metrics
commented_variables_metrics = filter(lambda x: x.startswith('Commented Variables'), all_metrics)
# Create metrics table for the Commented Variables metrics
metrics_table = active_app.code_analysis.metrics.metrics_table_from_query_chain_names(commented_variables_metrics)
# Store a html report of the metrics table
metrics_table.store_as_html(r"c:\Temp\MetricsResultReport.html")
metrics_table_from_query_chain_name
query_chain_name
contextNodeUri=None
Starts the Code Analysis and returns the metrics table for requested query chain.
query_chain_name (string) -- Name of the query chain.
contextNodeUri (string) -- The context node uri of a folder in application tree, if only a specific part of the application should be analyzed. If not set, the whole application or POU area (in case of a library) is analyzed.
The metrics result table.
The example shows how a metrics table for a specific metric can be created.
active_app = projects.primary.active_application
# Create metrics table with single selected query chain
metrics_table = active_app.code_analysis.metrics.metrics_table_from_query_chain_name('ST Cyclomatic Complexity')
# Store a html report of the metrics table
metrics_table.store_as_html(r"c:\Temp\MetricsResultReport.html")
metrics_table_from_ruleset_name
ruleset_name
contextNodeUri=None
Starts the Code Analysis and returns the metrics table for requested ruleset.
ruleset_name (string) -- The name of the ruleset to analyze.
contextNodeUri (string) -- The context node uri of a folder in application tree, if only a specific part of the application should be analyzed. If not set, the whole application or POU area (in case of a library) is analyzed.
The metrics result table.
The example shows how a metrics table for the Schneider Electric Basic Rules metrics can be created.
active_app = projects.primary.active_application
# Create conventions table with conventions in the Schneider Electric Basic Rules
conventions_table = active_app.code_analysis.conventions.conventions_table_from_ruleset_name('Schneider Electric Basic Rules')
# Store a html report of the conventions table
conventions_table.store_as_html(r"c:\Temp\MetricsResultReport.html")
metrics_table_from_query_chain_object
query_chain_object
contextNodeUri=None
Starts the Code Analysis and returns the metrics table for requested query_chain object.
query_chain_object (IScriptQueryChain) -- The query chain object to analyze.
contextNodeUri (string) -- The context node uri of a folder in application tree, if only a specific part of the application should be analyzed. If not set, the whole application or POU area (in case of a library) is analyzed.
The metrics result table.
metrics_table_from_ruleset_object
ruleset_object
contextNodeUri=None
Starts the Code Analysis and returns the metrics table for requested ruleset object.
ruleset_object (IScriptRuleSet) -- The ruleset object to analyze.
contextNodeUri (string) -- The context node uri of a folder in application tree, if only a specific part of the application should be analyzed. If not set, the whole application or POU area (in case of a library) is analyzed.
The metrics result table.